@@ -771,29 +771,36 @@ pub fn next_block_and_process_new_stacks_block(
771
771
772
772
/// Mine a bitcoin block, and wait until:
773
773
/// number_of_blocks has been processed by the coordinator
774
- pub fn next_block_and_process_new_stacks_blocks (
774
+ pub fn next_block_and_process_new_stacks_blocks < F > (
775
775
btc_controller : & BitcoinRegtestController ,
776
- number_of_blocks : u32 ,
776
+ number_of_blocks : u64 ,
777
777
timeout_secs : u64 ,
778
778
coord_channels : & Arc < Mutex < CoordinatorChannels > > ,
779
- ) -> Result < ( ) , String > {
780
- for _ in 0 ..number_of_blocks {
781
- let blocks_processed_before = coord_channels
779
+ mut post_block_generation : F ,
780
+ ) -> Result < ( ) , String >
781
+ where
782
+ F : FnMut ( ) -> Result < ( ) , String > ,
783
+ {
784
+ let blocks_processed_before = coord_channels
785
+ . lock ( )
786
+ . expect ( "Mutex poisoned" )
787
+ . get_stacks_blocks_processed ( ) ;
788
+ let mut block_processed_current = blocks_processed_before;
789
+ next_block_and ( btc_controller, timeout_secs, || {
790
+ let blocks_processed = coord_channels
782
791
. lock ( )
783
792
. expect ( "Mutex poisoned" )
784
793
. get_stacks_blocks_processed ( ) ;
785
- next_block_and ( btc_controller, timeout_secs, || {
786
- let blocks_processed = coord_channels
787
- . lock ( )
788
- . expect ( "Mutex poisoned" )
789
- . get_stacks_blocks_processed ( ) ;
790
- if blocks_processed > blocks_processed_before {
791
- return Ok ( true ) ;
792
- }
793
- Ok ( false )
794
- } ) ?;
795
- }
796
- Ok ( ( ) )
794
+ // new block?
795
+ if blocks_processed > block_processed_current {
796
+ post_block_generation ( ) ?;
797
+ block_processed_current += 1 ;
798
+ }
799
+ if blocks_processed >= blocks_processed_before + number_of_blocks {
800
+ return Ok ( true ) ;
801
+ }
802
+ Ok ( false )
803
+ } )
797
804
}
798
805
799
806
/// Mine a bitcoin block, and wait until:
@@ -13002,7 +13009,8 @@ fn test_sip_031_last_phase() {
13002
13009
let sender_signer_sk = Secp256k1PrivateKey :: random ( ) ;
13003
13010
let sender_signer_addr = tests:: to_addr ( & sender_signer_sk) ;
13004
13011
let mut signers = TestSigners :: new ( vec ! [ sender_signer_sk] ) ;
13005
- let tenure_count = 5 ;
13012
+ // let's assume funds for 200 tenures
13013
+ let tenure_count = 200 ;
13006
13014
let inter_blocks_per_tenure = 9 ;
13007
13015
// setup sender + recipient for some test stx transfers
13008
13016
// these are necessary for the interim blocks to get mined at all
@@ -13150,6 +13158,9 @@ fn test_sip_031_last_phase() {
13150
13158
)
13151
13159
. unwrap ( ) ;
13152
13160
13161
+ let http_origin = format ! ( "http://{}" , & naka_conf. node. rpc_bind) ;
13162
+
13163
+ let mut sender_nonce = 0 ;
13153
13164
// 50 more tenures (each one with 3 stacks blocks)
13154
13165
for _ in 0 ..50 {
13155
13166
let commits_before = commits_submitted. load ( Ordering :: SeqCst ) ;
@@ -13158,6 +13169,19 @@ fn test_sip_031_last_phase() {
13158
13169
3 ,
13159
13170
60 ,
13160
13171
& coord_channel,
13172
+ || {
13173
+ let transfer_tx = make_stacks_transfer_serialized (
13174
+ & sender_sk,
13175
+ sender_nonce,
13176
+ send_fee,
13177
+ naka_conf. burnchain . chain_id ,
13178
+ & PrincipalData :: from ( sender_signer_addr) ,
13179
+ send_amt,
13180
+ ) ;
13181
+ submit_tx ( & http_origin, & transfer_tx) ;
13182
+ sender_nonce += 1 ;
13183
+ Ok ( ( ) )
13184
+ } ,
13161
13185
)
13162
13186
. unwrap ( ) ;
13163
13187
wait_for ( 20 , || {
@@ -13214,8 +13238,8 @@ fn test_sip_031_last_phase() {
13214
13238
}
13215
13239
}
13216
13240
13217
- // (100_000 + 200_000 + 300_000) * 5
13218
- assert_eq ! ( total_minted_and_transferred, 3_000_000 ) ;
13241
+ // (100_000 + 200_000 + 300_000) * 10
13242
+ assert_eq ! ( total_minted_and_transferred, 6_000_000 ) ;
13219
13243
13220
13244
let latest_stacks_block_id = get_latest_block_proposal ( & naka_conf, & sortdb)
13221
13245
. unwrap ( )
0 commit comments