test: set nonce for tx stream explicitly (#1354)

This commit is contained in:
Matthias Seitz 2022-06-07 17:44:02 +02:00 committed by GitHub
parent f56146025a
commit 0197fe3fc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 8 deletions

View File

@ -495,10 +495,10 @@ pub mod spoof {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::{Http, Middleware, Provider}; use crate::{Http, Provider};
use ethers_core::{ use ethers_core::{
types::TransactionRequest, types::TransactionRequest,
utils::{get_contract_address, keccak256, parse_ether, Anvil, Geth}, utils::{get_contract_address, keccak256, parse_ether, Geth},
}; };
use std::convert::TryFrom; use std::convert::TryFrom;
@ -516,7 +516,7 @@ mod tests {
} }
// Tests "roundtrip" serialization of calls: deserialize(serialize(call)) == call // Tests "roundtrip" serialization of calls: deserialize(serialize(call)) == call
fn test_encode<'a, P>(call: CallBuilder<'a, P>) { fn test_encode<P>(call: CallBuilder<P>) {
let input = call.unwrap().input; let input = call.unwrap().input;
let ser = utils::serialize(&input).to_string(); let ser = utils::serialize(&input).to_string();
let de: CallInputOwned = serde_json::from_str(&ser).unwrap(); let de: CallInputOwned = serde_json::from_str(&ser).unwrap();

View File

@ -190,7 +190,7 @@ where
poll_broadcast_fut!(cx, this, fut); poll_broadcast_fut!(cx, this, fut);
} }
Sleeping(delay) => { Sleeping(delay) => {
let _ready = futures_util::ready!(delay.as_mut().poll(cx)); futures_util::ready!(delay.as_mut().poll(cx));
// if broadcast timer has elapsed and if we have a TX to // if broadcast timer has elapsed and if we have a TX to
// broadcast, broadcast it // broadcast, broadcast it
if this.last.elapsed() > *this.broadcast_interval { if this.last.elapsed() > *this.broadcast_interval {

View File

@ -172,7 +172,7 @@ impl<'a, P: JsonRpcClient> Future for PendingTransaction<'a, P> {
match this.state { match this.state {
PendingTxState::InitialDelay(fut) => { PendingTxState::InitialDelay(fut) => {
let _ready = futures_util::ready!(fut.as_mut().poll(ctx)); futures_util::ready!(fut.as_mut().poll(ctx));
tracing::debug!("Starting to poll pending tx {:?}", *this.tx_hash); tracing::debug!("Starting to poll pending tx {:?}", *this.tx_hash);
let fut = Box::pin(this.provider.get_transaction(*this.tx_hash)); let fut = Box::pin(this.provider.get_transaction(*this.tx_hash));
rewake_with_new_state!(ctx, this, PendingTxState::GettingTx(fut)); rewake_with_new_state!(ctx, this, PendingTxState::GettingTx(fut));

View File

@ -284,7 +284,11 @@ mod tests {
let tx = TransactionRequest::new().from(accounts[0]).to(accounts[0]).value(1e18 as u64); let tx = TransactionRequest::new().from(accounts[0]).to(accounts[0]).value(1e18 as u64);
let mut sending = futures_util::future::join_all( let mut sending = futures_util::future::join_all(
std::iter::repeat(tx.clone()).take(num_txs).map(|tx| async { std::iter::repeat(tx.clone())
.take(num_txs)
.enumerate()
.map(|(nonce, tx)| tx.nonce(nonce))
.map(|tx| async {
provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap() provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap()
}), }),
) )