Skip to content

Commit bc51cbb

Browse files
committed
test: improvements to allow_reorg_within_first_proposal_burn_block_timing_secs
1 parent 978fddc commit bc51cbb

File tree

1 file changed

+39
-13
lines changed
  • testnet/stacks-node/src/tests/signer

1 file changed

+39
-13
lines changed

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

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10823,18 +10823,13 @@ fn injected_signatures_are_ignored_across_boundaries() {
1082310823
/// Signers accept and the stacks tip advances to N
1082410824
/// Miner 1's block commits are paused so it cannot confirm the next tenure.
1082510825
/// Sortition occurs. Miner 2 wins.
10826-
/// Miner 2 proposes block N+1
10827-
/// Signers accept and the stacks tip advances to N+1
10826+
/// Miner 2 successfully mines blocks N+1, N+2, and N+3
1082810827
/// Sortition occurs quickly, within first_proposal_burn_block_timing_secs. Miner 1 wins.
1082910828
/// Miner 1 proposes block N+1'
1083010829
/// Signers approve N+1', saying "Miner is not building off of most recent tenure. A tenure they
1083110830
/// reorg has already mined blocks, but the block was poorly timed, allowing the reorg."
10832-
/// Miner 1 proposes N+2 and it is accepted.
10833-
/// Asserts:
10834-
/// - N+1 is signed and broadcasted
10835-
/// - N+1' is signed and broadcasted
10836-
/// - The tip advances to N+1 (Signed by Miner 1)
10837-
/// - The tip advances to N+2 (Signed by Miner 1)
10831+
/// Miner 1 proposes N+2' and it is accepted.
10832+
/// Miner 1 wins the next tenure and mines N+4, off of miner 2's tip.
1083810833
#[test]
1083910834
#[ignore]
1084010835
fn allow_reorg_within_first_proposal_burn_block_timing_secs() {
@@ -11184,7 +11179,7 @@ fn allow_reorg_within_first_proposal_burn_block_timing_secs() {
1118411179
send_amt,
1118511180
);
1118611181
let tx = submit_tx(&http_origin, &transfer_tx);
11187-
info!("Submitted tx {tx} in attempt to mine block N+2");
11182+
info!("Submitted tx {tx} in attempt to mine block N+3");
1118811183
sender_nonce += 1;
1118911184

1119011185
wait_for(30, || {
@@ -11201,7 +11196,7 @@ fn allow_reorg_within_first_proposal_burn_block_timing_secs() {
1120111196

1120211197
assert_eq!(get_chain_info(&conf).stacks_tip_height, block_n_height + 3);
1120311198

11204-
info!("------------------------- Miner 1 Wins the Next Tenure -------------------------");
11199+
info!("------------------------- Miner 1 Wins the Next Tenure, Mines N+1' -------------------------");
1120511200

1120611201
let blocks_processed_before_1 = blocks_mined1.load(Ordering::SeqCst);
1120711202
let mined_before = test_observer::get_mined_nakamoto_blocks().len();
@@ -11222,7 +11217,25 @@ fn allow_reorg_within_first_proposal_burn_block_timing_secs() {
1122211217
let last_block = blocks.last().expect("No blocks mined");
1122311218
assert_eq!(last_block.stacks_height, block_n_height + 1);
1122411219

11225-
info!("------------------------- Miner 1 Mines N+2 -------------------------");
11220+
info!("------------------------- Miner 1 Submits a Block Commit -------------------------");
11221+
11222+
let rl1_commits_before = rl1_commits.load(Ordering::SeqCst);
11223+
signer_test
11224+
.running_nodes
11225+
.nakamoto_test_skip_commit_op
11226+
.set(false);
11227+
11228+
wait_for(30, || {
11229+
Ok(rl1_commits.load(Ordering::SeqCst) > rl1_commits_before)
11230+
})
11231+
.expect("Timed out waiting for Miner 1 to submit its block commit");
11232+
11233+
signer_test
11234+
.running_nodes
11235+
.nakamoto_test_skip_commit_op
11236+
.set(true);
11237+
11238+
info!("------------------------- Miner 1 Mines N+2' -------------------------");
1122611239

1122711240
let blocks_processed_before_1 = blocks_mined1.load(Ordering::SeqCst);
1122811241
let mined_before = test_observer::get_mined_nakamoto_blocks().len();
@@ -11237,20 +11250,33 @@ fn allow_reorg_within_first_proposal_burn_block_timing_secs() {
1123711250
send_amt,
1123811251
);
1123911252
let tx = submit_tx(&http_origin, &transfer_tx);
11240-
info!("Submitted tx {tx} in attempt to mine block N+2");
11253+
info!("Submitted tx {tx} in attempt to mine block N+2'");
1124111254

1124211255
wait_for(30, || {
1124311256
Ok(
1124411257
blocks_mined1.load(Ordering::SeqCst) > blocks_processed_before_1
1124511258
&& test_observer::get_mined_nakamoto_blocks().len() > mined_before,
1124611259
)
1124711260
})
11248-
.expect("Timed out waiting for Miner 1 to Mine Block N+2");
11261+
.expect("Timed out waiting for Miner 1 to Mine Block N+2'");
1124911262

1125011263
let blocks = test_observer::get_mined_nakamoto_blocks();
1125111264
let last_block = blocks.last().expect("No blocks mined");
1125211265
assert_eq!(last_block.stacks_height, block_n_height + 2);
1125311266

11267+
info!("------------------------- Miner 1 Mines N+4 in Next Tenure -------------------------");
11268+
11269+
next_block_and_process_new_stacks_block(
11270+
&mut signer_test.running_nodes.btc_regtest_controller,
11271+
30,
11272+
&signer_test.running_nodes.coord_channel,
11273+
)
11274+
.expect("Timed out waiting for Miner 1 to Mine Block N+4");
11275+
11276+
let blocks = test_observer::get_mined_nakamoto_blocks();
11277+
let last_block = blocks.last().expect("No blocks mined");
11278+
assert_eq!(last_block.stacks_height, block_n_height + 4);
11279+
1125411280
info!("------------------------- Shutdown -------------------------");
1125511281
rl2_coord_channels
1125611282
.lock()

0 commit comments

Comments
 (0)