deploy tx

Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This commit is contained in:
Cyrill Leutwiler
2025-03-25 17:54:40 +01:00
parent a835754d41
commit 34b8879b15
7 changed files with 141 additions and 18 deletions
+26 -11
View File
@@ -1,14 +1,17 @@
//! The test driver handles the compilation and execution of the test cases.
use alloy::primitives::{Address, map::HashMap};
use alloy::{
primitives::{Address, map::HashMap},
rpc::types::trace::geth::GethTrace,
};
use revive_dt_compiler::{Compiler, CompilerInput, SolidityCompiler};
use revive_dt_config::Arguments;
use revive_dt_format::{
case::Case,
input::Input,
metadata::Metadata,
mode::{Mode, SolcMode},
};
use revive_dt_node::Node;
use revive_dt_node_interaction::EthereumNode;
use revive_dt_solc_binaries::download_solc;
use revive_solc_json_interface::SolcStandardJsonOutput;
@@ -23,7 +26,6 @@ pub struct State<'a, T: Platform> {
config: &'a Arguments,
contracts: Contracts<T>,
deployed_contracts: HashMap<String, Address>,
node: T::Blockchain,
}
impl<'a, T> State<'a, T>
@@ -35,7 +37,6 @@ where
config,
contracts: Default::default(),
deployed_contracts: Default::default(),
node: <T::Blockchain as Node>::new(config),
}
}
@@ -61,10 +62,18 @@ where
Ok(())
}
pub fn execute_case(&mut self, case: &Case) -> anyhow::Result<()> {
for input in &case.inputs {}
Ok(())
pub fn execute_input(
&mut self,
input: &Input,
node: &T::Blockchain,
) -> anyhow::Result<GethTrace> {
let receipt = node.execute_transaction(input.legacy_transaction(
self.config.network_id,
0,
&self.deployed_contracts,
)?)?;
dbg!(&receipt);
Ok(node.trace_transaction(receipt)?)
}
}
@@ -89,7 +98,11 @@ where
}
}
pub fn execute(&mut self) -> anyhow::Result<()> {
pub fn execute(
&mut self,
leader: L::Blockchain,
follower: F::Blockchain,
) -> anyhow::Result<()> {
for mode in self.modes() {
self.leader.build_contracts(&mode, self.metadata)?;
self.follower.build_contracts(&mode, self.metadata)?;
@@ -99,7 +112,9 @@ where
}
for case in &self.metadata.cases {
self.leader.execute_case(case)?;
for input in &case.inputs {
let expected = self.leader.execute_input(input, &leader)?;
}
}
*self = Self::new(self.metadata, self.config);
+16 -4
View File
@@ -1,11 +1,12 @@
use std::collections::BTreeSet;
use clap::Parser;
use rayon::prelude::*;
use rayon::{ThreadPoolBuilder, prelude::*};
use revive_dt_config::*;
use revive_dt_core::{Geth, Kitchensink, driver::Driver};
use revive_dt_format::corpus::Corpus;
use revive_dt_node::{Node, geth};
use temp_dir::TempDir;
fn main() -> anyhow::Result<()> {
@@ -19,23 +20,34 @@ fn main() -> anyhow::Result<()> {
args.temp_dir = TempDir::new()?.into()
}
ThreadPoolBuilder::new()
.num_threads(args.workers)
.build_global()
.unwrap();
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:?}");
let tests = corpus.enumerate_tests();
log::info!("found {} tests", tests.len());
log::info!("corpus '{}' contains {} tests", &corpus.name, tests.len());
tests.par_iter().for_each(|metadata| {
let (leader, follower) = match (&args.leader, &args.follower) {
(TestingPlatform::Geth, TestingPlatform::Kitchensink) => {
(geth::Instance::new(&args), geth::Instance::new(&args))
}
_ => unimplemented!(),
};
let mut driver = match (&args.leader, &args.follower) {
(TestingPlatform::Geth, TestingPlatform::Kitchensink) => {
Driver::<Geth, Kitchensink>::new(metadata, &args)
Driver::<Geth, Geth>::new(metadata, &args)
}
_ => unimplemented!(),
};
match driver.execute() {
match Driver::<Geth, Geth>::new(metadata, &args).execute(leader, follower) {
Ok(build) => {
log::info!(
"metadata {} success",