From 7f554dfac64870e25d8d7693ab54d72de0af11c6 Mon Sep 17 00:00:00 2001 From: Angel Petrov <146711006+Angel-Petrov@users.noreply.github.com> Date: Fri, 16 Feb 2024 15:06:52 +0200 Subject: [PATCH] fix: start verifying tx after they are all executed (#41) * Replace Goose sequencing with on stop transactions * Fix wrong ensure! for erc721 --- src/actions/goose.rs | 52 +++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/src/actions/goose.rs b/src/actions/goose.rs index c79bef2..8a575ea 100644 --- a/src/actions/goose.rs +++ b/src/actions/goose.rs @@ -84,12 +84,14 @@ pub async fn erc20(shooter: &GatlingShooterSetup) -> color_eyre::Result<()> { .register_transaction( Transaction::new(transfer_wait) .set_name("Transfer Finalizing") - .set_sequence(2), + .set_sequence(2) + .set_on_stop(), ) .register_transaction( transaction!(verify_transactions) .set_name("Transfer Verification") - .set_sequence(3), + .set_sequence(3) + .set_on_stop(), ), ) .execute() @@ -103,7 +105,7 @@ pub async fn erc721(shooter: &GatlingShooterSetup) -> color_eyre::Result<()> { let environment = shooter.environment()?; ensure!( - config.run.num_erc20_transfers >= config.run.concurrency, + config.run.num_erc721_mints >= config.run.concurrency, "Too few erc721 mints for the amount of concurrency" ); @@ -166,12 +168,14 @@ pub async fn erc721(shooter: &GatlingShooterSetup) -> color_eyre::Result<()> { .register_transaction( Transaction::new(mint_wait) .set_name("Mint Finalizing") - .set_sequence(2), + .set_sequence(2) + .set_on_stop(), ) .register_transaction( transaction!(verify_transactions) .set_name("Mint Verification") - .set_sequence(3), + .set_sequence(3) + .set_on_stop(), ), ) .execute() @@ -331,27 +335,31 @@ async fn mint( } async fn verify_transactions(user: &mut GooseUser) -> TransactionResult { - let transaction = user - .get_session_data_mut::() - .expect("Should be in a goose user with GooseUserState session data") - .prev_tx - .pop() - .expect("There should be enough previous transactions for every verification"); - - let receipt: MaybePendingTransactionReceipt = - send_request(user, JsonRpcMethod::GetTransactionReceipt, transaction).await?; + let transactions = mem::take( + &mut user + .get_session_data_mut::() + .expect("Should be in a goose user with GooseUserState session data") + .prev_tx, + ); - match receipt { - MaybePendingTransactionReceipt::Receipt(receipt) => match receipt.execution_result() { - ExecutionResult::Succeeded => Ok(()), - ExecutionResult::Reverted { reason } => { - panic!("Transaction {transaction:#064x} has been rejected/reverted: {reason}"); + for tx in transactions { + let receipt: MaybePendingTransactionReceipt = + send_request(user, JsonRpcMethod::GetTransactionReceipt, tx).await?; + + match receipt { + MaybePendingTransactionReceipt::Receipt(receipt) => match receipt.execution_result() { + ExecutionResult::Succeeded => {} + ExecutionResult::Reverted { reason } => { + panic!("Transaction {tx:#064x} has been rejected/reverted: {reason}"); + } + }, + MaybePendingTransactionReceipt::PendingReceipt(_) => { + panic!("Transaction {tx:#064x} is pending when no transactions should be") } - }, - MaybePendingTransactionReceipt::PendingReceipt(_) => { - panic!("Transaction {transaction:#064x} is pending when no transactions should be") } } + + Ok(()) } pub async fn send_execution(