Skip to content

Commit

Permalink
[e2e testsuite] Fix test execution strategy (#10988)
Browse files Browse the repository at this point in the history
  • Loading branch information
gelash authored Nov 21, 2023
1 parent a676c14 commit eaad9ac
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions aptos-move/e2e-testsuite/src/tests/execution_strategies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,30 @@ use aptos_language_e2e_tests::{
types::Executor,
},
};
use aptos_types::{transaction::SignedTransaction, vm_status::VMStatus};
use aptos_types::{
transaction::{ExecutionStatus, SignedTransaction, TransactionStatus},
vm_status::VMStatus,
};

fn txn(seq_num: u64) -> SignedTransaction {
let account = Account::new();
let aptos_root = Account::new_aptos_root();
create_account_txn(&aptos_root, &account, seq_num + 1)
create_account_txn(&aptos_root, &account, seq_num)
}

fn execute_and_assert_success<T>(
exec: &mut impl Executor<Txn = T>,
block: Vec<T>,
num_txns: usize,
) {
let output = exec.execute_block(block).unwrap();
output.iter().for_each(|txn_output| {
assert_eq!(
txn_output.status(),
&TransactionStatus::Keep(ExecutionStatus::Success)
);
});
assert_eq!(output.len(), num_txns);
}

#[test]
Expand All @@ -32,7 +50,7 @@ fn test_execution_strategies() {
println!("===========================================================================");
let big_block = (0..10).map(txn).collect();
let mut exec = BasicExecutor::new();
exec.execute_block(big_block).unwrap();
execute_and_assert_success(&mut exec, big_block, 10);
}

{
Expand All @@ -41,7 +59,7 @@ fn test_execution_strategies() {
println!("===========================================================================");
let big_block = (0..10).map(txn).collect();
let mut exec = RandomExecutor::from_os_rng();
exec.execute_block(big_block).unwrap();
execute_and_assert_success(&mut exec, big_block, 10);
}

{
Expand All @@ -68,7 +86,7 @@ fn test_execution_strategies() {
block1.append(&mut block);

let mut exec = GuidedExecutor::new(PartitionedGuidedStrategy);
exec.execute_block(block1).unwrap();
execute_and_assert_success(&mut exec, block1, 42);
}

{
Expand Down Expand Up @@ -97,7 +115,7 @@ fn test_execution_strategies() {
let mut exec = MultiExecutor::<AnnotatedTransaction, VMStatus>::new();
exec.add_executor(GuidedExecutor::new(PartitionedGuidedStrategy));
exec.add_executor(GuidedExecutor::new(UnPartitionedGuidedStrategy));
exec.execute_block(block1).unwrap();
execute_and_assert_success(&mut exec, block1, 42);
}

{
Expand All @@ -110,6 +128,6 @@ fn test_execution_strategies() {
exec.add_executor(RandomExecutor::from_os_rng());
exec.add_executor(RandomExecutor::from_os_rng());
exec.add_executor(RandomExecutor::from_os_rng());
exec.execute_block(block).unwrap();
execute_and_assert_success(&mut exec, block, 10);
}
}

0 comments on commit eaad9ac

Please sign in to comment.