mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-06-12 13:31:06 +00:00
add dev account to config
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This commit is contained in:
@@ -40,6 +40,14 @@ pub struct Arguments {
|
|||||||
/// Configure nodes according to this genesis.json file.
|
/// Configure nodes according to this genesis.json file.
|
||||||
#[arg(long = "genesis-file")]
|
#[arg(long = "genesis-file")]
|
||||||
pub genesis_file: Option<PathBuf>,
|
pub genesis_file: Option<PathBuf>,
|
||||||
|
|
||||||
|
/// The signing account private key.
|
||||||
|
#[arg(
|
||||||
|
short,
|
||||||
|
long = "account",
|
||||||
|
default_value = "0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d"
|
||||||
|
)]
|
||||||
|
pub account: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Arguments {
|
impl Default for Arguments {
|
||||||
|
|||||||
@@ -19,31 +19,21 @@ pub struct SolcSettings {
|
|||||||
pub fn build_evm(
|
pub fn build_evm(
|
||||||
metadata: &Metadata,
|
metadata: &Metadata,
|
||||||
) -> anyhow::Result<HashMap<SolcSettings, SolcStandardJsonOutput>> {
|
) -> anyhow::Result<HashMap<SolcSettings, SolcStandardJsonOutput>> {
|
||||||
let Some(metadata_path) = &metadata.path else {
|
let sources = metadata.contract_sources()?;
|
||||||
anyhow::bail!("missing directory in metadata");
|
let base_path = metadata.directory()?.display().to_string();
|
||||||
};
|
|
||||||
let Some(directory) = metadata_path.parent() else {
|
|
||||||
anyhow::bail!("metadata path has no parent: {}", metadata_path.display());
|
|
||||||
};
|
|
||||||
let Some(contracts) = &metadata.contracts else {
|
|
||||||
anyhow::bail!("missing contracts in metadata: {}", metadata_path.display());
|
|
||||||
};
|
|
||||||
let modes = metadata
|
let modes = metadata
|
||||||
.modes
|
.modes
|
||||||
.to_owned()
|
.to_owned()
|
||||||
.unwrap_or_else(|| vec![Mode::Solidity(Default::default())]);
|
.unwrap_or_else(|| vec![Mode::Solidity(Default::default())]);
|
||||||
|
|
||||||
let sources = super::contract_sources_from_metadata(directory, contracts)?;
|
|
||||||
|
|
||||||
let mut result = HashMap::new();
|
let mut result = HashMap::new();
|
||||||
for mode in modes {
|
for mode in modes {
|
||||||
let mut compiler = Compiler::<Solc>::new().base_path(directory.display().to_string());
|
let mut compiler = Compiler::<Solc>::new().base_path(base_path.clone());
|
||||||
for file in sources.values() {
|
for (file, _contract) in sources.values() {
|
||||||
compiler = compiler.with_source(file)?;
|
compiler = compiler.with_source(file)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
match mode {
|
match mode {
|
||||||
Mode::Unknown(mode) => log::debug!("compiler: ignoring unknown mode '{mode}'"),
|
|
||||||
Mode::Solidity(SolcMode {
|
Mode::Solidity(SolcMode {
|
||||||
solc_version: _,
|
solc_version: _,
|
||||||
solc_optimize,
|
solc_optimize,
|
||||||
@@ -61,6 +51,7 @@ pub fn build_evm(
|
|||||||
out,
|
out,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Mode::Unknown(mode) => log::debug!("compiler: ignoring unknown mode '{mode}'"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +1,4 @@
|
|||||||
//! The test driver handles the compilation and execution of the test cases.
|
//! The test driver handles the compilation and execution of the test cases.
|
||||||
|
|
||||||
use std::{
|
|
||||||
collections::BTreeMap,
|
|
||||||
path::{Path, PathBuf},
|
|
||||||
};
|
|
||||||
|
|
||||||
pub mod compiler;
|
pub mod compiler;
|
||||||
pub mod input;
|
pub mod input;
|
||||||
|
|
||||||
pub(crate) fn contract_sources_from_metadata(
|
|
||||||
directory: &Path,
|
|
||||||
contracts: &BTreeMap<String, String>,
|
|
||||||
) -> anyhow::Result<BTreeMap<String, PathBuf>> {
|
|
||||||
let mut sources = BTreeMap::new();
|
|
||||||
for (name, contract) in contracts {
|
|
||||||
// TODO: broken if a colon is in the dir name..
|
|
||||||
let Some(solidity_file_name) = contract.split(':').next() else {
|
|
||||||
anyhow::bail!("metadata contains invalid contract: {contract}");
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut file = directory.to_path_buf();
|
|
||||||
file.push(solidity_file_name);
|
|
||||||
sources.insert(name.clone(), file);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(sources)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,5 +2,7 @@
|
|||||||
//!
|
//!
|
||||||
//! This crate defines the testing configuration and
|
//! This crate defines the testing configuration and
|
||||||
//! provides a helper utilty to execute tests.
|
//! provides a helper utilty to execute tests.
|
||||||
|
//!
|
||||||
|
//!
|
||||||
|
|
||||||
pub mod driver;
|
pub mod driver;
|
||||||
|
|||||||
+23
-21
@@ -11,18 +11,14 @@ use temp_dir::TempDir;
|
|||||||
fn main() -> anyhow::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
|
|
||||||
let mut config = Arguments::parse();
|
let mut args = Arguments::parse();
|
||||||
|
if args.corpus.is_empty() {
|
||||||
if config.corpus.is_empty() {
|
|
||||||
anyhow::bail!("no test corpus specified");
|
anyhow::bail!("no test corpus specified");
|
||||||
}
|
}
|
||||||
|
let temp_dir = TempDir::new()?;
|
||||||
|
args.working_directory.get_or_insert(temp_dir.path().into());
|
||||||
|
|
||||||
let temporary_directory = TempDir::new()?;
|
for path in args.corpus.iter().collect::<BTreeSet<_>>() {
|
||||||
config
|
|
||||||
.working_directory
|
|
||||||
.get_or_insert_with(|| temporary_directory.path().into());
|
|
||||||
|
|
||||||
for path in config.corpus.iter().collect::<BTreeSet<_>>() {
|
|
||||||
log::trace!("attempting corpus {path:?}");
|
log::trace!("attempting corpus {path:?}");
|
||||||
let corpus = Corpus::try_from_path(path)?;
|
let corpus = Corpus::try_from_path(path)?;
|
||||||
log::info!("found corpus: {corpus:?}");
|
log::info!("found corpus: {corpus:?}");
|
||||||
@@ -30,18 +26,24 @@ fn main() -> anyhow::Result<()> {
|
|||||||
let tests = corpus.enumerate_tests();
|
let tests = corpus.enumerate_tests();
|
||||||
log::info!("found {} tests", tests.len());
|
log::info!("found {} tests", tests.len());
|
||||||
|
|
||||||
tests
|
tests.par_iter().for_each(|metadata| {
|
||||||
.par_iter()
|
let _ = match build_evm(metadata) {
|
||||||
.for_each(|metadata| match build_evm(metadata) {
|
Ok(build) => {
|
||||||
Ok(_) => log::info!(
|
log::info!(
|
||||||
"metadata {} compilation success",
|
"metadata {} compilation success",
|
||||||
metadata.path.as_ref().unwrap().display()
|
metadata.file_path.as_ref().unwrap().display()
|
||||||
),
|
);
|
||||||
Err(error) => log::warn!(
|
build
|
||||||
"metadata {} compilation failure: {error:?}",
|
}
|
||||||
metadata.path.as_ref().unwrap().display()
|
Err(error) => {
|
||||||
),
|
log::warn!(
|
||||||
});
|
"metadata {} compilation failure: {error:?}",
|
||||||
|
metadata.file_path.as_ref().unwrap().display()
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -18,10 +18,47 @@ pub struct Metadata {
|
|||||||
pub libraries: Option<BTreeMap<String, BTreeMap<String, String>>>,
|
pub libraries: Option<BTreeMap<String, BTreeMap<String, String>>>,
|
||||||
pub ignore: Option<bool>,
|
pub ignore: Option<bool>,
|
||||||
pub modes: Option<Vec<Mode>>,
|
pub modes: Option<Vec<Mode>>,
|
||||||
pub path: Option<PathBuf>,
|
pub file_path: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Metadata {
|
impl Metadata {
|
||||||
|
/// Returns the base directory of this metadata.
|
||||||
|
pub fn directory(&self) -> anyhow::Result<PathBuf> {
|
||||||
|
Ok(self
|
||||||
|
.file_path
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|path| path.parent())
|
||||||
|
.ok_or_else(|| anyhow::anyhow!("metadata invalid file path: {:?}", self.file_path))?
|
||||||
|
.to_path_buf())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Extract the contract sources.
|
||||||
|
///
|
||||||
|
/// Returns a mapping of contract IDs to their source path and contract name.
|
||||||
|
pub fn contract_sources(&self) -> anyhow::Result<BTreeMap<String, (PathBuf, String)>> {
|
||||||
|
let directory = self.directory()?;
|
||||||
|
let mut sources = BTreeMap::new();
|
||||||
|
let Some(contracts) = &self.contracts else {
|
||||||
|
return Ok(sources);
|
||||||
|
};
|
||||||
|
|
||||||
|
for (id, contract) in contracts {
|
||||||
|
// TODO: broken if a colon is in the dir name..
|
||||||
|
let mut parts = contract.split(':');
|
||||||
|
let (Some(file_name), Some(contract_name)) = (parts.next(), parts.next()) else {
|
||||||
|
anyhow::bail!("metadata contains invalid contract: {contract}");
|
||||||
|
};
|
||||||
|
let file = directory.to_path_buf().join(file_name);
|
||||||
|
if !file.is_file() {
|
||||||
|
anyhow::bail!("contract {id} is not a file: {}", file.display());
|
||||||
|
}
|
||||||
|
|
||||||
|
sources.insert(id.clone(), (file, contract_name.to_string()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(sources)
|
||||||
|
}
|
||||||
|
|
||||||
/// Try to parse the test metadata struct from the given file at `path`.
|
/// Try to parse the test metadata struct from the given file at `path`.
|
||||||
///
|
///
|
||||||
/// Returns `None` if `path` didn't contain a test metadata or case definition.
|
/// Returns `None` if `path` didn't contain a test metadata or case definition.
|
||||||
@@ -41,8 +78,7 @@ impl Metadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if file_extension == SOLIDITY_CASE_FILE_EXTENSION {
|
if file_extension == SOLIDITY_CASE_FILE_EXTENSION {
|
||||||
return None;
|
return Self::try_from_solidity(path);
|
||||||
//return Self::try_from_solidity(path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log::debug!("ignoring invalid corpus file: {}", path.display());
|
log::debug!("ignoring invalid corpus file: {}", path.display());
|
||||||
@@ -61,7 +97,7 @@ impl Metadata {
|
|||||||
|
|
||||||
match serde_json::from_reader::<_, Metadata>(file) {
|
match serde_json::from_reader::<_, Metadata>(file) {
|
||||||
Ok(mut metadata) => {
|
Ok(mut metadata) => {
|
||||||
metadata.path = Some(path.to_path_buf());
|
metadata.file_path = Some(path.to_path_buf());
|
||||||
Some(metadata)
|
Some(metadata)
|
||||||
}
|
}
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"config": {
|
||||||
|
"chainId": 420420420,
|
||||||
|
"homesteadBlock": 0,
|
||||||
|
"eip150Block": 0,
|
||||||
|
"eip155Block": 0,
|
||||||
|
"eip158Block": 0,
|
||||||
|
"byzantiumBlock": 0,
|
||||||
|
"constantinopleBlock": 0,
|
||||||
|
"petersburgBlock": 0,
|
||||||
|
"istanbulBlock": 0,
|
||||||
|
"berlinBlock": 0,
|
||||||
|
"londonBlock": 0,
|
||||||
|
"arrowGlacierBlock": 0,
|
||||||
|
"grayGlacierBlock": 0,
|
||||||
|
"shanghaiTime": 0,
|
||||||
|
"cancunTime": 0,
|
||||||
|
"terminalTotalDifficulty": 0,
|
||||||
|
"terminalTotalDifficultyPassed": true,
|
||||||
|
"blobSchedule": {
|
||||||
|
"cancun": {
|
||||||
|
"target": 3,
|
||||||
|
"max": 6,
|
||||||
|
"baseFeeUpdateFraction": 3338477
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"coinbase": "0xffffffffffffffffffffffffffffffffffffffff",
|
||||||
|
"difficulty": "0x00",
|
||||||
|
"extraData": "",
|
||||||
|
"gasLimit": "0xffffffff",
|
||||||
|
"nonce": "0x0000000000000042",
|
||||||
|
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
|
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
|
"timestamp": "0x00",
|
||||||
|
"alloc": {
|
||||||
|
"90F8bf6A479f320ead074411a4B0e7944Ea8c9C1": {
|
||||||
|
"balance": "1000000000000000000"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user