diff --git a/ethers-core/src/utils/anvil.rs b/ethers-core/src/utils/anvil.rs index 26612aac..1fe5baf7 100644 --- a/ethers-core/src/utils/anvil.rs +++ b/ethers-core/src/utils/anvil.rs @@ -85,6 +85,7 @@ impl Drop for AnvilInstance { /// drop(anvil); // this will kill the instance /// ``` #[derive(Debug, Clone, Default)] +#[must_use = "This Builder struct does nothing unless it is `spawn`ed"] pub struct Anvil { program: Option, port: Option, @@ -135,35 +136,30 @@ impl Anvil { /// /// By default, it's expected that `anvil` is in `$PATH`, see also /// [`std::process::Command::new()`] - #[must_use] pub fn path>(mut self, path: T) -> Self { self.program = Some(path.into()); self } /// Sets the port which will be used when the `anvil` instance is launched. - #[must_use] pub fn port>(mut self, port: T) -> Self { self.port = Some(port.into()); self } /// Sets the chain_id the `anvil` instance will use. - #[must_use] pub fn chain_id>(mut self, chain_id: T) -> Self { self.chain_id = Some(chain_id.into()); self } /// Sets the mnemonic which will be used when the `anvil` instance is launched. - #[must_use] pub fn mnemonic>(mut self, mnemonic: T) -> Self { self.mnemonic = Some(mnemonic.into()); self } /// Sets the block-time in seconds which will be used when the `anvil` instance is launched. - #[must_use] pub fn block_time>(mut self, block_time: T) -> Self { self.block_time = Some(block_time.into()); self @@ -172,7 +168,6 @@ impl Anvil { /// Sets the `fork-block-number` which will be used in addition to [`Self::fork`]. /// /// **Note:** if set, then this requires `fork` to be set as well - #[must_use] pub fn fork_block_number>(mut self, fork_block_number: T) -> Self { self.fork_block_number = Some(fork_block_number.into()); self @@ -182,21 +177,18 @@ impl Anvil { /// at a given block. Input should be the HTTP location and port of the other client, /// e.g. `http://localhost:8545`. You can optionally specify the block to fork from /// using an @ sign: `http://localhost:8545@1599200` - #[must_use] pub fn fork>(mut self, fork: T) -> Self { self.fork = Some(fork.into()); self } /// Adds an argument to pass to the `anvil`. - #[must_use] pub fn arg>(mut self, arg: T) -> Self { self.args.push(arg.into()); self } /// Adds multiple arguments to pass to the `anvil`. - #[must_use] pub fn args(mut self, args: I) -> Self where I: IntoIterator, @@ -209,14 +201,17 @@ impl Anvil { } /// Sets the timeout which will be used when the `anvil` instance is launched. - #[must_use] pub fn timeout>(mut self, timeout: T) -> Self { self.timeout = Some(timeout.into()); self } - /// Consumes the builder and spawns `anvil` with stdout redirected - /// to /dev/null. + /// Consumes the builder and spawns `anvil`. + /// + /// # Panics + /// + /// If spawning the instance fails at any point. + #[track_caller] pub fn spawn(self) -> AnvilInstance { let mut cmd = if let Some(ref prg) = self.program { Command::new(prg) diff --git a/ethers-core/src/utils/ganache.rs b/ethers-core/src/utils/ganache.rs index d1300e78..d040eb73 100644 --- a/ethers-core/src/utils/ganache.rs +++ b/ethers-core/src/utils/ganache.rs @@ -78,6 +78,7 @@ impl Drop for GanacheInstance { /// drop(ganache); // this will kill the instance /// ``` #[derive(Clone, Default)] +#[must_use = "This Builder struct does nothing unless it is `spawn`ed"] pub struct Ganache { port: Option, block_time: Option, @@ -102,21 +103,18 @@ impl Ganache { } /// Sets the port which will be used when the `ganache-cli` instance is launched. - #[must_use] pub fn port>(mut self, port: T) -> Self { self.port = Some(port.into()); self } /// Sets the mnemonic which will be used when the `ganache-cli` instance is launched. - #[must_use] pub fn mnemonic>(mut self, mnemonic: T) -> Self { self.mnemonic = Some(mnemonic.into()); self } /// Sets the block-time which will be used when the `ganache-cli` instance is launched. - #[must_use] pub fn block_time>(mut self, block_time: T) -> Self { self.block_time = Some(block_time.into()); self @@ -126,21 +124,18 @@ impl Ganache { /// at a given block. Input should be the HTTP location and port of the other client, /// e.g. `http://localhost:8545`. You can optionally specify the block to fork from /// using an @ sign: `http://localhost:8545@1599200` - #[must_use] pub fn fork>(mut self, fork: T) -> Self { self.fork = Some(fork.into()); self } /// Adds an argument to pass to the `ganache-cli`. - #[must_use] pub fn arg>(mut self, arg: T) -> Self { self.args.push(arg.into()); self } /// Adds multiple arguments to pass to the `ganache-cli`. - #[must_use] pub fn args(mut self, args: I) -> Self where I: IntoIterator, @@ -152,9 +147,12 @@ impl Ganache { self } - /// Consumes the builder and spawns `ganache-cli` with stdout redirected - /// to /dev/null. This takes ~2 seconds to execute as it blocks while - /// waiting for `ganache-cli` to launch. + /// Consumes the builder and spawns `ganache-cli`. + /// + /// # Panics + /// + /// If spawning the instance fails at any point. + #[track_caller] pub fn spawn(self) -> GanacheInstance { let mut cmd = Command::new("ganache-cli"); cmd.stdout(std::process::Stdio::piped()); diff --git a/ethers-core/src/utils/geth.rs b/ethers-core/src/utils/geth.rs index bf9b0b2b..4cb6a1d7 100644 --- a/ethers-core/src/utils/geth.rs +++ b/ethers-core/src/utils/geth.rs @@ -189,6 +189,7 @@ impl Default for PrivateNetOptions { /// drop(geth); // this will kill the instance /// ``` #[derive(Clone, Default)] +#[must_use = "This Builder struct does nothing unless it is `spawn`ed"] pub struct Geth { program: Option, port: Option, @@ -234,7 +235,6 @@ impl Geth { /// /// By default, it's expected that `geth` is in `$PATH`, see also /// [`std::process::Command::new()`] - #[must_use] pub fn path>(mut self, path: T) -> Self { self.program = Some(path.into()); self @@ -245,14 +245,12 @@ impl Geth { /// /// The address derived from this private key will be used to set the `miner.etherbase` field /// on the node. - #[must_use] pub fn set_clique_private_key>(mut self, private_key: T) -> Self { self.clique_private_key = Some(private_key.into()); self } /// Sets the port which will be used when the `geth-cli` instance is launched. - #[must_use] pub fn port>(mut self, port: T) -> Self { self.port = Some(port.into()); self @@ -262,7 +260,6 @@ impl Geth { /// /// This will put the geth instance into non-dev mode, discarding any previously set dev-mode /// options. - #[must_use] pub fn p2p_port(mut self, port: u16) -> Self { match self.mode { GethMode::Dev(_) => { @@ -280,21 +277,18 @@ impl Geth { /// /// This will put the geth instance in `dev` mode, discarding any previously set options that /// cannot be used in dev mode. - #[must_use] pub fn block_time>(mut self, block_time: T) -> Self { self.mode = GethMode::Dev(DevOptions { block_time: Some(block_time.into()) }); self } /// Sets the chain id for the geth instance. - #[must_use] pub fn chain_id>(mut self, chain_id: T) -> Self { self.chain_id = Some(chain_id.into()); self } /// Allow geth to unlock accounts when rpc apis are open. - #[must_use] pub fn insecure_unlock(mut self) -> Self { self.insecure_unlock = true; self @@ -304,7 +298,6 @@ impl Geth { /// /// This will put the geth instance into non-dev mode, discarding any previously set dev-mode /// options. - #[must_use] pub fn disable_discovery(mut self) -> Self { self.inner_disable_discovery(); self @@ -321,14 +314,12 @@ impl Geth { } /// Manually sets the IPC path for the socket manually. - #[must_use] pub fn ipc_path>(mut self, path: T) -> Self { self.ipc_path = Some(path.into()); self } /// Sets the data directory for geth. - #[must_use] pub fn data_dir>(mut self, path: T) -> Self { self.data_dir = Some(path.into()); self @@ -340,21 +331,22 @@ impl Geth { /// set to the same value as `data_dir`. /// /// This is destructive and will overwrite any existing data in the data directory. - #[must_use] pub fn genesis(mut self, genesis: Genesis) -> Self { self.genesis = Some(genesis); self } /// Sets the port for authenticated RPC connections. - #[must_use] pub fn authrpc_port(mut self, port: u16) -> Self { self.authrpc_port = Some(port); self } - /// Consumes the builder and spawns `geth` with stdout redirected to /dev/null. - #[must_use] + /// Consumes the builder and spawns `geth`. + /// + /// # Panics + /// + /// If spawning the instance fails at any point. #[track_caller] pub fn spawn(mut self) -> GethInstance { let bin_path = match self.program.as_ref() { diff --git a/ethers/tests/eip712.rs b/ethers/tests/eip712.rs index d50e94b1..4cc16063 100644 --- a/ethers/tests/eip712.rs +++ b/ethers/tests/eip712.rs @@ -42,7 +42,6 @@ async fn test_derive_eip712() { const PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/DeriveEip712Test.sol"); Solc::find_or_install_svm_version("0.6.0").unwrap(); // install solc let result = Solc::default().compile_source(PATH).unwrap(); - eprintln!("{result:#?}"); let (abi, bytecode, _) = result .find("DeriveEip712Test") .expect("failed to get DeriveEip712Test contract")