@@ -264,6 +264,11 @@ impl SignerTest<SpawnedSigner> {
264
264
info ! ( "Signers initialized" ) ;
265
265
266
266
self . run_until_epoch_3_boundary ( ) ;
267
+ std:: thread:: sleep ( Duration :: from_secs ( 1 ) ) ;
268
+ wait_for ( 60 , || {
269
+ Ok ( get_chain_info_opt ( & self . running_nodes . conf ) . is_some ( ) )
270
+ } )
271
+ . expect ( "Timed out waiting for network to restart after 3.0 boundary reached" ) ;
267
272
268
273
// Wait until we see the first block of epoch 3.0.
269
274
// Note, we don't use `nakamoto_blocks_mined` counter, because there
@@ -4128,25 +4133,24 @@ fn locally_rejected_blocks_overriden_by_global_acceptance() {
4128
4133
signer_test. boot_to_epoch_3 ( ) ;
4129
4134
info ! ( "------------------------- Test Mine Nakamoto Block N -------------------------" ) ;
4130
4135
let mined_blocks = signer_test. running_nodes . nakamoto_blocks_mined . clone ( ) ;
4131
- let blocks_before = mined_blocks. load ( Ordering :: SeqCst ) ;
4132
4136
let info_before = signer_test
4133
4137
. stacks_client
4134
4138
. get_peer_info ( )
4135
4139
. expect ( "Failed to get peer info" ) ;
4136
- let start_time = Instant :: now ( ) ;
4137
4140
// submit a tx so that the miner will mine a stacks block
4138
4141
let mut sender_nonce = 0 ;
4139
4142
let transfer_tx =
4140
4143
make_stacks_transfer ( & sender_sk, sender_nonce, send_fee, & recipient, send_amt) ;
4141
4144
let tx = submit_tx ( & http_origin, & transfer_tx) ;
4142
4145
info ! ( "Submitted tx {tx} in to mine block N" ) ;
4143
- while mined_blocks. load ( Ordering :: SeqCst ) <= blocks_before {
4144
- assert ! (
4145
- start_time. elapsed( ) < short_timeout,
4146
- "FAIL: Test timed out while waiting for block production" ,
4147
- ) ;
4148
- thread:: sleep ( Duration :: from_secs ( 1 ) ) ;
4149
- }
4146
+ wait_for ( short_timeout. as_secs ( ) , || {
4147
+ let info_after = signer_test
4148
+ . stacks_client
4149
+ . get_peer_info ( )
4150
+ . expect ( "Failed to get peer info" ) ;
4151
+ Ok ( info_after. stacks_tip_height > info_before. stacks_tip_height )
4152
+ } )
4153
+ . expect ( "Timed out waiting for block to be mined and processed" ) ;
4150
4154
4151
4155
sender_nonce += 1 ;
4152
4156
let info_after = signer_test
@@ -4196,13 +4200,14 @@ fn locally_rejected_blocks_overriden_by_global_acceptance() {
4196
4200
. stacks_client
4197
4201
. get_peer_info ( )
4198
4202
. expect ( "Failed to get peer info" ) ;
4199
- while mined_blocks. load ( Ordering :: SeqCst ) <= blocks_before {
4200
- assert ! (
4201
- start_time. elapsed( ) < short_timeout,
4202
- "FAIL: Test timed out while waiting for block production" ,
4203
- ) ;
4204
- thread:: sleep ( Duration :: from_secs ( 1 ) ) ;
4205
- }
4203
+ wait_for ( short_timeout. as_secs ( ) , || {
4204
+ let info_after = signer_test
4205
+ . stacks_client
4206
+ . get_peer_info ( )
4207
+ . expect ( "Failed to get peer info" ) ;
4208
+ Ok ( info_after. stacks_tip_height > info_before. stacks_tip_height )
4209
+ } )
4210
+ . expect ( "Timed out waiting for block to be mined and processed" ) ;
4206
4211
loop {
4207
4212
let stackerdb_events = test_observer:: get_stackerdb_chunks ( ) ;
4208
4213
let block_rejections = stackerdb_events
@@ -4274,13 +4279,14 @@ fn locally_rejected_blocks_overriden_by_global_acceptance() {
4274
4279
make_stacks_transfer ( & sender_sk, sender_nonce, send_fee, & recipient, send_amt) ;
4275
4280
let tx = submit_tx ( & http_origin, & transfer_tx) ;
4276
4281
info ! ( "Submitted tx {tx} in to mine block N+2" ) ;
4277
- while mined_blocks. load ( Ordering :: SeqCst ) <= blocks_before {
4278
- assert ! (
4279
- start_time. elapsed( ) < short_timeout,
4280
- "FAIL: Test timed out while waiting for block production" ,
4281
- ) ;
4282
- thread:: sleep ( Duration :: from_secs ( 1 ) ) ;
4283
- }
4282
+ wait_for ( short_timeout. as_secs ( ) , || {
4283
+ let info_after = signer_test
4284
+ . stacks_client
4285
+ . get_peer_info ( )
4286
+ . expect ( "Failed to get peer info" ) ;
4287
+ Ok ( info_after. stacks_tip_height > info_before. stacks_tip_height )
4288
+ } )
4289
+ . expect ( "Timed out waiting for block to be mined and processed" ) ;
4284
4290
let blocks_after = mined_blocks. load ( Ordering :: SeqCst ) ;
4285
4291
assert_eq ! ( blocks_after, blocks_before + 1 ) ;
4286
4292
@@ -4348,31 +4354,31 @@ fn reorg_locally_accepted_blocks_across_tenures_succeeds() {
4348
4354
info ! ( "------------------------- Starting Tenure A -------------------------" ) ;
4349
4355
info ! ( "------------------------- Test Mine Nakamoto Block N -------------------------" ) ;
4350
4356
let mined_blocks = signer_test. running_nodes . nakamoto_blocks_mined . clone ( ) ;
4351
- let blocks_before = mined_blocks. load ( Ordering :: SeqCst ) ;
4352
4357
let info_before = signer_test
4353
4358
. stacks_client
4354
4359
. get_peer_info ( )
4355
4360
. expect ( "Failed to get peer info" ) ;
4356
- let start_time = Instant :: now ( ) ;
4357
4361
// submit a tx so that the miner will mine a stacks block
4358
4362
let mut sender_nonce = 0 ;
4359
4363
let transfer_tx =
4360
4364
make_stacks_transfer ( & sender_sk, sender_nonce, send_fee, & recipient, send_amt) ;
4361
4365
let tx = submit_tx ( & http_origin, & transfer_tx) ;
4362
4366
info ! ( "Submitted tx {tx} in to mine block N" ) ;
4363
- while mined_blocks. load ( Ordering :: SeqCst ) <= blocks_before {
4364
- assert ! (
4365
- start_time. elapsed( ) < short_timeout,
4366
- "FAIL: Test timed out while waiting for block production" ,
4367
- ) ;
4368
- thread:: sleep ( Duration :: from_secs ( 1 ) ) ;
4369
- }
4367
+ wait_for ( short_timeout. as_secs ( ) , || {
4368
+ let info_after = signer_test
4369
+ . stacks_client
4370
+ . get_peer_info ( )
4371
+ . expect ( "Failed to get peer info" ) ;
4372
+ Ok ( info_after. stacks_tip_height > info_before. stacks_tip_height )
4373
+ } )
4374
+ . expect ( "Timed out waiting for block to be mined and processed" ) ;
4370
4375
4371
4376
sender_nonce += 1 ;
4372
4377
let info_after = signer_test
4373
4378
. stacks_client
4374
4379
. get_peer_info ( )
4375
4380
. expect ( "Failed to get peer info" ) ;
4381
+
4376
4382
assert_eq ! (
4377
4383
info_before. stacks_tip_height + 1 ,
4378
4384
info_after. stacks_tip_height
@@ -4400,13 +4406,12 @@ fn reorg_locally_accepted_blocks_across_tenures_succeeds() {
4400
4406
make_stacks_transfer ( & sender_sk, sender_nonce, send_fee, & recipient, send_amt) ;
4401
4407
let tx = submit_tx ( & http_origin, & transfer_tx) ;
4402
4408
info ! ( "Submitted tx {tx} in to attempt to mine block N+1" ) ;
4403
- let start_time = Instant :: now ( ) ;
4404
4409
let blocks_before = mined_blocks. load ( Ordering :: SeqCst ) ;
4405
4410
let info_before = signer_test
4406
4411
. stacks_client
4407
4412
. get_peer_info ( )
4408
4413
. expect ( "Failed to get peer info" ) ;
4409
- loop {
4414
+ wait_for ( short_timeout . as_secs ( ) , || {
4410
4415
let ignored_signers = test_observer:: get_stackerdb_chunks ( )
4411
4416
. into_iter ( )
4412
4417
. flat_map ( |chunk| chunk. modified_slots )
@@ -4423,15 +4428,9 @@ fn reorg_locally_accepted_blocks_across_tenures_succeeds() {
4423
4428
}
4424
4429
} )
4425
4430
. collect :: < Vec < _ > > ( ) ;
4426
- if ignored_signers. len ( ) + ignoring_signers. len ( ) == num_signers {
4427
- break ;
4428
- }
4429
- assert ! (
4430
- start_time. elapsed( ) < short_timeout,
4431
- "FAIL: Test timed out while waiting for block proposal acceptance" ,
4432
- ) ;
4433
- sleep_ms ( 1000 ) ;
4434
- }
4431
+ Ok ( ignored_signers. len ( ) + ignoring_signers. len ( ) == num_signers)
4432
+ } )
4433
+ . expect ( "FAIL: Timed out waiting for block proposal acceptance" ) ;
4435
4434
let blocks_after = mined_blocks. load ( Ordering :: SeqCst ) ;
4436
4435
let info_after = signer_test
4437
4436
. stacks_client
@@ -4464,25 +4463,23 @@ fn reorg_locally_accepted_blocks_across_tenures_succeeds() {
4464
4463
. lock ( )
4465
4464
. unwrap ( )
4466
4465
. replace ( Vec :: new ( ) ) ;
4467
- let mined_blocks = signer_test. running_nodes . nakamoto_blocks_mined . clone ( ) ;
4468
- let blocks_before = mined_blocks. load ( Ordering :: SeqCst ) ;
4469
4466
let info_before = signer_test
4470
4467
. stacks_client
4471
4468
. get_peer_info ( )
4472
4469
. expect ( "Failed to get peer info" ) ;
4473
- let start_time = Instant :: now ( ) ;
4474
4470
// submit a tx so that the miner will mine a stacks block
4475
4471
let transfer_tx =
4476
4472
make_stacks_transfer ( & sender_sk, sender_nonce, send_fee, & recipient, send_amt) ;
4477
4473
let tx = submit_tx ( & http_origin, & transfer_tx) ;
4478
4474
info ! ( "Submitted tx {tx} in to mine block N" ) ;
4479
- while mined_blocks. load ( Ordering :: SeqCst ) <= blocks_before {
4480
- assert ! (
4481
- start_time. elapsed( ) < short_timeout,
4482
- "FAIL: Test timed out while waiting for block production" ,
4483
- ) ;
4484
- thread:: sleep ( Duration :: from_secs ( 1 ) ) ;
4485
- }
4475
+ wait_for ( short_timeout. as_secs ( ) , || {
4476
+ let info_after = signer_test
4477
+ . stacks_client
4478
+ . get_peer_info ( )
4479
+ . expect ( "Failed to get peer info" ) ;
4480
+ Ok ( info_after. stacks_tip_height > info_before. stacks_tip_height )
4481
+ } )
4482
+ . expect ( "Timed out waiting for block to be mined and processed" ) ;
4486
4483
4487
4484
let info_after = signer_test
4488
4485
. stacks_client
0 commit comments