feat: add --fork-block-number setter for anvil bindings (#1468)
This commit is contained in:
parent
8db1899820
commit
1ff4be74f9
|
@ -82,6 +82,7 @@ pub struct Anvil {
|
||||||
block_time: Option<u64>,
|
block_time: Option<u64>,
|
||||||
mnemonic: Option<String>,
|
mnemonic: Option<String>,
|
||||||
fork: Option<String>,
|
fork: Option<String>,
|
||||||
|
fork_block_number: Option<u64>,
|
||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,6 +114,15 @@ impl Anvil {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 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<T: Into<u64>>(mut self, fork_block_number: T) -> Self {
|
||||||
|
self.fork_block_number = Some(fork_block_number.into());
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Sets the `fork` argument to fork from another currently running Ethereum client
|
/// Sets the `fork` argument to fork from another currently running Ethereum client
|
||||||
/// at a given block. Input should be the HTTP location and port of the other client,
|
/// 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
|
/// e.g. `http://localhost:8545`. You can optionally specify the block to fork from
|
||||||
|
@ -163,6 +173,10 @@ impl Anvil {
|
||||||
cmd.arg("-f").arg(fork);
|
cmd.arg("-f").arg(fork);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(fork_block_number) = self.fork_block_number {
|
||||||
|
cmd.arg("--fork-block-number").arg(fork_block_number.to_string());
|
||||||
|
}
|
||||||
|
|
||||||
cmd.args(self.args);
|
cmd.args(self.args);
|
||||||
|
|
||||||
let mut child = cmd.spawn().expect("couldnt start anvil");
|
let mut child = cmd.spawn().expect("couldnt start anvil");
|
||||||
|
|
Loading…
Reference in New Issue