Skip to content

Commit

Permalink
Run rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Tamika Nomara committed Aug 2, 2021
1 parent 7e3fa88 commit f668b2a
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 77 deletions.
4 changes: 2 additions & 2 deletions ethcontract-mock/src/details/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -883,7 +883,7 @@ impl<P: Tokenize + Send + 'static, R: Tokenize + Send + 'static> Expectation<P,
}

impl<P: Tokenize + Send + 'static, R: Tokenize + Send + 'static> ExpectationApi
for Expectation<P, R>
for Expectation<P, R>
{
fn as_any(&mut self) -> &mut dyn Any {
self
Expand Down
6 changes: 3 additions & 3 deletions ethcontract-mock/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,9 +708,9 @@ impl<P: Tokenize + Send + 'static, R: Tokenize + Send + 'static> Expectation<P,
/// [limiting number of expectation uses]: Expectation::times
/// [`returns_fn`]: Expectation::returns_fn
pub fn predicate<T>(self, pred: T) -> Self
where
T: TuplePredicate<P> + Send + 'static,
<T as predicate::TuplePredicate<P>>::P: Send,
where
T: TuplePredicate<P> + Send + 'static,
<T as predicate::TuplePredicate<P>>::P: Send,
{
self.transport.predicate::<P, R>(
self.address,
Expand Down
8 changes: 2 additions & 6 deletions ethcontract-mock/src/test/eth_estimate_gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down
3 changes: 1 addition & 2 deletions ethcontract-mock/src/test/eth_get_transaction_receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 3 additions & 1 deletion ethcontract-mock/src/test/eth_transaction_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
126 changes: 63 additions & 63 deletions ethcontract-mock/src/test/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit f668b2a

Please sign in to comment.