Skip to content

Commit 4d3a200

Browse files
kantaiobycode
andauthored
test: assert block times increasing
Co-authored-by: Brice Dobry <[email protected]>
1 parent 880b345 commit 4d3a200

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

testnet/stacks-node/src/tests/nakamoto_integrations.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,16 +2271,18 @@ fn correct_burn_outs() {
22712271
"Blocks should be sorted by cycle number already"
22722272
);
22732273

2274-
let block_times: Vec<u64> = new_blocks_with_reward_set
2275-
.iter()
2276-
.filter_map(|block| block.get("block_time").and_then(|cn| cn.as_u64()))
2277-
.collect();
2278-
// Assert that block_times are all greater than 0
2279-
assert!(block_times.iter().all(|&t| t > 0));
2280-
2274+
let mut last_block_time = None;
22812275
for block in new_blocks_with_reward_set.iter() {
22822276
let cycle_number = block["cycle_number"].as_u64().unwrap();
22832277
let reward_set = block["reward_set"].as_object().unwrap();
2278+
if let Some(block_time) = block["block_time"].as_u64() {
2279+
if let Some(last) = last_block_time {
2280+
assert!(block_time > last, "Block times should be increasing");
2281+
}
2282+
last_block_time = Some(block_time);
2283+
}
2284+
let cycle_number = block["cycle_number"].as_u64().unwrap();
2285+
let reward_set = block["reward_set"].as_object().unwrap();
22842286

22852287
if cycle_number < first_epoch_3_cycle {
22862288
assert!(

0 commit comments

Comments
 (0)