mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-06-13 14:01:01 +00:00
Generated
+8
@@ -2886,6 +2886,7 @@ dependencies = [
|
|||||||
"semver 1.0.26",
|
"semver 1.0.26",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"temp-dir",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2909,6 +2910,7 @@ dependencies = [
|
|||||||
"revive-dt-config",
|
"revive-dt-config",
|
||||||
"revive-dt-node-interaction",
|
"revive-dt-node-interaction",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"temp-dir",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3527,6 +3529,12 @@ version = "1.0.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
|
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "temp-dir"
|
||||||
|
version = "0.1.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bc1ee6eef34f12f765cb94725905c6312b6610ab2b0940889cfe58dae7bc3c72"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tempfile"
|
name = "tempfile"
|
||||||
version = "3.19.1"
|
version = "3.19.1"
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ semver = { version = "1.0", features = ["serde"] }
|
|||||||
serde = { version = "1.0", default-features = false, features = ["derive"] }
|
serde = { version = "1.0", default-features = false, features = ["derive"] }
|
||||||
serde_json = { version = "1.0", default-features = false, features = ["arbitrary_precision", "std"] }
|
serde_json = { version = "1.0", default-features = false, features = ["arbitrary_precision", "std"] }
|
||||||
sha2 = { version = "0.10.8" }
|
sha2 = { version = "0.10.8" }
|
||||||
|
temp-dir = { version = "0.1.14" }
|
||||||
tokio = { version = "1", default-features = false, features = ["rt-multi-thread"] }
|
tokio = { version = "1", default-features = false, features = ["rt-multi-thread"] }
|
||||||
|
|
||||||
# revive compiler
|
# revive compiler
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//! The global configuration used accross all revive differential testing crates.
|
//! The global configuration used accross all revive differential testing crates.
|
||||||
|
|
||||||
use std::{env, path::PathBuf};
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
@@ -18,8 +18,10 @@ pub struct Arguments {
|
|||||||
pub corpus: Vec<PathBuf>,
|
pub corpus: Vec<PathBuf>,
|
||||||
|
|
||||||
/// A place to store temporary artifacts during test execution.
|
/// A place to store temporary artifacts during test execution.
|
||||||
#[arg(long = "workdir", short, default_value_t = cwd())]
|
///
|
||||||
pub working_directory: String,
|
/// Creates a temporary dir if not specified.
|
||||||
|
#[arg(long = "workdir", short)]
|
||||||
|
pub working_directory: Option<PathBuf>,
|
||||||
|
|
||||||
/// The path to the `geth` executable.
|
/// The path to the `geth` executable.
|
||||||
///
|
///
|
||||||
@@ -40,13 +42,6 @@ pub struct Arguments {
|
|||||||
pub genesis_file: Option<PathBuf>,
|
pub genesis_file: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cwd() -> String {
|
|
||||||
env::current_dir()
|
|
||||||
.expect("should be able to access current woring directory")
|
|
||||||
.to_string_lossy()
|
|
||||||
.to_string()
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for Arguments {
|
impl Default for Arguments {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Arguments::parse_from(["retester"])
|
Arguments::parse_from(["retester"])
|
||||||
|
|||||||
@@ -27,3 +27,4 @@ rayon = { workspace = true }
|
|||||||
semver = { workspace = true }
|
semver = { workspace = true }
|
||||||
serde = { workspace = true, features = [ "derive" ] }
|
serde = { workspace = true, features = [ "derive" ] }
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
|
temp-dir = { workspace = true }
|
||||||
|
|||||||
@@ -6,15 +6,22 @@ use rayon::prelude::*;
|
|||||||
use revive_dt_config::*;
|
use revive_dt_config::*;
|
||||||
use revive_dt_core::driver::compiler::build_evm;
|
use revive_dt_core::driver::compiler::build_evm;
|
||||||
use revive_dt_format::corpus::Corpus;
|
use revive_dt_format::corpus::Corpus;
|
||||||
|
use temp_dir::TempDir;
|
||||||
|
|
||||||
fn main() -> anyhow::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
|
|
||||||
let config = Arguments::parse();
|
let mut config = Arguments::parse();
|
||||||
|
|
||||||
if config.corpus.is_empty() {
|
if config.corpus.is_empty() {
|
||||||
anyhow::bail!("no test corpus specified");
|
anyhow::bail!("no test corpus specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 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)?;
|
||||||
|
|||||||
@@ -15,3 +15,6 @@ serde_json = { workspace = true }
|
|||||||
|
|
||||||
revive-dt-node-interaction = { workspace = true }
|
revive-dt-node-interaction = { workspace = true }
|
||||||
revive-dt-config = { workspace = true }
|
revive-dt-config = { workspace = true }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
temp-dir = { workspace = true }
|
||||||
|
|||||||
+16
-4
@@ -54,7 +54,11 @@ impl Instance {
|
|||||||
|
|
||||||
/// Create a new uninitialized instance.
|
/// Create a new uninitialized instance.
|
||||||
pub fn new(config: &Arguments) -> anyhow::Result<Self> {
|
pub fn new(config: &Arguments) -> anyhow::Result<Self> {
|
||||||
let geth_directory = PathBuf::from(&config.working_directory).join(Self::BASE_DIRECTORY);
|
let geth_directory = config
|
||||||
|
.working_directory
|
||||||
|
.as_ref()
|
||||||
|
.ok_or_else(|| anyhow::anyhow!("config did not provide working directory"))?
|
||||||
|
.join(Self::BASE_DIRECTORY);
|
||||||
let id = NODE_COUNT.fetch_add(1, Ordering::SeqCst);
|
let id = NODE_COUNT.fetch_add(1, Ordering::SeqCst);
|
||||||
let base_directory = geth_directory.join(id.to_string());
|
let base_directory = geth_directory.join(id.to_string());
|
||||||
|
|
||||||
@@ -218,16 +222,24 @@ impl Drop for Instance {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
use revive_dt_config::Arguments;
|
use revive_dt_config::Arguments;
|
||||||
|
use temp_dir::TempDir;
|
||||||
|
|
||||||
use crate::{GENESIS_JSON, Node};
|
use crate::{GENESIS_JSON, Node};
|
||||||
|
|
||||||
use super::Instance;
|
use super::Instance;
|
||||||
|
|
||||||
|
fn test_config() -> (Arguments, TempDir) {
|
||||||
|
let mut config = Arguments::default();
|
||||||
|
let temp_dir = TempDir::new().unwrap();
|
||||||
|
config.working_directory = temp_dir.path().to_path_buf().into();
|
||||||
|
|
||||||
|
(config, temp_dir)
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn init_works() {
|
fn init_works() {
|
||||||
Instance::new(&Arguments::default())
|
Instance::new(&test_config().0)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.init(GENESIS_JSON.to_string())
|
.init(GENESIS_JSON.to_string())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -235,7 +247,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn spawn_works() {
|
fn spawn_works() {
|
||||||
Instance::new(&Arguments::default())
|
Instance::new(&test_config().0)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.spawn(GENESIS_JSON.to_string())
|
.spawn(GENESIS_JSON.to_string())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|||||||
Reference in New Issue
Block a user