@@ -1915,7 +1915,10 @@ fn end_of_tenure() {
1915
1915
let http_origin = format ! ( "http://{}" , & signer_test. running_nodes. conf. node. rpc_bind) ;
1916
1916
let long_timeout = Duration :: from_secs ( 200 ) ;
1917
1917
let short_timeout = Duration :: from_secs ( 20 ) ;
1918
-
1918
+ let blocks_before = signer_test
1919
+ . running_nodes
1920
+ . nakamoto_blocks_mined
1921
+ . load ( Ordering :: SeqCst ) ;
1919
1922
signer_test. boot_to_epoch_3 ( ) ;
1920
1923
let curr_reward_cycle = signer_test. get_current_reward_cycle ( ) ;
1921
1924
// Advance to one before the next reward cycle to ensure we are on the reward cycle boundary
@@ -1928,15 +1931,26 @@ fn end_of_tenure() {
1928
1931
- 2 ;
1929
1932
1930
1933
// give the system a chance to mine a Nakamoto block
1931
- sleep_ms ( 30_000 ) ;
1934
+ // But it doesn't have to mine one for this test to succeed?
1935
+ let start = Instant :: now ( ) ;
1936
+ while start. elapsed ( ) <= short_timeout {
1937
+ let mined_blocks = signer_test
1938
+ . running_nodes
1939
+ . nakamoto_blocks_mined
1940
+ . load ( Ordering :: SeqCst ) ;
1941
+ if mined_blocks > blocks_before {
1942
+ break ;
1943
+ }
1944
+ sleep_ms ( 100 ) ;
1945
+ }
1932
1946
1933
1947
info ! ( "------------------------- Test Mine to Next Reward Cycle Boundary -------------------------" ) ;
1934
1948
signer_test. run_until_burnchain_height_nakamoto (
1935
1949
long_timeout,
1936
1950
final_reward_cycle_height_boundary,
1937
1951
num_signers,
1938
1952
) ;
1939
- println ! ( "Advanced to nexct reward cycle boundary: {final_reward_cycle_height_boundary}" ) ;
1953
+ println ! ( "Advanced to next reward cycle boundary: {final_reward_cycle_height_boundary}" ) ;
1940
1954
assert_eq ! (
1941
1955
signer_test. get_current_reward_cycle( ) ,
1942
1956
final_reward_cycle - 1
@@ -1977,39 +1991,20 @@ fn end_of_tenure() {
1977
1991
std:: thread:: sleep ( Duration :: from_millis ( 100 ) ) ;
1978
1992
}
1979
1993
1980
- info ! ( "Triggering a new block to be mined" ) ;
1981
-
1982
- // Mine a block into the next reward cycle
1983
- let commits_before = signer_test
1984
- . running_nodes
1985
- . commits_submitted
1986
- . load ( Ordering :: SeqCst ) ;
1987
- next_block_and (
1988
- & mut signer_test. running_nodes . btc_regtest_controller ,
1989
- 10 ,
1990
- || {
1991
- let commits_count = signer_test
1992
- . running_nodes
1993
- . commits_submitted
1994
- . load ( Ordering :: SeqCst ) ;
1995
- Ok ( commits_count > commits_before)
1996
- } ,
1997
- )
1998
- . unwrap ( ) ;
1999
-
2000
- // Mine a few blocks so we are well into the next reward cycle
2001
- for _ in 0 ..2 {
1994
+ while signer_test. get_current_reward_cycle ( ) != final_reward_cycle {
2002
1995
next_block_and (
2003
1996
& mut signer_test. running_nodes . btc_regtest_controller ,
2004
1997
10 ,
2005
1998
|| Ok ( true ) ,
2006
1999
)
2007
2000
. unwrap ( ) ;
2001
+ assert ! (
2002
+ start_time. elapsed( ) <= short_timeout,
2003
+ "Timed out waiting to enter the next reward cycle"
2004
+ ) ;
2005
+ std:: thread:: sleep ( Duration :: from_millis ( 100 ) ) ;
2008
2006
}
2009
2007
2010
- sleep_ms ( 10_000 ) ;
2011
- assert_eq ! ( signer_test. get_current_reward_cycle( ) , final_reward_cycle) ;
2012
-
2013
2008
while test_observer:: get_burn_blocks ( )
2014
2009
. last ( )
2015
2010
. unwrap ( )
0 commit comments