mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-04-22 06:47:56 +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.
|
||||
#[arg(long = "genesis-file")]
|
||||
pub genesis_file: Option<PathBuf>,
|
||||
|
||||
/// The signing account private key.
|
||||
#[arg(
|
||||
short,
|
||||
long = "account",
|
||||
default_value = "0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d"
|
||||
)]
|
||||
pub account: String,
|
||||
}
|
||||
|
||||
impl Default for Arguments {
|
||||
|
||||
@@ -19,31 +19,21 @@ pub struct SolcSettings {
|
||||
pub fn build_evm(
|
||||
metadata: &Metadata,
|
||||
) -> anyhow::Result<HashMap<SolcSettings, SolcStandardJsonOutput>> {
|
||||
let Some(metadata_path) = &metadata.path else {
|
||||
anyhow::bail!("missing directory in metadata");
|
||||
};
|
||||
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 sources = metadata.contract_sources()?;
|
||||
let base_path = metadata.directory()?.display().to_string();
|
||||
let modes = metadata
|
||||
.modes
|
||||
.to_owned()
|
||||
.unwrap_or_else(|| vec![Mode::Solidity(Default::default())]);
|
||||
|
||||
let sources = super::contract_sources_from_metadata(directory, contracts)?;
|
||||
|
||||
let mut result = HashMap::new();
|
||||
for mode in modes {
|
||||
let mut compiler = Compiler::<Solc>::new().base_path(directory.display().to_string());
|
||||
for file in sources.values() {
|
||||
let mut compiler = Compiler::<Solc>::new().base_path(base_path.clone());
|
||||
for (file, _contract) in sources.values() {
|
||||
compiler = compiler.with_source(file)?;
|
||||
}
|
||||
|
||||
match mode {
|
||||
Mode::Unknown(mode) => log::debug!("compiler: ignoring unknown mode '{mode}'"),
|
||||
Mode::Solidity(SolcMode {
|
||||
solc_version: _,
|
||||
solc_optimize,
|
||||
@@ -61,6 +51,7 @@ pub fn build_evm(
|
||||
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.
|
||||
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
pub mod compiler;
|
||||
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
|
||||
//! provides a helper utilty to execute tests.
|
||||
//!
|
||||
//!
|
||||
|
||||
pub mod driver;
|
||||
|
||||
+23
-21
@@ -11,18 +11,14 @@ use temp_dir::TempDir;
|
||||
fn main() -> anyhow::Result<()> {
|
||||
env_logger::init();
|
||||
|
||||
let mut config = Arguments::parse();
|
||||
|
||||
if config.corpus.is_empty() {
|
||||
let mut args = Arguments::parse();
|
||||
if args.corpus.is_empty() {
|
||||
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()?;
|
||||
config
|
||||
.working_directory
|
||||
.get_or_insert_with(|| temporary_directory.path().into());
|
||||
|
||||
for path in config.corpus.iter().collect::<BTreeSet<_>>() {
|
||||
for path in args.corpus.iter().collect::<BTreeSet<_>>() {
|
||||
log::trace!("attempting corpus {path:?}");
|
||||
let corpus = Corpus::try_from_path(path)?;
|
||||
log::info!("found corpus: {corpus:?}");
|
||||
@@ -30,18 +26,24 @@ fn main() -> anyhow::Result<()> {
|
||||
let tests = corpus.enumerate_tests();
|
||||
log::info!("found {} tests", tests.len());
|
||||
|
||||
tests
|
||||
.par_iter()
|
||||
.for_each(|metadata| match build_evm(metadata) {
|
||||
Ok(_) => log::info!(
|
||||
"metadata {} compilation success",
|
||||
metadata.path.as_ref().unwrap().display()
|
||||
),
|
||||
Err(error) => log::warn!(
|
||||
"metadata {} compilation failure: {error:?}",
|
||||
metadata.path.as_ref().unwrap().display()
|
||||
),
|
||||
});
|
||||
tests.par_iter().for_each(|metadata| {
|
||||
let _ = match build_evm(metadata) {
|
||||
Ok(build) => {
|
||||
log::info!(
|
||||
"metadata {} compilation success",
|
||||
metadata.file_path.as_ref().unwrap().display()
|
||||
);
|
||||
build
|
||||
}
|
||||
Err(error) => {
|
||||
log::warn!(
|
||||
"metadata {} compilation failure: {error:?}",
|
||||
metadata.file_path.as_ref().unwrap().display()
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -18,10 +18,47 @@ pub struct Metadata {
|
||||
pub libraries: Option<BTreeMap<String, BTreeMap<String, String>>>,
|
||||
pub ignore: Option<bool>,
|
||||
pub modes: Option<Vec<Mode>>,
|
||||
pub path: Option<PathBuf>,
|
||||
pub file_path: Option<PathBuf>,
|
||||
}
|
||||
|
||||
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`.
|
||||
///
|
||||
/// 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 {
|
||||
return None;
|
||||
//return Self::try_from_solidity(path);
|
||||
return Self::try_from_solidity(path);
|
||||
}
|
||||
|
||||
log::debug!("ignoring invalid corpus file: {}", path.display());
|
||||
@@ -61,7 +97,7 @@ impl Metadata {
|
||||
|
||||
match serde_json::from_reader::<_, Metadata>(file) {
|
||||
Ok(mut metadata) => {
|
||||
metadata.path = Some(path.to_path_buf());
|
||||
metadata.file_path = Some(path.to_path_buf());
|
||||
Some(metadata)
|
||||
}
|
||||
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