Skip to content

Commit b87f8ff

Browse files
committed
refactor: improve tx replay rejection test, #5970
1 parent 3d4ae73 commit b87f8ff

File tree

1 file changed

+9
-19
lines changed
  • testnet/stacks-node/src/tests/signer

1 file changed

+9
-19
lines changed

testnet/stacks-node/src/tests/signer/v0.rs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3404,7 +3404,7 @@ fn tx_replay_rejected_when_forking_across_reward_cycle() {
34043404
let sender_addr = tests::to_addr(&sender_sk);
34053405
let send_amt = 100;
34063406
let send_fee = 180;
3407-
let mut signer_test: SignerTest<SpawnedSigner> = SignerTest::new_with_config_modifications(
3407+
let signer_test: SignerTest<SpawnedSigner> = SignerTest::new_with_config_modifications(
34083408
num_signers,
34093409
vec![(sender_addr, (send_amt + send_fee) * 10)],
34103410
|_| {},
@@ -3416,10 +3416,9 @@ fn tx_replay_rejected_when_forking_across_reward_cycle() {
34163416
);
34173417
let conf = signer_test.running_nodes.conf.clone();
34183418
let http_origin = format!("http://{}", &conf.node.rpc_bind);
3419-
let burn_chain = signer_test
3420-
.running_nodes
3421-
.btc_regtest_controller
3422-
.get_burnchain();
3419+
let btc_controller = &signer_test.running_nodes.btc_regtest_controller;
3420+
let burn_chain = btc_controller.get_burnchain();
3421+
let counters = &signer_test.running_nodes.counters;
34233422

34243423
signer_test.boot_to_epoch_3();
34253424
info!("------------------------- Reached Epoch 3.0 -------------------------");
@@ -3465,7 +3464,6 @@ fn tx_replay_rejected_when_forking_across_reward_cycle() {
34653464

34663465
info!("----- Trigger Bitcoin fork -----");
34673466
//Fork on the third-to-last tenure of prev reward cycle
3468-
let btc_controller = &signer_test.running_nodes.btc_regtest_controller;
34693467
let burn_block_hash_to_fork = btc_controller.get_block_hash(new_burn_block_height - 2);
34703468
btc_controller.invalidate_block(&burn_block_hash_to_fork);
34713469
btc_controller.build_next_block(3);
@@ -3475,27 +3473,19 @@ fn tx_replay_rejected_when_forking_across_reward_cycle() {
34753473

34763474
//mine throught the fork (just check commits because of naka block mining stalled)
34773475
TEST_MINE_STALL.set(true);
3478-
let submitted_commits = signer_test
3479-
.running_nodes
3480-
.counters
3481-
.naka_submitted_commits
3482-
.clone();
34833476

3477+
let submitted_commits = counters.naka_submitted_commits.clone();
34843478
for i in 0..3 {
34853479
let current_burn_height = get_chain_info(&signer_test.running_nodes.conf).burn_block_height;
34863480
info!(
34873481
"Mining block #{i} to be considered a frequent miner";
34883482
"current_burn_height" => current_burn_height,
34893483
);
34903484
let commits_count = submitted_commits.load(Ordering::SeqCst);
3491-
next_block_and(
3492-
&mut signer_test.running_nodes.btc_regtest_controller,
3493-
60,
3494-
|| {
3495-
let commits_submitted = submitted_commits.load(Ordering::SeqCst);
3496-
Ok(commits_submitted > commits_count)
3497-
},
3498-
)
3485+
next_block_and(btc_controller, 60, || {
3486+
let commits_submitted = submitted_commits.load(Ordering::SeqCst);
3487+
Ok(commits_submitted > commits_count)
3488+
})
34993489
.unwrap();
35003490
}
35013491

0 commit comments

Comments
 (0)