@@ -831,31 +831,31 @@ fn reloads_signer_set_in() {
831
831
) ;
832
832
833
833
info ! ( "Waiting for signer set calculation." ) ;
834
- let mut reward_set_calculated = false ;
835
834
let short_timeout = Duration :: from_secs ( 30 ) ;
836
- let now = std:: time:: Instant :: now ( ) ;
837
835
// Make sure the signer set is calculated before continuing or signers may not
838
836
// recognize that they are registered signers in the subsequent burn block event
839
837
let reward_cycle = signer_test. get_current_reward_cycle ( ) + 1 ;
840
838
signer_test
841
839
. running_nodes
842
840
. btc_regtest_controller
843
841
. build_next_block ( 1 ) ;
844
- while !reward_set_calculated {
845
- let reward_set = signer_test
842
+ wait_for ( short_timeout . as_secs ( ) , || {
843
+ let reward_set = match signer_test
846
844
. stacks_client
847
845
. get_reward_set_signers ( reward_cycle)
848
- . expect ( "Failed to check if reward set is calculated" ) ;
849
- reward_set_calculated = reward_set. is_some ( ) ;
850
- if reward_set_calculated {
851
- info ! ( "Signer set: {:?}" , reward_set. unwrap( ) ) ;
846
+ {
847
+ Ok ( x) => x,
848
+ Err ( e) => {
849
+ warn ! ( "Failed to check if reward set is calculated yet: {e:?}. Will try again" ) ;
850
+ return Ok ( false ) ;
851
+ }
852
+ } ;
853
+ if let Some ( ref set) = reward_set {
854
+ info ! ( "Signer set: {:?}" , set) ;
852
855
}
853
- std:: thread:: sleep ( Duration :: from_secs ( 1 ) ) ;
854
- assert ! (
855
- now. elapsed( ) < short_timeout,
856
- "Timed out waiting for reward set calculation"
857
- ) ;
858
- }
856
+ Ok ( reward_set. is_some ( ) )
857
+ } )
858
+ . expect ( "Timed out waiting for reward set to be calculated" ) ;
859
859
info ! ( "Signer set calculated" ) ;
860
860
861
861
// Manually consume one more block to ensure signers refresh their state
0 commit comments