@@ -2227,53 +2227,56 @@ fn signers_broadcast_signed_blocks() {
2227
2227
let http_origin = format ! ( "http://{}" , & signer_test. running_nodes. conf. node. rpc_bind) ;
2228
2228
2229
2229
signer_test. boot_to_epoch_3 ( ) ;
2230
- sleep_ms ( 10_000 ) ;
2231
-
2230
+ let info_before = get_chain_info ( & signer_test. running_nodes . conf ) ;
2231
+ let blocks_before = signer_test
2232
+ . running_nodes
2233
+ . nakamoto_blocks_mined
2234
+ . load ( Ordering :: SeqCst ) ;
2232
2235
signer_test. mine_nakamoto_block ( Duration :: from_secs ( 30 ) ) ;
2233
- sleep_ms ( 10_000 ) ;
2234
2236
2235
- TEST_IGNORE_SIGNERS . lock ( ) . unwrap ( ) . replace ( true ) ;
2237
+ wait_for ( 30 , || {
2238
+ let blocks_mined = signer_test
2239
+ . running_nodes
2240
+ . nakamoto_blocks_mined
2241
+ . load ( Ordering :: SeqCst ) ;
2242
+ let info = get_chain_info ( & signer_test. running_nodes . conf ) ;
2243
+ debug ! (
2244
+ "blocks_mined: {},{}, stacks_tip_height: {},{}" ,
2245
+ blocks_mined, blocks_before, info. stacks_tip_height, info_before. stacks_tip_height
2246
+ ) ;
2247
+ Ok ( blocks_mined > blocks_before && info. stacks_tip_height > info_before. stacks_tip_height )
2248
+ } )
2249
+ . expect ( "Timed out waiting for first nakamoto block to be mined" ) ;
2236
2250
2251
+ TEST_IGNORE_SIGNERS . lock ( ) . unwrap ( ) . replace ( true ) ;
2237
2252
let blocks_before = signer_test
2238
2253
. running_nodes
2239
2254
. nakamoto_blocks_mined
2240
2255
. load ( Ordering :: SeqCst ) ;
2241
-
2242
2256
let signer_pushed_before = signer_test
2243
2257
. running_nodes
2244
2258
. nakamoto_blocks_signer_pushed
2245
2259
. load ( Ordering :: SeqCst ) ;
2246
-
2247
2260
let info_before = get_chain_info ( & signer_test. running_nodes . conf ) ;
2248
2261
2249
- // submit a tx so that the miner will mine a block
2262
+ // submit a tx so that the miner will mine a blockn
2250
2263
let sender_nonce = 0 ;
2251
2264
let transfer_tx =
2252
2265
make_stacks_transfer ( & sender_sk, sender_nonce, send_fee, & recipient, send_amt) ;
2253
2266
submit_tx ( & http_origin, & transfer_tx) ;
2254
2267
2255
2268
debug ! ( "Transaction sent; waiting for block-mining" ) ;
2256
2269
2257
- let start = Instant :: now ( ) ;
2258
- let duration = 60 ;
2259
- loop {
2260
- let blocks_mined = signer_test
2261
- . running_nodes
2262
- . nakamoto_blocks_mined
2263
- . load ( Ordering :: SeqCst ) ;
2270
+ wait_for ( 30 , || {
2264
2271
let signer_pushed = signer_test
2265
2272
. running_nodes
2266
2273
. nakamoto_blocks_signer_pushed
2267
2274
. load ( Ordering :: SeqCst ) ;
2268
-
2275
+ let blocks_mined = signer_test
2276
+ . running_nodes
2277
+ . nakamoto_blocks_mined
2278
+ . load ( Ordering :: SeqCst ) ;
2269
2279
let info = get_chain_info ( & signer_test. running_nodes . conf ) ;
2270
- if blocks_mined > blocks_before
2271
- && signer_pushed > signer_pushed_before
2272
- && info. stacks_tip_height > info_before. stacks_tip_height
2273
- {
2274
- break ;
2275
- }
2276
-
2277
2280
debug ! (
2278
2281
"blocks_mined: {},{}, signers_pushed: {},{}, stacks_tip_height: {},{}" ,
2279
2282
blocks_mined,
@@ -2283,12 +2286,11 @@ fn signers_broadcast_signed_blocks() {
2283
2286
info. stacks_tip_height,
2284
2287
info_before. stacks_tip_height
2285
2288
) ;
2286
-
2287
- std:: thread:: sleep ( Duration :: from_millis ( 100 ) ) ;
2288
- if start. elapsed ( ) >= Duration :: from_secs ( duration) {
2289
- panic ! ( "Timed out" ) ;
2290
- }
2291
- }
2289
+ Ok ( blocks_mined > blocks_before
2290
+ && info. stacks_tip_height > info_before. stacks_tip_height
2291
+ && signer_pushed > signer_pushed_before)
2292
+ } )
2293
+ . expect ( "Timed out waiting for second nakamoto block to be mined" ) ;
2292
2294
2293
2295
signer_test. shutdown ( ) ;
2294
2296
}
@@ -4754,7 +4756,7 @@ fn miner_recovers_when_broadcast_block_delay_across_tenures_occurs() {
4754
4756
4755
4757
info ! ( "Allowing miner to accept block responses again. " ) ;
4756
4758
TEST_IGNORE_SIGNERS . lock ( ) . unwrap ( ) . replace ( false ) ;
4757
- info ! ( "Allowing singers to broadcast block N+1 to the miner" ) ;
4759
+ info ! ( "Allowing signers to broadcast block N+1 to the miner" ) ;
4758
4760
TEST_PAUSE_BLOCK_BROADCAST . lock ( ) . unwrap ( ) . replace ( false ) ;
4759
4761
4760
4762
// Assert the N+1' block was rejected
0 commit comments