Merge b7e0a97264
into 36dac5864c
This commit is contained in:
commit
e467c0c752
|
@ -31,7 +31,7 @@ jobs:
|
|||
- name: all features
|
||||
flags: --workspace --all-features
|
||||
include:
|
||||
# not workspace because compiling examples fails for no reason in CI,
|
||||
# not workspace because compiling examples fails for no reason in CI
|
||||
- os: windows-latest
|
||||
flags:
|
||||
name: no default features
|
||||
|
@ -92,6 +92,13 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Install Anvil
|
||||
uses: foundry-rs/foundry-toolchain@v1
|
||||
with:
|
||||
version: nightly
|
||||
- name: Install test binaries
|
||||
shell: bash
|
||||
run: ./.github/scripts/install_test_binaries.sh
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: live tests
|
||||
run: cargo test -p ethers --all-features
|
||||
|
|
|
@ -47,7 +47,7 @@ ethers-solc.workspace = true
|
|||
ethers-providers = { workspace = true, features = ["ws"] }
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
|
||||
tokio = { workspace = true, features = ["macros"] }
|
||||
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
|
||||
|
||||
[features]
|
||||
default = ["abigen"]
|
||||
|
|
|
@ -621,7 +621,7 @@ mod tests {
|
|||
fn serde_to_string_match() {
|
||||
for chain in Chain::iter() {
|
||||
let chain_serde = serde_json::to_string(&chain).unwrap();
|
||||
let chain_string = format!("\"{}\"", chain.to_string());
|
||||
let chain_string = format!("\"{chain}\"");
|
||||
assert_eq!(chain_serde, chain_string);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<PathBuf>,
|
||||
port: Option<u16>,
|
||||
|
@ -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<T: Into<PathBuf>>(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<T: Into<u16>>(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<T: Into<u64>>(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<T: Into<String>>(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<T: Into<u64>>(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<T: Into<u64>>(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<T: Into<String>>(mut self, fork: T) -> Self {
|
||||
self.fork = Some(fork.into());
|
||||
self
|
||||
}
|
||||
|
||||
/// Adds an argument to pass to the `anvil`.
|
||||
#[must_use]
|
||||
pub fn arg<T: Into<String>>(mut self, arg: T) -> Self {
|
||||
self.args.push(arg.into());
|
||||
self
|
||||
}
|
||||
|
||||
/// Adds multiple arguments to pass to the `anvil`.
|
||||
#[must_use]
|
||||
pub fn args<I, S>(mut self, args: I) -> Self
|
||||
where
|
||||
I: IntoIterator<Item = S>,
|
||||
|
@ -209,14 +201,17 @@ impl Anvil {
|
|||
}
|
||||
|
||||
/// Sets the timeout which will be used when the `anvil` instance is launched.
|
||||
#[must_use]
|
||||
pub fn timeout<T: Into<u64>>(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)
|
||||
|
|
|
@ -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<u16>,
|
||||
block_time: Option<u64>,
|
||||
|
@ -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<T: Into<u16>>(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<T: Into<String>>(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<T: Into<u64>>(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<T: Into<String>>(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<T: Into<String>>(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<I, S>(mut self, args: I) -> Self
|
||||
where
|
||||
I: IntoIterator<Item = S>,
|
||||
|
@ -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());
|
||||
|
|
|
@ -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<PathBuf>,
|
||||
port: Option<u16>,
|
||||
|
@ -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<T: Into<PathBuf>>(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<T: Into<SigningKey>>(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<T: Into<u16>>(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<T: Into<u64>>(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<T: Into<u64>>(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<T: Into<PathBuf>>(mut self, path: T) -> Self {
|
||||
self.ipc_path = Some(path.into());
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the data directory for geth.
|
||||
#[must_use]
|
||||
pub fn data_dir<T: Into<PathBuf>>(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() {
|
||||
|
|
|
@ -60,7 +60,7 @@ once_cell.workspace = true
|
|||
reqwest = { workspace = true, features = ["json", "rustls"] }
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
|
||||
tokio = { workspace = true, features = ["rt", "macros", "time"] }
|
||||
tokio = { workspace = true, features = ["rt-multi-thread", "macros", "time"] }
|
||||
|
||||
[features]
|
||||
default = ["rustls"]
|
||||
|
|
|
@ -74,7 +74,7 @@ web-sys = { version = "0.3", features = ["console"] }
|
|||
getrandom.workspace = true
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
|
||||
tokio = { workspace = true, features = ["rt", "macros", "time"] }
|
||||
tokio = { workspace = true, features = ["rt-multi-thread", "macros", "time"] }
|
||||
tempfile = "3.4.0"
|
||||
|
||||
[features]
|
||||
|
|
|
@ -74,7 +74,7 @@ tracing-subscriber.workspace = true
|
|||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
|
||||
yubihsm = { version = "0.42.0-pre.0", features = ["secp256k1", "usb", "mockhsm"] }
|
||||
tokio = { workspace = true, features = ["macros", "rt"] }
|
||||
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
|
||||
|
||||
[features]
|
||||
futures = ["futures-util", "futures-executor"]
|
||||
|
|
|
@ -64,7 +64,7 @@ svm = { package = "svm-rs", version = "0.2", default-features = false, features
|
|||
"blocking",
|
||||
], optional = true }
|
||||
svm-builds = { package = "svm-rs-builds", version = "0.1", optional = true }
|
||||
tokio = { workspace = true, features = ["rt"] }
|
||||
tokio = { workspace = true, features = ["rt-multi-thread"] }
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
# NOTE: this enables wasm compatibility for getrandom indirectly
|
||||
|
|
|
@ -8,7 +8,7 @@ use ethers::{
|
|||
signers::LocalWallet,
|
||||
solc::Solc,
|
||||
};
|
||||
use std::{path::PathBuf, sync::Arc};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_derive_eip712() {
|
||||
|
@ -39,9 +39,9 @@ async fn test_derive_eip712() {
|
|||
}
|
||||
|
||||
// get ABI and bytecode for the DeriveEip712Test contract
|
||||
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests");
|
||||
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();
|
||||
let result = Solc::default().compile_source(PATH).unwrap();
|
||||
let (abi, bytecode, _) = result
|
||||
.find("DeriveEip712Test")
|
||||
.expect("failed to get DeriveEip712Test contract")
|
||||
|
|
Loading…
Reference in New Issue