@@ -966,6 +966,10 @@ fn forked_tenure_testing(
966
966
},
967
967
|config| {
968
968
config.miner.tenure_cost_limit_per_block_percentage = None;
969
+ // this test relies on the miner submitting these timed out commits.
970
+ // the test still passes without this override, but the default timeout
971
+ // makes the test take longer than strictly necessary
972
+ config.miner.block_commit_delay = Duration::from_secs(10);
969
973
},
970
974
None,
971
975
None,
@@ -1204,8 +1208,6 @@ fn forked_tenure_testing(
1204
1208
(None, None)
1205
1209
} else {
1206
1210
// Now let's produce a second block for tenure C and ensure it builds off of block C.
1207
- let blocks_before = mined_blocks.load(Ordering::SeqCst);
1208
- let start_time = Instant::now();
1209
1211
// submit a tx so that the miner will mine an extra block
1210
1212
let sender_nonce = 0;
1211
1213
let transfer_tx = make_stacks_transfer(
@@ -1218,16 +1220,10 @@ fn forked_tenure_testing(
1218
1220
);
1219
1221
let tx = submit_tx(&http_origin, &transfer_tx);
1220
1222
info!("Submitted tx {tx} in Tenure C to mine a second block");
1221
- while mined_blocks.load(Ordering::SeqCst) <= blocks_before {
1222
- assert!(
1223
- start_time.elapsed() < Duration::from_secs(30),
1224
- "FAIL: Test timed out while waiting for block production",
1225
- );
1226
- thread::sleep(Duration::from_secs(1));
1227
- }
1228
-
1229
- // give C's second block a moment to process
1230
- sleep_ms(1000);
1223
+ wait_for(60, || {
1224
+ Ok(get_account(&http_origin, &sender_addr).nonce > sender_nonce)
1225
+ })
1226
+ .unwrap();
1231
1227
1232
1228
info!("Tenure C produced a second block!");
1233
1229
@@ -1240,27 +1236,22 @@ fn forked_tenure_testing(
1240
1236
(Some(block_2_tenure_c), Some(block_2_c))
1241
1237
};
1242
1238
1243
- // allow block C2 to be processed
1244
- sleep_ms(1000);
1239
+ // make sure that a block commit has been submitted
1240
+ let burn_ht = signer_test.get_peer_info().burn_block_height;
1241
+ wait_for(60, || {
1242
+ let submitted_ht = signer_test
1243
+ .running_nodes
1244
+ .counters
1245
+ .naka_submitted_commit_last_burn_height
1246
+ .load(Ordering::SeqCst);
1247
+ Ok(submitted_ht >= burn_ht)
1248
+ })
1249
+ .unwrap();
1245
1250
1246
1251
info!("Starting Tenure D.");
1247
1252
1248
- // Submit a block commit op for tenure D and mine a stacks block
1249
- let commits_before = commits_submitted.load(Ordering::SeqCst);
1250
- let blocks_before = mined_blocks.load(Ordering::SeqCst);
1251
- next_block_and(
1252
- &mut signer_test.running_nodes.btc_regtest_controller,
1253
- 60,
1254
- || {
1255
- let commits_count = commits_submitted.load(Ordering::SeqCst);
1256
- let blocks_count = mined_blocks.load(Ordering::SeqCst);
1257
- Ok(commits_count > commits_before && blocks_count > blocks_before)
1258
- },
1259
- )
1260
- .unwrap();
1261
-
1262
- // allow block D to be processed
1263
- sleep_ms(1000);
1253
+ // Mine tenure D
1254
+ signer_test.mine_nakamoto_block(Duration::from_secs(60), false);
1264
1255
1265
1256
let tip_d = NakamotoChainState::get_canonical_block_header(chainstate.db(), &sortdb)
1266
1257
.unwrap()
@@ -10211,6 +10202,10 @@ fn no_reorg_due_to_successive_block_validation_ok() {
10211
10202
config.node.data_url = format!("http://{localhost}:{node_1_rpc}");
10212
10203
config.node.p2p_address = format!("{localhost}:{node_1_p2p}");
10213
10204
config.miner.wait_on_interim_blocks = Duration::from_secs(5);
10205
+ // Override this option, because this test depends on a block commit being submitted
10206
+ // without a tenure change being detected. The default option would work, but it would
10207
+ // make the test take unnecessarily long (and could be close to test failing timeouts)
10208
+ config.miner.block_commit_delay = Duration::from_secs(5);
10214
10209
config.node.pox_sync_sample_secs = 30;
10215
10210
config.burnchain.pox_reward_length = Some(max_nakamoto_tenures);
10216
10211
@@ -10448,7 +10443,7 @@ fn no_reorg_due_to_successive_block_validation_ok() {
10448
10443
let burn_height_before = get_burn_height();
10449
10444
next_block_and(
10450
10445
&mut signer_test.running_nodes.btc_regtest_controller,
10451
- 30 ,
10446
+ 60 ,
10452
10447
|| {
10453
10448
Ok(get_burn_height() > burn_height_before
10454
10449
&& rl2_proposals.load(Ordering::SeqCst) > proposals_before_2
0 commit comments