Skip to content

Commit

Permalink
couple more tests. this works beautifully
Browse files Browse the repository at this point in the history
  • Loading branch information
2501babe committed Sep 13, 2024
1 parent ef119fe commit 47f647a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
2 changes: 0 additions & 2 deletions svm/src/transaction_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
&None::<Vec<SanitizedTransaction>>,
&processing_results,
);
println!("HANA update acocunts: {:#?}", update_accounts);
for (pubkey, account) in update_accounts {
accounts_map.insert(*pubkey, account.clone());
}
Expand Down Expand Up @@ -537,7 +536,6 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
}
});

println!("HANA nonces equal: {:?}", nonces_are_equal);
match nonces_are_equal {
Some(false) => (),
Some(true) => {
Expand Down
52 changes: 48 additions & 4 deletions svm/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,27 @@ fn nonce_reuse(enable_fee_only_transactions: bool, fee_paying_nonce: bool) -> Ve

common_test_entry.decrease_expected_lamports(&fee_payer, LAMPORTS_PER_SIGNATURE);

// batch 0:
// batch 0: one transaction that advances the nonce twice
{
let mut test_entry = common_test_entry.clone();

let transaction = Transaction::new_signed_with_payer(
&[advance_instruction.clone(), advance_instruction.clone()],
Some(&fee_payer),
&[&fee_payer_keypair],
*initial_durable.as_hash(),
);

test_entry.push_nonce_transaction_with_status(
transaction,
initial_nonce_info.clone(),
ExecutionStatus::ExecutedFailed,
);

test_entries.push(test_entry);
}

// batch 1:
// * a successful nonce transaction
// * a nonce transaction that reuses the same nonce; this transaction must be dropped
{
Expand All @@ -1198,7 +1218,7 @@ fn nonce_reuse(enable_fee_only_transactions: bool, fee_paying_nonce: bool) -> Ve
test_entries.push(test_entry);
}

// batch 1:
// batch 2:
// * an executable failed nonce transaction
// * a nonce transaction that reuses the same nonce; this transaction must be dropped
{
Expand Down Expand Up @@ -1226,7 +1246,7 @@ fn nonce_reuse(enable_fee_only_transactions: bool, fee_paying_nonce: bool) -> Ve
test_entries.push(test_entry);
}

// batch 2:
// batch 3:
// * a processable non-executable nonce transaction, if fee-only transactions are enabled
// * a nonce transaction that reuses the same nonce; this transaction must be dropped
if enable_fee_only_transactions {
Expand Down Expand Up @@ -1263,7 +1283,31 @@ fn nonce_reuse(enable_fee_only_transactions: bool, fee_paying_nonce: bool) -> Ve
test_entries.push(test_entry);
}

// TODO very evil idea: tx1 is a non-nonce txn that nevertheless advances the nonce. tx2 dropped
// batch 4:
// * a successful blockhash transaction that also advances the nonce
// * a nonce transaction that reuses the same nonce; this transaction must be dropped
{
let mut test_entry = common_test_entry.clone();

let first_transaction = Transaction::new_signed_with_payer(
&[
successful_noop_instruction.clone(),
advance_instruction.clone(),
],
Some(&fee_payer),
&[&fee_payer_keypair],
Hash::default(),
);

test_entry.push_nonce_transaction(first_transaction, initial_nonce_info.clone());
test_entry.push_nonce_transaction_with_status(
second_transaction.clone(),
advanced_nonce_info.clone(),
ExecutionStatus::Discarded,
);

test_entries.push(test_entry);
}

for test_entry in &mut test_entries {
test_entry
Expand Down

0 comments on commit 47f647a

Please sign in to comment.