Compare commits

..

1 Commits

Author SHA1 Message Date
Omar Abdulla b8f63321e2 Implement storage empty assertion 2025-08-11 15:24:26 +03:00
12 changed files with 1 additions and 205 deletions
Generated
-2
View File
@@ -4095,7 +4095,6 @@ dependencies = [
"alloy-primitives",
"alloy-sol-types",
"anyhow",
"revive-common",
"revive-dt-common",
"semver 1.0.26",
"serde",
@@ -4110,7 +4109,6 @@ version = "0.1.0"
dependencies = [
"alloy",
"anyhow",
"revive-common",
"revive-dt-common",
"revive-dt-config",
"revive-dt-format",
+1 -1
View File
@@ -8,7 +8,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT/Apache-2.0"
edition = "2024"
repository = "https://github.com/paritytech/revive-differential-testing.git"
rust-version = "1.87.0"
rust-version = "1.85.0"
[workspace.dependencies]
revive-dt-common = { version = "0.1.0", path = "crates/common" }
-2
View File
@@ -550,7 +550,6 @@ where
BalanceAssertion {
address: address_string,
expected_balance: amount,
..
}: &BalanceAssertion,
node: &T::Blockchain,
) -> anyhow::Result<()> {
@@ -610,7 +609,6 @@ where
StorageEmptyAssertion {
address: address_string,
is_storage_empty,
..
}: &StorageEmptyAssertion,
node: &T::Blockchain,
) -> anyhow::Result<()> {
-21
View File
@@ -177,27 +177,6 @@ where
Some(false) | None => true,
},
)
.filter(|(metadata_file_path, metadata, ..)| match metadata.required_evm_version {
Some(evm_version_requirement) => {
let is_allowed = evm_version_requirement
.matches(&<L::Blockchain as revive_dt_node::Node>::evm_version())
&& evm_version_requirement
.matches(&<F::Blockchain as revive_dt_node::Node>::evm_version());
if !is_allowed {
tracing::warn!(
metadata_file_path = %metadata_file_path.display(),
leader_evm_version = %<L::Blockchain as revive_dt_node::Node>::evm_version(),
follower_evm_version = %<F::Blockchain as revive_dt_node::Node>::evm_version(),
version_requirement = %evm_version_requirement,
"Skipped test since the EVM version requirement was not fulfilled."
);
}
is_allowed
}
None => true,
})
.collect::<Vec<_>>();
let metadata_case_status = Arc::new(RwLock::new(test_cases.iter().fold(
-2
View File
@@ -11,8 +11,6 @@ rust-version.workspace = true
[dependencies]
revive-dt-common = { workspace = true }
revive-common = { workspace = true }
alloy = { workspace = true }
alloy-primitives = { workspace = true }
alloy-sol-types = { workspace = true }
-6
View File
@@ -9,19 +9,13 @@ use crate::{
#[derive(Debug, Default, Serialize, Deserialize, Clone, Eq, PartialEq)]
pub struct Case {
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub modes: Option<Vec<Mode>>,
#[serde(rename = "inputs")]
pub steps: Vec<Step>,
#[serde(skip_serializing_if = "Option::is_none")]
pub group: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub expected: Option<Expected>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ignore: Option<bool>,
}
-17
View File
@@ -36,29 +36,20 @@ pub enum Step {
pub struct Input {
#[serde(default = "Input::default_caller")]
pub caller: Address,
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
#[serde(default = "Input::default_instance")]
pub instance: ContractInstance,
pub method: Method,
#[serde(default)]
pub calldata: Calldata,
#[serde(skip_serializing_if = "Option::is_none")]
pub expected: Option<Expected>,
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<EtherValue>,
#[serde(skip_serializing_if = "Option::is_none")]
pub storage: Option<HashMap<String, Calldata>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub variable_assignments: Option<VariableAssignments>,
}
#[derive(Clone, Debug, Default, Serialize, Deserialize, Eq, PartialEq)]
pub struct BalanceAssertion {
/// An optional comment on the balance assertion.
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
/// The address that the balance assertion should be done on.
///
/// This is a string which will be resolved into an address when being processed. Therefore,
@@ -73,10 +64,6 @@ pub struct BalanceAssertion {
#[derive(Clone, Debug, Default, Serialize, Deserialize, Eq, PartialEq)]
pub struct StorageEmptyAssertion {
/// An optional comment on the storage empty assertion.
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
/// The address that the balance assertion should be done on.
///
/// This is a string which will be resolved into an address when being processed. Therefore,
@@ -99,11 +86,8 @@ pub enum Expected {
#[derive(Clone, Debug, Default, Serialize, Deserialize, Eq, PartialEq)]
pub struct ExpectedOutput {
#[serde(skip_serializing_if = "Option::is_none")]
pub compiler_version: Option<VersionReq>,
#[serde(skip_serializing_if = "Option::is_none")]
pub return_data: Option<Calldata>,
#[serde(skip_serializing_if = "Option::is_none")]
pub events: Option<Vec<Event>>,
#[serde(default)]
pub exception: bool,
@@ -111,7 +95,6 @@ pub struct ExpectedOutput {
#[derive(Clone, Debug, Default, Serialize, Deserialize, Eq, PartialEq)]
pub struct Event {
#[serde(skip_serializing_if = "Option::is_none")]
pub address: Option<String>,
pub topics: Vec<String>,
pub values: Calldata,
-139
View File
@@ -1,5 +1,4 @@
use std::{
cmp::Ordering,
collections::BTreeMap,
fmt::Display,
fs::{File, read_to_string},
@@ -10,7 +9,6 @@ use std::{
use serde::{Deserialize, Serialize};
use revive_common::EVMVersion;
use revive_dt_common::{iterators::FilesWithExtensionIterator, macros::define_wrapper_type};
use crate::{
@@ -47,25 +45,13 @@ impl Deref for MetadataFile {
#[derive(Debug, Default, Serialize, Deserialize, Clone, Eq, PartialEq)]
pub struct Metadata {
#[serde(skip_serializing_if = "Option::is_none")]
pub targets: Option<Vec<String>>,
pub cases: Vec<Case>,
#[serde(skip_serializing_if = "Option::is_none")]
pub contracts: Option<BTreeMap<ContractInstance, ContractPathAndIdent>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub libraries: Option<BTreeMap<PathBuf, BTreeMap<ContractIdent, ContractInstance>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ignore: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub modes: Option<Vec<Mode>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub file_path: Option<PathBuf>,
/// This field specifies an EVM version requirement that the test case has
/// where the test might be run of the evm version of the nodes match the
/// evm version specified here.
#[serde(skip_serializing_if = "Option::is_none")]
pub required_evm_version: Option<EvmVersionRequirement>,
}
impl Metadata {
@@ -356,131 +342,6 @@ impl From<ContractPathAndIdent> for String {
}
}
/// An EVM version requirement that the test case has. This gets serialized and
/// deserialized from and into [`String`].
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[serde(try_from = "String", into = "String")]
pub struct EvmVersionRequirement {
ordering: Ordering,
or_equal: bool,
evm_version: EVMVersion,
}
impl EvmVersionRequirement {
pub fn new_greater_than_or_equals(version: EVMVersion) -> Self {
Self {
ordering: Ordering::Greater,
or_equal: true,
evm_version: version,
}
}
pub fn new_greater_than(version: EVMVersion) -> Self {
Self {
ordering: Ordering::Greater,
or_equal: false,
evm_version: version,
}
}
pub fn new_equals(version: EVMVersion) -> Self {
Self {
ordering: Ordering::Equal,
or_equal: false,
evm_version: version,
}
}
pub fn new_less_than(version: EVMVersion) -> Self {
Self {
ordering: Ordering::Less,
or_equal: false,
evm_version: version,
}
}
pub fn new_less_than_or_equals(version: EVMVersion) -> Self {
Self {
ordering: Ordering::Less,
or_equal: true,
evm_version: version,
}
}
pub fn matches(&self, other: &EVMVersion) -> bool {
let ordering = other.cmp(&self.evm_version);
ordering == self.ordering || (self.or_equal && matches!(ordering, Ordering::Equal))
}
}
impl Display for EvmVersionRequirement {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let Self {
ordering,
or_equal,
evm_version,
} = self;
match ordering {
Ordering::Less => write!(f, "<")?,
Ordering::Equal => write!(f, "=")?,
Ordering::Greater => write!(f, ">")?,
}
if *or_equal && !matches!(ordering, Ordering::Equal) {
write!(f, "=")?;
}
write!(f, "{evm_version}")
}
}
impl FromStr for EvmVersionRequirement {
type Err = anyhow::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.as_bytes() {
[b'>', b'=', remaining @ ..] => Ok(Self {
ordering: Ordering::Greater,
or_equal: true,
evm_version: str::from_utf8(remaining)?.try_into()?,
}),
[b'>', remaining @ ..] => Ok(Self {
ordering: Ordering::Greater,
or_equal: false,
evm_version: str::from_utf8(remaining)?.try_into()?,
}),
[b'<', b'=', remaining @ ..] => Ok(Self {
ordering: Ordering::Less,
or_equal: true,
evm_version: str::from_utf8(remaining)?.try_into()?,
}),
[b'<', remaining @ ..] => Ok(Self {
ordering: Ordering::Less,
or_equal: false,
evm_version: str::from_utf8(remaining)?.try_into()?,
}),
[b'=', remaining @ ..] => Ok(Self {
ordering: Ordering::Equal,
or_equal: false,
evm_version: str::from_utf8(remaining)?.try_into()?,
}),
_ => anyhow::bail!("Invalid EVM version requirement {s}"),
}
}
}
impl TryFrom<String> for EvmVersionRequirement {
type Error = anyhow::Error;
fn try_from(value: String) -> Result<Self, Self::Error> {
value.parse()
}
}
impl From<EvmVersionRequirement> for String {
fn from(value: EvmVersionRequirement) -> Self {
value.to_string()
}
}
#[cfg(test)]
mod test {
use super::*;
-1
View File
@@ -14,7 +14,6 @@ alloy = { workspace = true }
tracing = { workspace = true }
tokio = { workspace = true }
revive-common = { workspace = true }
revive-dt-common = { workspace = true }
revive-dt-config = { workspace = true }
revive-dt-format = { workspace = true }
-5
View File
@@ -32,7 +32,6 @@ use alloy::{
signers::local::PrivateKeySigner,
};
use anyhow::Context;
use revive_common::EVMVersion;
use tracing::{Instrument, Level};
use revive_dt_common::{fs::clear_directory, futures::poll};
@@ -580,10 +579,6 @@ impl Node for GethNode {
Some(targets) => targets.iter().any(|str| str.as_str() == "evm"),
}
}
fn evm_version() -> EVMVersion {
EVMVersion::Cancun
}
}
impl Drop for GethNode {
-5
View File
@@ -32,7 +32,6 @@ use alloy::{
signers::local::PrivateKeySigner,
};
use anyhow::Context;
use revive_common::EVMVersion;
use revive_dt_common::fs::clear_directory;
use revive_dt_format::traits::ResolverApi;
use serde::{Deserialize, Serialize};
@@ -639,10 +638,6 @@ impl Node for KitchensinkNode {
Some(targets) => targets.iter().any(|str| str.as_str() == "pvm"),
}
}
fn evm_version() -> EVMVersion {
EVMVersion::Cancun
}
}
impl Drop for KitchensinkNode {
-4
View File
@@ -1,6 +1,5 @@
//! This crate implements the testing nodes.
use revive_common::EVMVersion;
use revive_dt_config::Arguments;
use revive_dt_node_interaction::EthereumNode;
@@ -37,7 +36,4 @@ pub trait Node: EthereumNode {
/// Given a list of targets from the metadata file, this function determines if the metadata
/// file can be ran on this node or not.
fn matches_target(&self, targets: Option<&[String]>) -> bool;
/// Returns the EVM version of the node.
fn evm_version() -> EVMVersion;
}