diff --git a/ethcontract-mock/src/details/mod.rs b/ethcontract-mock/src/details/mod.rs index a8e94f0f..d94a1c05 100644 --- a/ethcontract-mock/src/details/mod.rs +++ b/ethcontract-mock/src/details/mod.rs @@ -794,7 +794,7 @@ impl Method { // are only a few expectations for a method, and they are likely // to be filtered out by `is_active`. if let Some(result) = - expectation.process_tx(&tx, &self.description, &self.function, params.clone()) + expectation.process_tx(&tx, &self.description, &self.function, params.clone()) { return result; } @@ -883,7 +883,7 @@ impl Expectation ExpectationApi -for Expectation + for Expectation { fn as_any(&mut self) -> &mut dyn Any { self diff --git a/ethcontract-mock/src/lib.rs b/ethcontract-mock/src/lib.rs index ceffe4de..54fd7190 100644 --- a/ethcontract-mock/src/lib.rs +++ b/ethcontract-mock/src/lib.rs @@ -708,9 +708,9 @@ impl Expectation(self, pred: T) -> Self - where - T: TuplePredicate

+ Send + 'static, - >::P: Send, + where + T: TuplePredicate

+ Send + 'static, + >::P: Send, { self.transport.predicate::( self.address, diff --git a/ethcontract-mock/src/test/eth_estimate_gas.rs b/ethcontract-mock/src/test/eth_estimate_gas.rs index e8f97124..28234a75 100644 --- a/ethcontract-mock/src/test/eth_estimate_gas.rs +++ b/ethcontract-mock/src/test/eth_estimate_gas.rs @@ -73,9 +73,7 @@ async fn estimate_gas_is_supported_for_edge_block() -> Result { } #[tokio::test] -#[should_panic( - expected = "mock node does not support executing methods on non-last block" -)] +#[should_panic(expected = "mock node does not support executing methods on non-last block")] async fn estimate_gas_is_not_supported_for_custom_block() { let (_, web3, contract, instance) = setup(); @@ -105,9 +103,7 @@ async fn estimate_gas_is_not_supported_for_custom_block() { } #[tokio::test] -#[should_panic( - expected = "mock node does not support executing methods on earliest block" -)] +#[should_panic(expected = "mock node does not support executing methods on earliest block")] async fn estimate_gas_is_not_supported_for_earliest_block() { let (_, web3, contract, instance) = setup(); diff --git a/ethcontract-mock/src/test/eth_get_transaction_receipt.rs b/ethcontract-mock/src/test/eth_get_transaction_receipt.rs index cdec4221..ed09c977 100644 --- a/ethcontract-mock/src/test/eth_get_transaction_receipt.rs +++ b/ethcontract-mock/src/test/eth_get_transaction_receipt.rs @@ -28,8 +28,7 @@ async fn transaction_receipt_is_returned() -> Result { async fn transaction_receipt_is_panicking_when_hash_not_fount() { let web3 = Mock::new(1234).web3(); - web3 - .eth() + web3.eth() .transaction_receipt(Default::default()) .await .unwrap(); diff --git a/ethcontract-mock/src/test/eth_transaction_count.rs b/ethcontract-mock/src/test/eth_transaction_count.rs index 27616cdf..403d7659 100644 --- a/ethcontract-mock/src/test/eth_transaction_count.rs +++ b/ethcontract-mock/src/test/eth_transaction_count.rs @@ -136,7 +136,9 @@ async fn transaction_count_is_supported_for_edge_block() -> Result { } #[tokio::test] -#[should_panic(expected = "mock node does not support returning transaction count for specific block number")] +#[should_panic( + expected = "mock node does not support returning transaction count for specific block number" +)] async fn transaction_count_is_not_supported_for_custom_block() { let web3 = Mock::new(1234).web3(); diff --git a/ethcontract-mock/src/test/mod.rs b/ethcontract-mock/src/test/mod.rs index fd678f8d..51763e59 100644 --- a/ethcontract-mock/src/test/mod.rs +++ b/ethcontract-mock/src/test/mod.rs @@ -1,66 +1,66 @@ -/// Tests for mock crate. -/// -/// # TODO -/// -/// Some tests for API are missing: -/// -/// - malformed input in -/// - eth_call -/// - eth_sendTransaction -/// - eth_sendRawTransaction -/// - eth_estimateGas -/// -/// - deployment works -/// - different contracts have different addresses -/// - returned instance has correct address -/// -/// - call to method with no expectations panics -/// - tx to method with no expectations panics -/// - call to method with an expectation succeeds -/// - tx to method with an expectation succeeds -/// -/// - call expectations only match calls -/// - tx expectations only match txs -/// - regular expectations match both calls and txs -/// -/// - predicate filters expectation so test panics -/// - predicate filters multiple expectations so test panics -/// - expectations are evaluated in FIFO order -/// - predicate_fn gets called -/// - predicate_fn_ctx gets called -/// -/// - times can be set for expectation -/// - if expectation called not enough times, test panics -/// - if expectation called enough times, test passes -/// - if expectation called enough times, it is satisfied and test panics -/// - if expectation called enough times, it is satisfied and next expectation is used -/// - expectation is not satisfied if calls are not matched by a predicate -/// -/// - expectations can be added to sequences -/// - expectation can only be in one sequence -/// - adding expectation to sequence requires exact time greater than zero -/// - updating times after expectation was set requires exact time greater than zero -/// - when method called in-order, test passes -/// - when method called in-order multiple times, test passes -/// - when method called out-of-order, test panics -/// - when method called out-of-order first time with times(2), test panics -/// - when method called out-of-order last time with times(2), test panics -/// -/// - default value for solidity type is returned -/// - rust's Default trait is not honored -/// - you can set return value -/// - returns_fn gets called -/// - returns_fn_ctx gets called -/// -/// - expectations become immutable after use in calls and txs -/// - expectations become immutable after use in calls and txs even if they are not matched by a predicate -/// - new expectations are not immutable -/// -/// - checkpoint verifies expectations -/// - checkpoint clears expectations -/// - expectations become invalid -/// -/// - confirmations plays nicely with tx.confirmations +//! Tests for mock crate. +//! +//! # TODO +//! +//! Some tests for API are missing: +//! +//! - malformed input in +//! - eth_call +//! - eth_sendTransaction +//! - eth_sendRawTransaction +//! - eth_estimateGas +//! +//! - deployment works +//! - different contracts have different addresses +//! - returned instance has correct address +//! +//! - call to method with no expectations panics +//! - tx to method with no expectations panics +//! - call to method with an expectation succeeds +//! - tx to method with an expectation succeeds +//! +//! - call expectations only match calls +//! - tx expectations only match txs +//! - regular expectations match both calls and txs +//! +//! - predicate filters expectation so test panics +//! - predicate filters multiple expectations so test panics +//! - expectations are evaluated in FIFO order +//! - predicate_fn gets called +//! - predicate_fn_ctx gets called +//! +//! - times can be set for expectation +//! - if expectation called not enough times, test panics +//! - if expectation called enough times, test passes +//! - if expectation called enough times, it is satisfied and test panics +//! - if expectation called enough times, it is satisfied and next expectation is used +//! - expectation is not satisfied if calls are not matched by a predicate +//! +//! - expectations can be added to sequences +//! - expectation can only be in one sequence +//! - adding expectation to sequence requires exact time greater than zero +//! - updating times after expectation was set requires exact time greater than zero +//! - when method called in-order, test passes +//! - when method called in-order multiple times, test passes +//! - when method called out-of-order, test panics +//! - when method called out-of-order first time with times(2), test panics +//! - when method called out-of-order last time with times(2), test panics +//! +//! - default value for solidity type is returned +//! - rust's Default trait is not honored +//! - you can set return value +//! - returns_fn gets called +//! - returns_fn_ctx gets called +//! +//! - expectations become immutable after use in calls and txs +//! - expectations become immutable after use in calls and txs even if they are not matched by a predicate +//! - new expectations are not immutable +//! +//! - checkpoint verifies expectations +//! - checkpoint clears expectations +//! - expectations become invalid +//! +//! - confirmations plays nicely with tx.confirmations use crate::{Contract, Mock}; use ethcontract::dyns::DynWeb3;