Skip to content

Commit 273156e

Browse files
committed
test: add simple fast_sortition test
This test fails in develop but passes with the changes in #5515.
1 parent 8b4c3d6 commit 273156e

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

.github/workflows/bitcoin-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ jobs:
142142
- tests::signer::v0::incoming_signers_ignore_block_proposals
143143
- tests::signer::v0::outgoing_signers_ignore_block_proposals
144144
- tests::signer::v0::injected_signatures_are_ignored_across_boundaries
145+
- tests::signer::v0::fast_sortition
145146
- tests::nakamoto_integrations::burn_ops_integration_test
146147
- tests::nakamoto_integrations::check_block_heights
147148
- tests::nakamoto_integrations::clarity_burn_state

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

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11175,3 +11175,79 @@ fn injected_signatures_are_ignored_across_boundaries() {
1117511175

1117611176
assert!(new_spawned_signer.stop().is_none());
1117711177
}
11178+
11179+
#[test]
11180+
#[ignore]
11181+
fn fast_sortition() {
11182+
if env::var("BITCOIND_TEST") != Ok("1".into()) {
11183+
return;
11184+
}
11185+
11186+
info!("------------------------- Test Setup -------------------------");
11187+
let num_signers = 5;
11188+
let sender_sk = Secp256k1PrivateKey::new();
11189+
let sender_addr = tests::to_addr(&sender_sk);
11190+
let mut sender_nonce = 0;
11191+
let send_amt = 100;
11192+
let send_fee = 400;
11193+
let num_transfers = 3;
11194+
let recipient = PrincipalData::from(StacksAddress::burn_address(false));
11195+
let mut signer_test: SignerTest<SpawnedSigner> = SignerTest::new(
11196+
num_signers,
11197+
vec![(sender_addr, num_transfers * (send_amt + send_fee))],
11198+
);
11199+
11200+
let http_origin = format!("http://{}", &signer_test.running_nodes.conf.node.rpc_bind);
11201+
11202+
signer_test.boot_to_epoch_3();
11203+
11204+
info!("------------------------- Mine a Block -------------------------");
11205+
let transfer_tx = make_stacks_transfer(
11206+
&sender_sk,
11207+
sender_nonce,
11208+
send_fee,
11209+
signer_test.running_nodes.conf.burnchain.chain_id,
11210+
&recipient,
11211+
send_amt,
11212+
);
11213+
submit_tx(&http_origin, &transfer_tx);
11214+
sender_nonce += 1;
11215+
11216+
wait_for(60, || {
11217+
Ok(get_account(&http_origin, &sender_addr).nonce == sender_nonce)
11218+
})
11219+
.expect("Timed out waiting for call tx to be mined");
11220+
11221+
info!("------------------------- Cause a missed sortition -------------------------");
11222+
11223+
signer_test
11224+
.running_nodes
11225+
.btc_regtest_controller
11226+
.build_next_block(1);
11227+
next_block_and_process_new_stacks_block(
11228+
&mut signer_test.running_nodes.btc_regtest_controller,
11229+
60,
11230+
&signer_test.running_nodes.coord_channel,
11231+
)
11232+
.expect("Failed to mine a block");
11233+
11234+
info!("------------------------- Mine a Block -------------------------");
11235+
let transfer_tx = make_stacks_transfer(
11236+
&sender_sk,
11237+
sender_nonce,
11238+
send_fee,
11239+
signer_test.running_nodes.conf.burnchain.chain_id,
11240+
&recipient,
11241+
send_amt,
11242+
);
11243+
submit_tx(&http_origin, &transfer_tx);
11244+
sender_nonce += 1;
11245+
11246+
wait_for(60, || {
11247+
Ok(get_account(&http_origin, &sender_addr).nonce == sender_nonce)
11248+
})
11249+
.expect("Timed out waiting for call tx to be mined");
11250+
11251+
info!("------------------------- Shutdown -------------------------");
11252+
signer_test.shutdown();
11253+
}

0 commit comments

Comments
 (0)