Skip to content

Commit 4f21011

Browse files
authored
Merge pull request #5352 from stacks-network/fix/partial-tenure-fork
Fix partial tenure fork test for real: Only check if we advanced pre fork miner 2 blocks forward
2 parents 50c723a + c4a88f6 commit 4f21011

File tree

1 file changed

+7
-15
lines changed
  • testnet/stacks-node/src/tests/signer

1 file changed

+7
-15
lines changed

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

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3874,12 +3874,9 @@ fn partial_tenure_fork() {
38743874

38753875
let mut miner_1_blocks = 0;
38763876
let mut miner_2_blocks = 0;
3877-
// Make sure that both miner 1 and 2 mine at least 1 block each
3878-
while miner_1_tenures < min_miner_1_tenures
3879-
|| miner_2_tenures < min_miner_2_tenures
3880-
|| miner_1_blocks == 0
3881-
|| miner_2_blocks == 0
3882-
{
3877+
let mut min_miner_2_blocks = 0;
3878+
3879+
while miner_1_tenures < min_miner_1_tenures || miner_2_tenures < min_miner_2_tenures {
38833880
if btc_blocks_mined >= max_nakamoto_tenures {
38843881
panic!("Produced {btc_blocks_mined} sortitions, but didn't cover the test scenarios, aborting");
38853882
}
@@ -3963,6 +3960,7 @@ fn partial_tenure_fork() {
39633960
// Ensure that miner 2 runs at least one more tenure
39643961
min_miner_2_tenures = miner_2_tenures + 1;
39653962
fork_initiated = true;
3963+
min_miner_2_blocks = miner_2_blocks;
39663964
}
39673965
if miner == 2 && miner_2_tenures == min_miner_2_tenures {
39683966
// This is the forking tenure. Ensure that miner 1 runs one more
@@ -4096,15 +4094,9 @@ fn partial_tenure_fork() {
40964094
// The height may be higher than expected due to extra transactions waiting
40974095
// to be mined during the forking miner's tenure.
40984096
// We cannot guarantee due to TooMuchChaining that the miner will mine inter_blocks_per_tenure
4099-
let min_num_miner_2_blocks = std::cmp::min(
4100-
miner_2_blocks,
4101-
min_miner_2_tenures * (inter_blocks_per_tenure + 1),
4102-
);
4103-
assert!(
4104-
miner_2_tenures >= min_miner_2_tenures,
4105-
"Miner 2 failed to win its minimum number of tenures"
4106-
);
4107-
assert!(peer_1_height >= pre_nakamoto_peer_1_height + miner_1_blocks + min_num_miner_2_blocks,);
4097+
// Must be at least the number of blocks mined by miner 1 and the number of blocks mined by miner 2
4098+
// before the fork was initiated
4099+
assert!(peer_1_height >= pre_nakamoto_peer_1_height + miner_1_blocks + min_miner_2_blocks);
41084100
assert_eq!(
41094101
btc_blocks_mined,
41104102
u64::try_from(miner_1_tenures + miner_2_tenures).unwrap()

0 commit comments

Comments
 (0)