@@ -759,39 +759,43 @@ impl MultipleMinerTest {
759
759
Ok ( txid)
760
760
}
761
761
762
- pub fn send_contract_publish ( & mut self , contract_name : & str , contract_src : & str ) -> String {
763
- let http_origin = format ! (
764
- "http://{}" ,
765
- & self . signer_test. running_nodes. conf. node. rpc_bind
766
- ) ;
762
+ pub fn send_contract_publish (
763
+ & mut self ,
764
+ sender_nonce : u64 ,
765
+ contract_name : & str ,
766
+ contract_src : & str ,
767
+ ) -> String {
768
+ let http_origin = self . node_http ( ) ;
769
+ let sender_addr = tests:: to_addr ( & self . sender_sk ) ;
767
770
let contract_tx = make_contract_publish (
768
771
& self . sender_sk ,
769
- self . sender_nonce ,
772
+ sender_nonce,
770
773
self . send_fee + contract_name. len ( ) as u64 + contract_src. len ( ) as u64 ,
771
774
self . signer_test . running_nodes . conf . burnchain . chain_id ,
772
775
contract_name,
773
776
contract_src,
774
777
) ;
775
- self . sender_nonce += 1 ;
776
778
submit_tx ( & http_origin, & contract_tx)
777
779
}
778
780
779
781
/// Sends a contract publish tx to the stacks node and waits for the stacks node to mine it
780
782
/// Returns the txid of the transfer tx.
781
783
pub fn send_and_mine_contract_publish (
782
784
& mut self ,
785
+ sender_nonce : u64 ,
783
786
contract_name : & str ,
784
787
contract_src : & str ,
785
788
timeout_secs : u64 ,
786
789
) -> Result < String , String > {
787
790
let stacks_height_before = self . get_peer_stacks_tip_height ( ) ;
788
791
789
- let txid = self . send_contract_publish ( contract_name, contract_src) ;
792
+ let txid = self . send_contract_publish ( sender_nonce , contract_name, contract_src) ;
790
793
791
794
// wait for the new block to be mined
792
795
wait_for ( timeout_secs, || {
793
796
Ok ( self . get_peer_stacks_tip_height ( ) > stacks_height_before)
794
- } ) ?;
797
+ } )
798
+ . unwrap ( ) ;
795
799
796
800
// wait for the observer to see it
797
801
self . wait_for_test_observer_blocks ( timeout_secs) ;
@@ -805,25 +809,22 @@ impl MultipleMinerTest {
805
809
806
810
pub fn send_contract_call (
807
811
& mut self ,
812
+ sender_nonce : u64 ,
808
813
contract_name : & str ,
809
814
function_name : & str ,
810
815
function_args : & [ clarity:: vm:: Value ] ,
811
816
) -> String {
812
- let http_origin = format ! (
813
- "http://{}" ,
814
- & self . signer_test. running_nodes. conf. node. rpc_bind
815
- ) ;
817
+ let http_origin = self . node_http ( ) ;
816
818
let contract_tx = make_contract_call (
817
819
& self . sender_sk ,
818
- self . sender_nonce ,
820
+ sender_nonce,
819
821
self . send_fee ,
820
822
self . signer_test . running_nodes . conf . burnchain . chain_id ,
821
823
& tests:: to_addr ( & self . sender_sk ) ,
822
824
contract_name,
823
825
function_name,
824
826
function_args,
825
827
) ;
826
- self . sender_nonce += 1 ;
827
828
submit_tx ( & http_origin, & contract_tx)
828
829
}
829
830
@@ -8232,7 +8233,7 @@ fn block_proposal_max_age_rejections() {
8232
8233
let short_timeout = Duration :: from_secs ( 30 ) ;
8233
8234
8234
8235
info ! ( "------------------------- Send Block Proposal To Signers -------------------------" ) ;
8235
- let info_before = get_chain_info ( & signer_test. running_nodes . conf ) ;
8236
+ let _ = get_chain_info ( & signer_test. running_nodes . conf ) ;
8236
8237
let mut block = NakamotoBlock {
8237
8238
header : NakamotoBlockHeader :: empty ( ) ,
8238
8239
txs : vec ! [ ] ,
@@ -8301,7 +8302,9 @@ fn block_proposal_max_age_rejections() {
8301
8302
. unwrap_or ( ( 0 , 0 ) ) ;
8302
8303
assert_eq ! ( block_2_status. 1 , 0 , "Block 2 should always be rejected" ) ;
8303
8304
8304
- info ! ( "Block 2 status" ; "accepted" => block_2_status. 1 , "rejected" => block_2_status. 0 ) ;
8305
+ info ! ( "Block 2 status" ;
8306
+ "accepted" => %block_2_status. 1 , "rejected" => %block_2_status. 0
8307
+ ) ;
8305
8308
Ok ( block_2_status. 0 > num_signers * 7 / 10 )
8306
8309
} )
8307
8310
. expect ( "Timed out waiting for block rejections" ) ;
@@ -12474,19 +12477,25 @@ fn miner_rejection_by_contract_call_execution_time_expired() {
12474
12477
// First, lets deploy the contract
12475
12478
let dummy_contract_src = "(define-public (dummy (number uint)) (begin (ok (+ number u1))))" ;
12476
12479
12480
+ let sender_nonce = 0 ;
12481
+
12477
12482
let _ = miners
12478
- . send_and_mine_contract_publish ( "dummy-contract" , dummy_contract_src, 60 )
12483
+ . send_and_mine_contract_publish ( sender_nonce , "dummy-contract" , dummy_contract_src, 60 )
12479
12484
. expect ( "Failed to publish contract in a new block" ) ;
12480
12485
12481
12486
info ! ( "------------------------- Miner 1 Mines a Nakamoto Block N+1 -------------------------" ) ;
12482
12487
12483
12488
let stacks_height_before = miners. get_peer_stacks_tip_height ( ) ;
12484
12489
12485
- let tx1 = miners. send_transfer_tx ( ) ;
12490
+ let ( tx1, sender_nonce ) = miners. send_transfer_tx ( ) ;
12486
12491
12487
12492
// try calling the contract (has to fail)
12488
- let contract_call_txid =
12489
- miners. send_contract_call ( "dummy-contract" , "dummy" , & [ clarity:: vm:: Value :: UInt ( 1 ) ] ) ;
12493
+ let contract_call_txid = miners. send_contract_call (
12494
+ sender_nonce + 1 ,
12495
+ "dummy-contract" ,
12496
+ "dummy" ,
12497
+ & [ clarity:: vm:: Value :: UInt ( 1 ) ] ,
12498
+ ) ;
12490
12499
12491
12500
let _ = wait_for ( 60 , || {
12492
12501
Ok ( miners. get_peer_stacks_tip_height ( ) > stacks_height_before)
@@ -12499,8 +12508,6 @@ fn miner_rejection_by_contract_call_execution_time_expired() {
12499
12508
12500
12509
info ! ( "------------------------- Miner 1 Mines a Nakamoto Block N+2 -------------------------" ) ;
12501
12510
12502
- miners. sender_nonce -= 1 ;
12503
-
12504
12511
let tx2 = miners
12505
12512
. send_and_mine_transfer_tx ( 60 )
12506
12513
. expect ( "Failed to mine N + 2" ) ;
@@ -12523,8 +12530,12 @@ fn miner_rejection_by_contract_call_execution_time_expired() {
12523
12530
12524
12531
let stacks_height_before = miners. get_peer_stacks_tip_height ( ) ;
12525
12532
12526
- let contract_call_txid =
12527
- miners. send_contract_call ( "dummy-contract" , "dummy" , & [ clarity:: vm:: Value :: UInt ( 1 ) ] ) ;
12533
+ let contract_call_txid = miners. send_contract_call (
12534
+ sender_nonce + 2 ,
12535
+ "dummy-contract" ,
12536
+ "dummy" ,
12537
+ & [ clarity:: vm:: Value :: UInt ( 1 ) ] ,
12538
+ ) ;
12528
12539
12529
12540
let _ = wait_for_block_pushed_by_miner_key ( 30 , stacks_height_before + 1 , & miner_pk_2)
12530
12541
. expect ( "Failed to get block N+3" ) ;
@@ -12607,10 +12618,10 @@ fn miner_rejection_by_contract_publish_execution_time_expired() {
12607
12618
let dummy_contract_src =
12608
12619
"(define-public (dummy (number uint)) (begin (ok (+ number u1))))(+ 1 1)" ;
12609
12620
12610
- let tx1 = miners. send_transfer_tx ( ) ;
12621
+ let ( tx1, sender_nonce ) = miners. send_transfer_tx ( ) ;
12611
12622
12612
12623
let _ = miners
12613
- . send_and_mine_contract_publish ( "dummy-contract" , dummy_contract_src, 60 )
12624
+ . send_and_mine_contract_publish ( sender_nonce + 1 , "dummy-contract" , dummy_contract_src, 60 )
12614
12625
. expect_err ( "Expected an error while publishing contract in a new block" ) ;
12615
12626
12616
12627
assert_eq ! ( last_block_contains_txid( & tx1) , true ) ;
@@ -12627,10 +12638,8 @@ fn miner_rejection_by_contract_publish_execution_time_expired() {
12627
12638
12628
12639
info ! ( "------------------------- Miner 2 Mines Block N+1 -------------------------" ) ;
12629
12640
12630
- miners. sender_nonce -= 1 ;
12631
-
12632
12641
let _ = miners
12633
- . send_and_mine_contract_publish ( "dummy-contract" , dummy_contract_src, 60 )
12642
+ . send_and_mine_contract_publish ( sender_nonce + 1 , "dummy-contract" , dummy_contract_src, 60 )
12634
12643
. expect ( "Failed to publish contract in a new block" ) ;
12635
12644
12636
12645
verify_sortition_winner ( & sortdb, & miner_pkh_2) ;
0 commit comments