Skip to content

Commit 21ec8db

Browse files
committed
refactored test api
1 parent 3e0d03f commit 21ec8db

File tree

1 file changed

+16
-17
lines changed
  • testnet/stacks-node/src/tests/signer

1 file changed

+16
-17
lines changed

testnet/stacks-node/src/tests/signer/v0.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -792,11 +792,22 @@ impl MultipleMinerTest {
792792
timeout_secs: u64,
793793
) -> Result<String, String> {
794794
let stacks_height_before = self.get_peer_stacks_tip_height();
795+
795796
let txid = self.send_contract_publish(contract_name, contract_src);
797+
798+
// wait for the new block to be mined
796799
wait_for(timeout_secs, || {
797800
Ok(self.get_peer_stacks_tip_height() > stacks_height_before)
798801
})?;
799-
Ok(txid)
802+
803+
// wait for the observer to see it
804+
self.wait_for_test_observer_blocks(timeout_secs);
805+
806+
if last_block_contains_txid(&txid) {
807+
Ok(txid)
808+
} else {
809+
Err(txid)
810+
}
800811
}
801812

802813
pub fn send_contract_call(
@@ -12592,14 +12603,10 @@ fn miner_rejection_by_contract_call_execution_time_expired() {
1259212603
// First, lets deploy the contract
1259312604
let dummy_contract_src = "(define-public (dummy (number uint)) (begin (ok (+ number u1))))";
1259412605

12595-
let contract_publish_txid = miners
12606+
let _ = miners
1259612607
.send_and_mine_contract_publish("dummy-contract", dummy_contract_src, 60)
1259712608
.expect("Failed to publish contract in a new block");
1259812609

12599-
miners.wait_for_test_observer_blocks(60);
12600-
12601-
assert_eq!(last_block_contains_txid(&contract_publish_txid), true);
12602-
1260312610
info!("------------------------- Miner 1 Mines a Nakamoto Block N+1 -------------------------");
1260412611

1260512612
let stacks_height_before = miners.get_peer_stacks_tip_height();
@@ -12731,16 +12738,12 @@ fn miner_rejection_by_contract_publish_execution_time_expired() {
1273112738

1273212739
let tx1 = miners.send_transfer_tx();
1273312740

12734-
let contract_publish_txid = miners
12741+
let _ = miners
1273512742
.send_and_mine_contract_publish("dummy-contract", dummy_contract_src, 60)
12736-
.expect("Failed to publish contract in a new block");
12737-
12738-
miners.wait_for_test_observer_blocks(60);
12743+
.expect_err("Expected an error while publishing contract in a new block");
1273912744

1274012745
assert_eq!(last_block_contains_txid(&tx1), true);
1274112746

12742-
assert_eq!(last_block_contains_txid(&contract_publish_txid), false);
12743-
1274412747
verify_sortition_winner(&sortdb, &miner_pkh_1);
1274512748

1274612749
info!("------------------------- Miner 2 Submits a Block Commit -------------------------");
@@ -12755,14 +12758,10 @@ fn miner_rejection_by_contract_publish_execution_time_expired() {
1275512758

1275612759
miners.sender_nonce -= 1;
1275712760

12758-
let contract_publish_txid = miners
12761+
let _ = miners
1275912762
.send_and_mine_contract_publish("dummy-contract", dummy_contract_src, 60)
1276012763
.expect("Failed to publish contract in a new block");
1276112764

12762-
miners.wait_for_test_observer_blocks(60);
12763-
12764-
assert_eq!(last_block_contains_txid(&contract_publish_txid), true);
12765-
1276612765
verify_sortition_winner(&sortdb, &miner_pkh_2);
1276712766

1276812767
// ensure both miners are aligned

0 commit comments

Comments
 (0)