mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-04-27 16:07:58 +00:00
Remoe all references to leader and follower
This commit is contained in:
@@ -2,13 +2,13 @@ use std::path::PathBuf;
|
||||
|
||||
use revive_dt_common::types::VersionOrRequirement;
|
||||
use revive_dt_compiler::{Compiler, SolidityCompiler, revive_resolc::Resolc, solc::Solc};
|
||||
use revive_dt_config::ExecutionContext;
|
||||
use revive_dt_config::TestExecutionContext;
|
||||
use semver::Version;
|
||||
|
||||
#[tokio::test]
|
||||
async fn contracts_can_be_compiled_with_solc() {
|
||||
// Arrange
|
||||
let args = ExecutionContext::default();
|
||||
let args = TestExecutionContext::default();
|
||||
let solc = Solc::new(&args, VersionOrRequirement::Version(Version::new(0, 8, 30)))
|
||||
.await
|
||||
.unwrap();
|
||||
@@ -49,7 +49,7 @@ async fn contracts_can_be_compiled_with_solc() {
|
||||
#[tokio::test]
|
||||
async fn contracts_can_be_compiled_with_resolc() {
|
||||
// Arrange
|
||||
let args = ExecutionContext::default();
|
||||
let args = TestExecutionContext::default();
|
||||
let resolc = Resolc::new(&args, VersionOrRequirement::Version(Version::new(0, 8, 30)))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
+16
-16
@@ -27,8 +27,8 @@ use temp_dir::TempDir;
|
||||
#[derive(Clone, Debug, Parser, Serialize)]
|
||||
#[command(name = "retester")]
|
||||
pub enum Context {
|
||||
/// Executes tests in the MatterLabs format differentially against a leader and a follower.
|
||||
ExecuteTests(Box<ExecutionContext>),
|
||||
/// Executes tests in the MatterLabs format differentially on multiple targets concurrently.
|
||||
ExecuteTests(Box<TestExecutionContext>),
|
||||
/// Exports the JSON schema of the MatterLabs test format used by the tool.
|
||||
ExportJsonSchema,
|
||||
}
|
||||
@@ -152,7 +152,7 @@ impl AsRef<ReportConfiguration> for Context {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Parser, Serialize)]
|
||||
pub struct ExecutionContext {
|
||||
pub struct TestExecutionContext {
|
||||
/// The working directory that the program will use for all of the temporary artifacts needed at
|
||||
/// runtime.
|
||||
///
|
||||
@@ -219,79 +219,79 @@ pub struct ExecutionContext {
|
||||
pub report_configuration: ReportConfiguration,
|
||||
}
|
||||
|
||||
impl Default for ExecutionContext {
|
||||
impl Default for TestExecutionContext {
|
||||
fn default() -> Self {
|
||||
Self::parse_from(["execution-context"])
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<WorkingDirectoryConfiguration> for ExecutionContext {
|
||||
impl AsRef<WorkingDirectoryConfiguration> for TestExecutionContext {
|
||||
fn as_ref(&self) -> &WorkingDirectoryConfiguration {
|
||||
&self.working_directory
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<SolcConfiguration> for ExecutionContext {
|
||||
impl AsRef<SolcConfiguration> for TestExecutionContext {
|
||||
fn as_ref(&self) -> &SolcConfiguration {
|
||||
&self.solc_configuration
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<ResolcConfiguration> for ExecutionContext {
|
||||
impl AsRef<ResolcConfiguration> for TestExecutionContext {
|
||||
fn as_ref(&self) -> &ResolcConfiguration {
|
||||
&self.resolc_configuration
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<GethConfiguration> for ExecutionContext {
|
||||
impl AsRef<GethConfiguration> for TestExecutionContext {
|
||||
fn as_ref(&self) -> &GethConfiguration {
|
||||
&self.geth_configuration
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<KitchensinkConfiguration> for ExecutionContext {
|
||||
impl AsRef<KitchensinkConfiguration> for TestExecutionContext {
|
||||
fn as_ref(&self) -> &KitchensinkConfiguration {
|
||||
&self.kitchensink_configuration
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<ReviveDevNodeConfiguration> for ExecutionContext {
|
||||
impl AsRef<ReviveDevNodeConfiguration> for TestExecutionContext {
|
||||
fn as_ref(&self) -> &ReviveDevNodeConfiguration {
|
||||
&self.revive_dev_node_configuration
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<EthRpcConfiguration> for ExecutionContext {
|
||||
impl AsRef<EthRpcConfiguration> for TestExecutionContext {
|
||||
fn as_ref(&self) -> &EthRpcConfiguration {
|
||||
&self.eth_rpc_configuration
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<GenesisConfiguration> for ExecutionContext {
|
||||
impl AsRef<GenesisConfiguration> for TestExecutionContext {
|
||||
fn as_ref(&self) -> &GenesisConfiguration {
|
||||
&self.genesis_configuration
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<WalletConfiguration> for ExecutionContext {
|
||||
impl AsRef<WalletConfiguration> for TestExecutionContext {
|
||||
fn as_ref(&self) -> &WalletConfiguration {
|
||||
&self.wallet_configuration
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<ConcurrencyConfiguration> for ExecutionContext {
|
||||
impl AsRef<ConcurrencyConfiguration> for TestExecutionContext {
|
||||
fn as_ref(&self) -> &ConcurrencyConfiguration {
|
||||
&self.concurrency_configuration
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<CompilationConfiguration> for ExecutionContext {
|
||||
impl AsRef<CompilationConfiguration> for TestExecutionContext {
|
||||
fn as_ref(&self) -> &CompilationConfiguration {
|
||||
&self.compilation_configuration
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<ReportConfiguration> for ExecutionContext {
|
||||
impl AsRef<ReportConfiguration> for TestExecutionContext {
|
||||
fn as_ref(&self) -> &ReportConfiguration {
|
||||
&self.report_configuration
|
||||
}
|
||||
|
||||
+17
-10
@@ -112,7 +112,7 @@ fn main() -> anyhow::Result<()> {
|
||||
|
||||
#[instrument(level = "debug", name = "Collecting Corpora", skip_all)]
|
||||
fn collect_corpora(
|
||||
context: &ExecutionContext,
|
||||
context: &TestExecutionContext,
|
||||
) -> anyhow::Result<HashMap<Corpus, Vec<MetadataFile>>> {
|
||||
let mut corpora = HashMap::new();
|
||||
|
||||
@@ -134,7 +134,7 @@ fn collect_corpora(
|
||||
}
|
||||
|
||||
async fn run_driver(
|
||||
context: ExecutionContext,
|
||||
context: TestExecutionContext,
|
||||
metadata_files: &[MetadataFile],
|
||||
reporter: Reporter,
|
||||
report_aggregator_task: impl Future<Output = anyhow::Result<()>>,
|
||||
@@ -143,7 +143,14 @@ async fn run_driver(
|
||||
let mut nodes = Vec::<(&dyn DynPlatform, NodePool)>::new();
|
||||
for platform in platforms.into_iter() {
|
||||
let pool = NodePool::new(Context::ExecuteTests(Box::new(context.clone())), platform)
|
||||
.context("Failed to initialize follower node pool")?;
|
||||
.inspect_err(|err| {
|
||||
error!(
|
||||
%err,
|
||||
platform_identifier = %platform.platform_identifier(),
|
||||
"Failed to initialize the node pool for the platform."
|
||||
)
|
||||
})
|
||||
.context("Failed to initialize the node pool")?;
|
||||
nodes.push((platform, pool));
|
||||
}
|
||||
|
||||
@@ -166,7 +173,7 @@ async fn run_driver(
|
||||
}
|
||||
|
||||
async fn tests_stream<'a>(
|
||||
args: &ExecutionContext,
|
||||
args: &TestExecutionContext,
|
||||
metadata_files: impl IntoIterator<Item = &'a MetadataFile> + Clone,
|
||||
nodes: &'a [(&dyn DynPlatform, NodePool)],
|
||||
reporter: Reporter,
|
||||
@@ -284,7 +291,7 @@ async fn tests_stream<'a>(
|
||||
}
|
||||
|
||||
async fn start_driver_task<'a>(
|
||||
context: &ExecutionContext,
|
||||
context: &TestExecutionContext,
|
||||
tests: impl Stream<Item = Test<'a>>,
|
||||
) -> anyhow::Result<impl Future<Output = ()>> {
|
||||
info!("Starting driver task");
|
||||
@@ -489,7 +496,7 @@ async fn handle_case_driver<'a>(
|
||||
contract_ident: library_ident,
|
||||
} = contract_sources.remove(library_instance)?;
|
||||
|
||||
let (code, leader_abi) = compiler_output
|
||||
let (code, abi) = compiler_output
|
||||
.contracts
|
||||
.get(&library_source_path)
|
||||
.and_then(|contracts| contracts.get(library_ident.as_str()))?;
|
||||
@@ -537,7 +544,7 @@ async fn handle_case_driver<'a>(
|
||||
|
||||
deployed_libraries.get_or_insert_default().insert(
|
||||
library_instance.clone(),
|
||||
(library_ident.clone(), library_address, leader_abi.clone()),
|
||||
(library_ident.clone(), library_address, abi.clone()),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -601,7 +608,7 @@ async fn handle_case_driver<'a>(
|
||||
}
|
||||
|
||||
async fn execute_corpus(
|
||||
context: ExecutionContext,
|
||||
context: TestExecutionContext,
|
||||
tests: &[MetadataFile],
|
||||
reporter: Reporter,
|
||||
report_aggregator_task: impl Future<Output = anyhow::Result<()>>,
|
||||
@@ -703,7 +710,7 @@ impl<'a> Test<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
// Checks for the compatibility of the EVM version with the leader and follower nodes.
|
||||
// Checks for the compatibility of the EVM version with the platforms specified.
|
||||
fn check_evm_version_compatibility(&self) -> TestCheckFunctionResult {
|
||||
let Some(evm_version_requirement) = self.metadata.required_evm_version else {
|
||||
return Ok(());
|
||||
@@ -732,7 +739,7 @@ impl<'a> Test<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks if the leader and follower compilers support the mode that the test is for.
|
||||
/// Checks if the platforms compilers support the mode that the test is for.
|
||||
fn check_compiler_compatibility(&self) -> TestCheckFunctionResult {
|
||||
let mut error_map = indexmap! {
|
||||
"test_desired_evm_version" => json!(self.metadata.required_evm_version),
|
||||
|
||||
@@ -855,11 +855,11 @@ impl Drop for GethNode {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn test_config() -> ExecutionContext {
|
||||
ExecutionContext::default()
|
||||
fn test_config() -> TestExecutionContext {
|
||||
TestExecutionContext::default()
|
||||
}
|
||||
|
||||
fn new_node() -> (ExecutionContext, GethNode) {
|
||||
fn new_node() -> (TestExecutionContext, GethNode) {
|
||||
let context = test_config();
|
||||
let mut node = GethNode::new(&context);
|
||||
node.init(context.genesis_configuration.genesis().unwrap().clone())
|
||||
|
||||
@@ -1300,13 +1300,13 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::Node;
|
||||
|
||||
fn test_config() -> ExecutionContext {
|
||||
let mut context = ExecutionContext::default();
|
||||
fn test_config() -> TestExecutionContext {
|
||||
let mut context = TestExecutionContext::default();
|
||||
context.kitchensink_configuration.use_kitchensink = true;
|
||||
context
|
||||
}
|
||||
|
||||
fn new_node() -> (ExecutionContext, SubstrateNode) {
|
||||
fn new_node() -> (TestExecutionContext, SubstrateNode) {
|
||||
// Note: When we run the tests in the CI we found that if they're all
|
||||
// run in parallel then the CI is unable to start all of the nodes in
|
||||
// time and their start up times-out. Therefore, we want all of the
|
||||
@@ -1340,7 +1340,7 @@ mod tests {
|
||||
|
||||
/// A shared node that multiple tests can use. It starts up once.
|
||||
fn shared_node() -> &'static SubstrateNode {
|
||||
static NODE: LazyLock<(ExecutionContext, SubstrateNode)> = LazyLock::new(|| {
|
||||
static NODE: LazyLock<(TestExecutionContext, SubstrateNode)> = LazyLock::new(|| {
|
||||
let (context, node) = new_node();
|
||||
(context, node)
|
||||
});
|
||||
|
||||
@@ -466,7 +466,7 @@ pub enum TestCaseStatus {
|
||||
},
|
||||
}
|
||||
|
||||
/// Information related to the leader or follower node that's being used to execute the step.
|
||||
/// Information related to the platform node that's being used to execute the step.
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
pub struct TestCaseNodeInformation {
|
||||
/// The ID of the node that this case is being executed on.
|
||||
@@ -477,7 +477,7 @@ pub struct TestCaseNodeInformation {
|
||||
pub connection_string: String,
|
||||
}
|
||||
|
||||
/// Execution information tied to the leader or the follower.
|
||||
/// Execution information tied to the platform.
|
||||
#[derive(Clone, Debug, Default, Serialize)]
|
||||
pub struct ExecutionInformation {
|
||||
/// Information related to the node assigned to this test case.
|
||||
|
||||
@@ -22,7 +22,7 @@ pub struct TestSpecifier {
|
||||
}
|
||||
|
||||
/// An absolute path for a test that also includes information about the node that it's assigned to
|
||||
/// and whether it's the leader or follower.
|
||||
/// and what platform it belongs to.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct ExecutionSpecifier {
|
||||
pub test_specifier: Arc<TestSpecifier>,
|
||||
|
||||
@@ -434,7 +434,7 @@ macro_rules! define_event {
|
||||
}
|
||||
|
||||
/// A reporter that's tied to a specific execution of the test case such as execution on
|
||||
/// a specific node like the leader or follower.
|
||||
/// a specific node from a specific platform.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct [< $ident ExecutionSpecificReporter >] {
|
||||
$vis reporter: [< $ident Reporter >],
|
||||
@@ -520,7 +520,7 @@ define_event! {
|
||||
/// A reason for the failure of the test.
|
||||
reason: String,
|
||||
},
|
||||
/// An event emitted when the test case is assigned a leader node.
|
||||
/// An event emitted when the test case is assigned a platform node.
|
||||
NodeAssigned {
|
||||
/// A specifier for the test that the assignment is for.
|
||||
test_specifier: Arc<TestSpecifier>,
|
||||
|
||||
Reference in New Issue
Block a user