Skip to main content

revme/
cmd.rs

1pub mod bench;
2pub mod blockchaintest;
3pub mod bytecode;
4pub mod evmrunner;
5pub mod statetest;
6
7use clap::Parser;
8
9#[derive(Parser, Debug)]
10#[command(infer_subcommands = true)]
11pub enum MainCmd {
12    /// Execute Ethereum state tests.
13    Statetest(statetest::Cmd),
14    /// Execute Ethereum state tests.
15    Stest(statetest::Cmd),
16    /// Run arbitrary EVM bytecode.
17    Evm(evmrunner::Cmd),
18    /// Print the structure of an EVM bytecode.
19    Bytecode(bytecode::Cmd),
20    /// Run bench from specified list.
21    Bench(bench::Cmd),
22    /// Execute Ethereum blockchain tests.
23    Blockchaintest(blockchaintest::Cmd),
24    /// Execute Ethereum blockchain tests.
25    Btest(blockchaintest::Cmd),
26}
27
28#[derive(Debug, thiserror::Error)]
29pub enum Error {
30    #[error(transparent)]
31    Statetest(#[from] statetest::Error),
32    #[error(transparent)]
33    Blockchaintest(#[from] blockchaintest::Error),
34    #[error(transparent)]
35    EvmRunnerErrors(#[from] evmrunner::Errors),
36    #[error("Custom error: {0}")]
37    Custom(&'static str),
38}
39
40impl MainCmd {
41    pub fn run(&self) -> Result<(), Error> {
42        match self {
43            Self::Statetest(cmd) | Self::Stest(cmd) => cmd.run()?,
44            Self::Evm(cmd) => cmd.run()?,
45            Self::Bytecode(cmd) => {
46                cmd.run()?;
47            }
48            Self::Bench(cmd) => {
49                cmd.run();
50            }
51            Self::Blockchaintest(cmd) | Self::Btest(cmd) => cmd.run()?,
52        }
53        Ok(())
54    }
55}