Skip to content

Commit 74efa2c

Browse files
committed
Fix off by one error in mock_sign_epoch_25
Signed-off-by: Jacinta Ferrant <[email protected]>
1 parent df5f6b8 commit 74efa2c

File tree

1 file changed

+24
-18
lines changed
  • testnet/stacks-node/src/tests/signer

1 file changed

+24
-18
lines changed

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

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,8 @@ impl SignerTest<SpawnedSigner> {
175175
.wrapping_add(reward_cycle_len)
176176
.wrapping_add(1);
177177

178-
let next_reward_cycle_boundary = epoch_25_reward_cycle_boundary
179-
.wrapping_add(reward_cycle_len)
180-
.saturating_sub(1);
178+
let next_reward_cycle_boundary =
179+
epoch_25_reward_cycle_boundary.wrapping_add(reward_cycle_len);
181180
run_until_burnchain_height(
182181
&mut self.running_nodes.btc_regtest_controller,
183182
&self.running_nodes.blocks_processed,
@@ -2146,7 +2145,6 @@ fn mock_sign_epoch_25() {
21462145
info!("------------------------- Test Processing Epoch 2.5 Tenures -------------------------");
21472146

21482147
// Mine until epoch 3.0 and ensure that no more mock signatures are received
2149-
21502148
let mut reward_cycle = signer_test.get_current_reward_cycle();
21512149
let mut stackerdb = StackerDB::new(
21522150
&signer_test.running_nodes.conf.node.rpc_bind,
@@ -2163,19 +2161,33 @@ fn mock_sign_epoch_25() {
21632161
assert_eq!(signer_slot_ids.len(), num_signers);
21642162
// Mine until epoch 3.0 and ensure we get a new mock signature per epoch 2.5 sortition
21652163
let main_poll_time = Instant::now();
2166-
let mut current_burn_block_height = signer_test
2164+
while signer_test
21672165
.running_nodes
21682166
.btc_regtest_controller
2169-
.get_headers_height();
2170-
while current_burn_block_height + 1 < epoch_3_start_height {
2171-
current_burn_block_height = signer_test
2167+
.get_headers_height()
2168+
< epoch_3_start_height
2169+
{
2170+
next_block_and(
2171+
&mut signer_test.running_nodes.btc_regtest_controller,
2172+
60,
2173+
|| Ok(true),
2174+
)
2175+
.unwrap();
2176+
let current_burn_block_height = signer_test
21722177
.running_nodes
21732178
.btc_regtest_controller
21742179
.get_headers_height();
2175-
let current_reward_cycle = signer_test.get_current_reward_cycle();
2176-
if current_reward_cycle != reward_cycle {
2177-
debug!("Rolling over reward cycle to {:?}", current_reward_cycle);
2178-
reward_cycle = current_reward_cycle;
2180+
if current_burn_block_height
2181+
% signer_test
2182+
.running_nodes
2183+
.conf
2184+
.get_burnchain()
2185+
.pox_constants
2186+
.reward_cycle_length as u64
2187+
== 0
2188+
{
2189+
reward_cycle += 1;
2190+
debug!("Rolling over reward cycle to {:?}", reward_cycle);
21792191
stackerdb = StackerDB::new(
21802192
&signer_test.running_nodes.conf.node.rpc_bind,
21812193
StacksPrivateKey::new(), // We are just reading so don't care what the key is
@@ -2190,12 +2202,6 @@ fn mock_sign_epoch_25() {
21902202
.collect();
21912203
assert_eq!(signer_slot_ids.len(), num_signers);
21922204
}
2193-
next_block_and(
2194-
&mut signer_test.running_nodes.btc_regtest_controller,
2195-
60,
2196-
|| Ok(true),
2197-
)
2198-
.unwrap();
21992205
let mut mock_signatures = vec![];
22002206
let mock_poll_time = Instant::now();
22012207
debug!("Waiting for mock signatures for burn block height {current_burn_block_height}");

0 commit comments

Comments
 (0)