Skip to content

Commit 5f54144

Browse files
committed
Do not assume every signer rejects for testing directive reasons as they may hit the threshold rejection first
Signed-off-by: Jacinta Ferrant <[email protected]>
1 parent 0f8c4b8 commit 5f54144

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,6 @@ impl<S: Signer<T> + Send + 'static, T: SignerEventTrait + 'static> SignerTest<Sp
724724
&self,
725725
timeout_secs: u64,
726726
expected_signers: &[StacksPublicKey],
727-
reject_code: Option<RejectCode>,
728727
) -> Result<(), String> {
729728
wait_for(timeout_secs, || {
730729
let stackerdb_events = test_observer::get_stackerdb_chunks();
@@ -740,11 +739,6 @@ impl<S: Signer<T> + Send + 'static, T: SignerEventTrait + 'static> SignerTest<Sp
740739
.recover_public_key()
741740
.expect("Failed to recover public key from rejection");
742741
if expected_signers.contains(&rejected_pubkey) {
743-
if let Some(reject_code) = reject_code.as_ref() {
744-
if reject_code != &rejection.reason_code {
745-
return None;
746-
}
747-
}
748742
Some(rejection)
749743
} else {
750744
None

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3952,6 +3952,7 @@ fn locally_accepted_blocks_overriden_by_global_rejection() {
39523952
let send_fee = 180;
39533953
let nmb_txs = 2;
39543954
let recipient = PrincipalData::from(StacksAddress::burn_address(false));
3955+
let short_timeout_secs = 20;
39553956
let mut signer_test: SignerTest<SpawnedSigner> = SignerTest::new(
39563957
num_signers,
39573958
vec![(sender_addr.clone(), (send_amt + send_fee) * nmb_txs)],
@@ -3976,7 +3977,7 @@ fn locally_accepted_blocks_overriden_by_global_rejection() {
39763977
make_stacks_transfer(&sender_sk, sender_nonce, send_fee, &recipient, send_amt);
39773978
let tx = submit_tx(&http_origin, &transfer_tx);
39783979
info!("Submitted tx {tx} in to mine block N");
3979-
wait_for(30, || {
3980+
wait_for(short_timeout_secs, || {
39803981
Ok(mined_blocks.load(Ordering::SeqCst) > blocks_before
39813982
&& signer_test
39823983
.stacks_client
@@ -3996,7 +3997,11 @@ fn locally_accepted_blocks_overriden_by_global_rejection() {
39963997
let block_n = nakamoto_blocks.last().unwrap();
39973998
assert_eq!(info_after.stacks_tip.to_string(), block_n.block_hash);
39983999
signer_test
3999-
.wait_for_block_acceptance(30, &block_n.signer_signature_hash, &all_signers)
4000+
.wait_for_block_acceptance(
4001+
short_timeout_secs,
4002+
&block_n.signer_signature_hash,
4003+
&all_signers,
4004+
)
40004005
.expect("Timed out waiting for block acceptance of N");
40014006

40024007
info!("------------------------- Attempt to Mine Nakamoto Block N+1 -------------------------");
@@ -4014,8 +4019,9 @@ fn locally_accepted_blocks_overriden_by_global_rejection() {
40144019

40154020
let blocks_before = mined_blocks.load(Ordering::SeqCst);
40164021
let info_before = signer_test.stacks_client.get_peer_info().unwrap();
4022+
// We cannot gaurantee that ALL signers will reject due to the testing directive as we may hit majority first..So ensure that we only assert that up to the threshold number rejected
40174023
signer_test
4018-
.wait_for_block_rejections(60, &rejecting_signers, Some(RejectCode::TestingDirective))
4024+
.wait_for_block_rejections(short_timeout_secs, &rejecting_signers)
40194025
.expect("Timed out waiting for block rejection of N+1");
40204026

40214027
assert_eq!(blocks_before, mined_blocks.load(Ordering::SeqCst));
@@ -4032,7 +4038,7 @@ fn locally_accepted_blocks_overriden_by_global_rejection() {
40324038
.lock()
40334039
.unwrap()
40344040
.replace(Vec::new());
4035-
wait_for(30, || {
4041+
wait_for(short_timeout_secs, || {
40364042
Ok(mined_blocks.load(Ordering::SeqCst) > blocks_before
40374043
&& signer_test
40384044
.stacks_client
@@ -4061,7 +4067,11 @@ fn locally_accepted_blocks_overriden_by_global_rejection() {
40614067
assert_ne!(block_n_1_prime, block_n_1);
40624068
// Verify that all signers accepted the new block proposal
40634069
signer_test
4064-
.wait_for_block_acceptance(30, &block_n_1_prime.signer_signature_hash, &all_signers)
4070+
.wait_for_block_acceptance(
4071+
short_timeout_secs,
4072+
&block_n_1_prime.signer_signature_hash,
4073+
&all_signers,
4074+
)
40654075
.expect("Timed out waiting for block acceptance of N+1'");
40664076
}
40674077

@@ -4195,11 +4205,7 @@ fn locally_rejected_blocks_overriden_by_global_acceptance() {
41954205
.expect("Timed out waiting for stacks block N+1 to be mined");
41964206

41974207
signer_test
4198-
.wait_for_block_rejections(
4199-
short_timeout,
4200-
&rejecting_signers,
4201-
Some(RejectCode::TestingDirective),
4202-
)
4208+
.wait_for_block_rejections(short_timeout, &rejecting_signers)
42034209
.expect("Timed out waiting for block rejection of N+1");
42044210

42054211
// Assert the block was mined

0 commit comments

Comments
 (0)