From 66eb7359204a82af12022980cd5c28dc3d071e80 Mon Sep 17 00:00:00 2001 From: matias-gonz Date: Wed, 7 Aug 2024 15:36:52 +0300 Subject: [PATCH 1/3] Add test l1 contracts --- .../src/commands/test/l1_contracts.rs | 18 ++++++++++++++++++ .../zk_supervisor/src/commands/test/mod.rs | 8 ++++++-- .../crates/zk_supervisor/src/messages.rs | 3 +++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 zk_toolbox/crates/zk_supervisor/src/commands/test/l1_contracts.rs diff --git a/zk_toolbox/crates/zk_supervisor/src/commands/test/l1_contracts.rs b/zk_toolbox/crates/zk_supervisor/src/commands/test/l1_contracts.rs new file mode 100644 index 000000000000..f5eb272f97ae --- /dev/null +++ b/zk_toolbox/crates/zk_supervisor/src/commands/test/l1_contracts.rs @@ -0,0 +1,18 @@ +use common::{cmd::Cmd, logger, spinner::Spinner}; +use config::EcosystemConfig; +use xshell::{cmd, Shell}; + +use crate::messages::{MSG_L1_CONTRACTS_TEST_SPINNER, MSG_L1_CONTRACTS_TEST_SUCCESS}; + +pub fn run(shell: &Shell) -> anyhow::Result<()> { + let ecosystem = EcosystemConfig::from_file(shell)?; + let _dir_guard = shell.push_dir(&ecosystem.link_to_code); + + let spinner = Spinner::new(MSG_L1_CONTRACTS_TEST_SPINNER); + Cmd::new(cmd!(shell, "yarn l1-contracts test")).run()?; + spinner.finish(); + + logger::outro(MSG_L1_CONTRACTS_TEST_SUCCESS); + + Ok(()) +} diff --git a/zk_toolbox/crates/zk_supervisor/src/commands/test/mod.rs b/zk_toolbox/crates/zk_supervisor/src/commands/test/mod.rs index b66a7eaefc4c..094bd880a016 100644 --- a/zk_toolbox/crates/zk_supervisor/src/commands/test/mod.rs +++ b/zk_toolbox/crates/zk_supervisor/src/commands/test/mod.rs @@ -3,12 +3,13 @@ use clap::Subcommand; use xshell::Shell; use crate::messages::{ - MSG_INTEGRATION_TESTS_ABOUT, MSG_RECOVERY_TEST_ABOUT, MSG_REVERT_TEST_ABOUT, - MSG_UPGRADE_TEST_ABOUT, + MSG_INTEGRATION_TESTS_ABOUT, MSG_L1_CONTRACTS_ABOUT, MSG_RECOVERY_TEST_ABOUT, + MSG_REVERT_TEST_ABOUT, MSG_UPGRADE_TEST_ABOUT, }; mod args; mod integration; +mod l1_contracts; mod recovery; mod revert; mod upgrade; @@ -23,6 +24,8 @@ pub enum TestCommands { Recovery(RecoveryArgs), #[clap(about = MSG_UPGRADE_TEST_ABOUT, alias = "u")] Upgrade, + #[clap(about = MSG_L1_CONTRACTS_ABOUT, alias = "l1")] + L1Contracts, } pub fn run(shell: &Shell, args: TestCommands) -> anyhow::Result<()> { @@ -31,5 +34,6 @@ pub fn run(shell: &Shell, args: TestCommands) -> anyhow::Result<()> { TestCommands::Revert(args) => revert::run(shell, args), TestCommands::Recovery(args) => recovery::run(shell, args), TestCommands::Upgrade => upgrade::run(shell), + TestCommands::L1Contracts => l1_contracts::run(shell), } } diff --git a/zk_toolbox/crates/zk_supervisor/src/messages.rs b/zk_toolbox/crates/zk_supervisor/src/messages.rs index 116775072594..62a42e18932e 100644 --- a/zk_toolbox/crates/zk_supervisor/src/messages.rs +++ b/zk_toolbox/crates/zk_supervisor/src/messages.rs @@ -77,6 +77,9 @@ pub(super) const MSG_UPGRADE_TEST_ABOUT: &str = "Run upgrade tests"; pub(super) const MSG_TESTS_EXTERNAL_NODE_HELP: &str = "Run tests for external node"; pub(super) const MSG_TESTS_RECOVERY_SNAPSHOT_HELP: &str = "Run recovery from a snapshot instead of genesis"; +pub(super) const MSG_L1_CONTRACTS_ABOUT: &str = "Run L1 contracts tests"; +pub(super) const MSG_L1_CONTRACTS_TEST_SPINNER: &str = "Running L1 contracts tests..."; +pub(super) const MSG_L1_CONTRACTS_TEST_SUCCESS: &str = "L1 contracts tests ran successfully"; // Integration tests related messages pub(super) fn msg_integration_tests_run(external_node: bool) -> String { From a986d81c170bf301dc73d3620929c79788a72fee Mon Sep 17 00:00:00 2001 From: matias-gonz Date: Mon, 12 Aug 2024 10:38:26 +0300 Subject: [PATCH 2/3] Add matias-zk-toolbox-l1-contracts-tests --- .../zk_supervisor/src/commands/test/l1_contracts.rs | 10 +++++----- zk_toolbox/crates/zk_supervisor/src/messages.rs | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/zk_toolbox/crates/zk_supervisor/src/commands/test/l1_contracts.rs b/zk_toolbox/crates/zk_supervisor/src/commands/test/l1_contracts.rs index f5eb272f97ae..0a1e1ec5203f 100644 --- a/zk_toolbox/crates/zk_supervisor/src/commands/test/l1_contracts.rs +++ b/zk_toolbox/crates/zk_supervisor/src/commands/test/l1_contracts.rs @@ -1,16 +1,16 @@ -use common::{cmd::Cmd, logger, spinner::Spinner}; +use common::{cmd::Cmd, logger}; use config::EcosystemConfig; use xshell::{cmd, Shell}; -use crate::messages::{MSG_L1_CONTRACTS_TEST_SPINNER, MSG_L1_CONTRACTS_TEST_SUCCESS}; +use crate::messages::MSG_L1_CONTRACTS_TEST_SUCCESS; pub fn run(shell: &Shell) -> anyhow::Result<()> { let ecosystem = EcosystemConfig::from_file(shell)?; let _dir_guard = shell.push_dir(&ecosystem.link_to_code); - let spinner = Spinner::new(MSG_L1_CONTRACTS_TEST_SPINNER); - Cmd::new(cmd!(shell, "yarn l1-contracts test")).run()?; - spinner.finish(); + Cmd::new(cmd!(shell, "yarn l1-contracts test")) + .with_force_run() + .run()?; logger::outro(MSG_L1_CONTRACTS_TEST_SUCCESS); diff --git a/zk_toolbox/crates/zk_supervisor/src/messages.rs b/zk_toolbox/crates/zk_supervisor/src/messages.rs index 62a42e18932e..203dfcfb4ff4 100644 --- a/zk_toolbox/crates/zk_supervisor/src/messages.rs +++ b/zk_toolbox/crates/zk_supervisor/src/messages.rs @@ -78,7 +78,6 @@ pub(super) const MSG_TESTS_EXTERNAL_NODE_HELP: &str = "Run tests for external no pub(super) const MSG_TESTS_RECOVERY_SNAPSHOT_HELP: &str = "Run recovery from a snapshot instead of genesis"; pub(super) const MSG_L1_CONTRACTS_ABOUT: &str = "Run L1 contracts tests"; -pub(super) const MSG_L1_CONTRACTS_TEST_SPINNER: &str = "Running L1 contracts tests..."; pub(super) const MSG_L1_CONTRACTS_TEST_SUCCESS: &str = "L1 contracts tests ran successfully"; // Integration tests related messages From 7408b37502e7feedf138946ac9ff9c1d5a082351 Mon Sep 17 00:00:00 2001 From: matias-gonz Date: Mon, 12 Aug 2024 14:27:56 +0300 Subject: [PATCH 3/3] fmt --- .../zk_inception/src/commands/ecosystem/args/create.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zk_toolbox/crates/zk_inception/src/commands/ecosystem/args/create.rs b/zk_toolbox/crates/zk_inception/src/commands/ecosystem/args/create.rs index 24cf4e3b4a10..4063f4ccdcd2 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/ecosystem/args/create.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/ecosystem/args/create.rs @@ -65,9 +65,9 @@ impl EcosystemCreateArgs { } }); - let l1_network = self.l1_network.unwrap_or_else(|| { - PromptSelect::new(MSG_L1_NETWORK_PROMPT, L1Network::iter()).ask() - }); + let l1_network = self + .l1_network + .unwrap_or_else(|| PromptSelect::new(MSG_L1_NETWORK_PROMPT, L1Network::iter()).ask()); // Make the only chain as a default one self.chain.set_as_default = Some(true);