@@ -6375,15 +6375,15 @@ fn clarity_burn_state() {
63756375 let sender_signer_sk = Secp256k1PrivateKey::random();
63766376 let sender_signer_addr = tests::to_addr(&sender_signer_sk);
63776377 let tenure_count = 5;
6378- let inter_blocks_per_tenure = 9;
6378+ let min_inter_blocks_per_tenure = 9;
63796379 // setup sender + recipient for some test stx transfers
63806380 // these are necessary for the interim blocks to get mined at all
63816381 let sender_addr = tests::to_addr(&sender_sk);
63826382 let tx_fee = 1000;
63836383 let deploy_fee = 3000;
63846384 naka_conf.add_initial_balance(
63856385 PrincipalData::from(sender_addr.clone()).to_string(),
6386- deploy_fee + tx_fee * tenure_count + tx_fee * tenure_count * inter_blocks_per_tenure ,
6386+ deploy_fee + tx_fee * tenure_count + tx_fee * tenure_count * min_inter_blocks_per_tenure ,
63876387 );
63886388 naka_conf.add_initial_balance(
63896389 PrincipalData::from(sender_signer_addr.clone()).to_string(),
@@ -6553,9 +6553,10 @@ fn clarity_burn_state() {
65536553 }
65546554 });
65556555
6556- // mine the interim blocks
6557- for interim_block_ix in 0..inter_blocks_per_tenure {
6558- info!("Mining interim block {interim_block_ix}");
6556+ // mine the interim blocks (we may end up mining more than
6557+ // one block per run, thus the `min_...` naming)
6558+ for interim_ix in 0..min_inter_blocks_per_tenure {
6559+ info!("Interim block mining iteration #{interim_ix}");
65596560 let blocks_processed_before = coord_channel
65606561 .lock()
65616562 .expect("Mutex poisoned")
@@ -6587,15 +6588,27 @@ fn clarity_burn_state() {
65876588 &[expected_height],
65886589 );
65896590 sender_nonce += 1;
6590- submit_tx(&http_origin, &call_tx);
6591+ let txid = submit_tx(&http_origin, &call_tx);
65916592
65926593 loop {
65936594 let blocks_processed = coord_channel
65946595 .lock()
65956596 .expect("Mutex poisoned")
65966597 .get_stacks_blocks_processed();
65976598 if blocks_processed > blocks_processed_before {
6598- break;
6599+ // ensure that the transaction was included in the block -- it's possible
6600+ // that it only makes it into the second block, and if this is the last interim
6601+ // iteration before the next burnblock, the transaction would otherwise be
6602+ // executed in the next tenure and thus fail because the burn height has changed
6603+ if test_observer::get_mined_nakamoto_blocks()
6604+ .last()
6605+ .unwrap()
6606+ .tx_events
6607+ .iter()
6608+ .any(|tx| tx.txid().to_string() == txid)
6609+ {
6610+ break;
6611+ }
65996612 }
66006613 thread::sleep(Duration::from_millis(100));
66016614 }
0 commit comments