From ea50d567816f1006d24efb0064e4793c052fce20 Mon Sep 17 00:00:00 2001 From: aner-starkware <147302140+aner-starkware@users.noreply.github.com> Date: Sun, 27 Oct 2024 14:55:48 +0200 Subject: [PATCH] build(blockifier_reexecution): add main for tests via cli commands (#1573) --- Cargo.lock | 1 + crates/blockifier_reexecution/Cargo.toml | 1 + crates/blockifier_reexecution/src/main.rs | 39 +++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 crates/blockifier_reexecution/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 9b449abf23..012bf2ab66 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1539,6 +1539,7 @@ dependencies = [ "cairo-lang-starknet-classes", "cairo-lang-utils", "cairo-vm", + "clap", "flate2", "indexmap 2.6.0", "papyrus_execution", diff --git a/crates/blockifier_reexecution/Cargo.toml b/crates/blockifier_reexecution/Cargo.toml index 0a01f21ea9..db4d042c23 100644 --- a/crates/blockifier_reexecution/Cargo.toml +++ b/crates/blockifier_reexecution/Cargo.toml @@ -13,6 +13,7 @@ blockifier.workspace = true cairo-lang-starknet-classes.workspace = true cairo-lang-utils.workspace = true cairo-vm.workspace = true +clap = { workspace = true, features = ["cargo", "derive"] } flate2.workspace = true indexmap = { workspace = true, features = ["serde"] } papyrus_execution.workspace = true diff --git a/crates/blockifier_reexecution/src/main.rs b/crates/blockifier_reexecution/src/main.rs new file mode 100644 index 0000000000..67a6730f60 --- /dev/null +++ b/crates/blockifier_reexecution/src/main.rs @@ -0,0 +1,39 @@ +use clap::{Args, Parser, Subcommand}; + +/// BlockifierReexecution CLI. +#[derive(Debug, Parser)] +#[clap(name = "blockifier-reexecution-cli", version)] +pub struct BlockifierReexecutionCliArgs { + #[clap(flatten)] + global_options: GlobalOptions, + + #[clap(subcommand)] + command: Command, +} + +#[derive(Debug, Subcommand)] +enum Command { + /// Runs the RPC test. + RpcTest { + /// Node url. + /// Default: https://free-rpc.nethermind.io/mainnet-juno/. Won't work for big tests. + #[clap(long, short = 'n', default_value = "https://free-rpc.nethermind.io/mainnet-juno/")] + node_url: String, + + /// Block number. + #[clap(long, short = 'b')] + block_number: u64, + }, +} + +#[derive(Debug, Args)] +struct GlobalOptions {} + +/// Main entry point of the blockifier reexecution CLI. +fn main() { + let args = BlockifierReexecutionCliArgs::parse(); + + match args.command { + Command::RpcTest { .. } => todo!(), // TODO(Aner): Move the RPC test logic here. + } +}