mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-06-14 09:51:08 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8287146003 | |||
| b8cd5d6031 |
@@ -1,12 +1,8 @@
|
|||||||
//! 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 alloy::{
|
use alloy::{
|
||||||
network::TransactionBuilder,
|
primitives::{Address, map::HashMap},
|
||||||
primitives::{Address, bytes::Bytes, map::HashMap},
|
rpc::types::trace::geth::{AccountState, DiffMode, GethTrace},
|
||||||
rpc::types::{
|
|
||||||
TransactionRequest,
|
|
||||||
trace::geth::{AccountState, DiffMode, GethTrace},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
use revive_dt_compiler::{Compiler, CompilerInput, SolidityCompiler};
|
use revive_dt_compiler::{Compiler, CompilerInput, SolidityCompiler};
|
||||||
use revive_dt_config::Arguments;
|
use revive_dt_config::Arguments;
|
||||||
@@ -113,56 +109,6 @@ where
|
|||||||
|
|
||||||
Ok((trace, diff))
|
Ok((trace, diff))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deploy_contracts(&mut self, input: &Input, node: &T::Blockchain) -> anyhow::Result<()> {
|
|
||||||
for output in self.contracts.values() {
|
|
||||||
let Some(contract_map) = &output.contracts else {
|
|
||||||
log::debug!("No contracts in output — skipping deployment for this input.");
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
|
|
||||||
for contracts in contract_map.values() {
|
|
||||||
for (contract_name, contract) in contracts {
|
|
||||||
if contract_name != &input.instance {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let bytecode = contract
|
|
||||||
.evm
|
|
||||||
.as_ref()
|
|
||||||
.and_then(|evm| evm.bytecode.as_ref())
|
|
||||||
.map(|b| b.object.clone());
|
|
||||||
|
|
||||||
let Some(code) = bytecode else {
|
|
||||||
anyhow::bail!("no bytecode for contract `{}`", contract_name);
|
|
||||||
};
|
|
||||||
|
|
||||||
let tx = TransactionRequest::default()
|
|
||||||
.with_from(input.caller)
|
|
||||||
.with_to(Address::ZERO)
|
|
||||||
.with_input(Bytes::from(code.clone()))
|
|
||||||
.with_gas_price(20_000_000_000)
|
|
||||||
.with_gas_limit(20_000_000_000)
|
|
||||||
.with_chain_id(self.config.network_id)
|
|
||||||
.with_nonce(0);
|
|
||||||
|
|
||||||
let receipt = node.execute_transaction(tx)?;
|
|
||||||
let Some(address) = receipt.contract_address else {
|
|
||||||
anyhow::bail!(
|
|
||||||
"contract `{}` deployment did not return an address",
|
|
||||||
contract_name
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
self.deployed_contracts
|
|
||||||
.insert(contract_name.clone(), address);
|
|
||||||
log::info!("deployed contract `{}` at {:?}", contract_name, address);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Driver<'a, Leader: Platform, Follower: Platform> {
|
pub struct Driver<'a, Leader: Platform, Follower: Platform> {
|
||||||
@@ -227,9 +173,6 @@ where
|
|||||||
|
|
||||||
for case in &self.metadata.cases {
|
for case in &self.metadata.cases {
|
||||||
for input in &case.inputs {
|
for input in &case.inputs {
|
||||||
leader_state.deploy_contracts(input, self.leader_node)?;
|
|
||||||
follower_state.deploy_contracts(input, self.follower_node)?;
|
|
||||||
|
|
||||||
let (_, leader_diff) = leader_state.execute_input(input, self.leader_node)?;
|
let (_, leader_diff) = leader_state.execute_input(input, self.leader_node)?;
|
||||||
let (_, follower_diff) =
|
let (_, follower_diff) =
|
||||||
follower_state.execute_input(input, self.follower_node)?;
|
follower_state.execute_input(input, self.follower_node)?;
|
||||||
|
|||||||
+15
-31
@@ -5,7 +5,7 @@ use rayon::{ThreadPoolBuilder, prelude::*};
|
|||||||
|
|
||||||
use revive_dt_config::*;
|
use revive_dt_config::*;
|
||||||
use revive_dt_core::{
|
use revive_dt_core::{
|
||||||
Geth, Kitchensink, Platform,
|
Geth, Kitchensink,
|
||||||
driver::{Driver, State},
|
driver::{Driver, State},
|
||||||
};
|
};
|
||||||
use revive_dt_format::{corpus::Corpus, metadata::Metadata};
|
use revive_dt_format::{corpus::Corpus, metadata::Metadata};
|
||||||
@@ -74,30 +74,28 @@ fn collect_corpora(args: &Arguments) -> anyhow::Result<HashMap<Corpus, Vec<Metad
|
|||||||
Ok(corpora)
|
Ok(corpora)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_driver<L, F>(args: &Arguments, tests: &[Metadata], span: Span) -> anyhow::Result<()>
|
fn execute_corpus(args: &Arguments, tests: &[Metadata], span: Span) -> anyhow::Result<()> {
|
||||||
where
|
let leader_nodes = NodePool::new(args)?;
|
||||||
L: Platform,
|
let follower_nodes = NodePool::new(args)?;
|
||||||
F: Platform,
|
|
||||||
L::Blockchain: revive_dt_node::Node + Send + Sync + 'static,
|
|
||||||
F::Blockchain: revive_dt_node::Node + Send + Sync + 'static,
|
|
||||||
{
|
|
||||||
let leader_nodes = NodePool::<L::Blockchain>::new(args)?;
|
|
||||||
let follower_nodes = NodePool::<F::Blockchain>::new(args)?;
|
|
||||||
|
|
||||||
tests.par_iter().for_each(|metadata| {
|
tests.par_iter().for_each(|metadata| {
|
||||||
let mut driver = Driver::<L, F>::new(
|
let mut driver = match (&args.leader, &args.follower) {
|
||||||
metadata,
|
(TestingPlatform::Geth, TestingPlatform::Kitchensink) => Driver::<Geth, Geth>::new(
|
||||||
args,
|
metadata,
|
||||||
leader_nodes.round_robbin(),
|
args,
|
||||||
follower_nodes.round_robbin(),
|
leader_nodes.round_robbin(),
|
||||||
);
|
follower_nodes.round_robbin(),
|
||||||
|
),
|
||||||
|
_ => unimplemented!(),
|
||||||
|
};
|
||||||
|
|
||||||
match driver.execute(span) {
|
match driver.execute(span) {
|
||||||
Ok(_) => {
|
Ok(build) => {
|
||||||
log::info!(
|
log::info!(
|
||||||
"metadata {} success",
|
"metadata {} success",
|
||||||
metadata.directory().as_ref().unwrap().display()
|
metadata.directory().as_ref().unwrap().display()
|
||||||
);
|
);
|
||||||
|
build
|
||||||
}
|
}
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
log::warn!(
|
log::warn!(
|
||||||
@@ -111,20 +109,6 @@ where
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn execute_corpus(args: &Arguments, tests: &[Metadata], span: Span) -> anyhow::Result<()> {
|
|
||||||
match (&args.leader, &args.follower) {
|
|
||||||
(TestingPlatform::Geth, TestingPlatform::Kitchensink) => {
|
|
||||||
run_driver::<Geth, Kitchensink>(args, tests, span)?
|
|
||||||
}
|
|
||||||
(TestingPlatform::Geth, TestingPlatform::Geth) => {
|
|
||||||
run_driver::<Geth, Geth>(args, tests, span)?
|
|
||||||
}
|
|
||||||
_ => unimplemented!(),
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn compile_corpus(config: &Arguments, tests: &[Metadata], platform: &TestingPlatform, span: Span) {
|
fn compile_corpus(config: &Arguments, tests: &[Metadata], platform: &TestingPlatform, span: Span) {
|
||||||
tests.par_iter().for_each(|metadata| {
|
tests.par_iter().for_each(|metadata| {
|
||||||
for mode in &metadata.solc_modes() {
|
for mode in &metadata.solc_modes() {
|
||||||
|
|||||||
Reference in New Issue
Block a user