Skip to content

Commit 876a19b

Browse files
fix: guard against vacuous capacity-pool assertions in expiry tests
Add partition counters to all capacity-pool assertion loops so they fail if no partitions were actually checked. Prevents silent passes if slot.partitions is ever empty after expiry.
1 parent d6cc4e6 commit 876a19b

File tree

1 file changed

+30
-3
lines changed
  • crates/chain-tests/src/perm_ledger_expiry

1 file changed

+30
-3
lines changed

crates/chain-tests/src/perm_ledger_expiry/mod.rs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ async fn heavy_perm_ledger_expiry_basic() -> eyre::Result<()> {
149149

150150
// --- Assertion 3: Expired partitions returned to capacity pool ---
151151
let partition_assignments = &epoch_snapshot.partition_assignments;
152+
let mut checked_partitions = 0_usize;
152153
for (slot_index, slot) in perm_slots.iter().enumerate() {
153154
if slot_index < num_slots - 1 && slot.is_expired {
154155
for partition_hash in &slot.partitions {
@@ -167,10 +168,18 @@ async fn heavy_perm_ledger_expiry_basic() -> eyre::Result<()> {
167168
slot_index,
168169
assignment.ledger_id
169170
);
171+
checked_partitions += 1;
170172
}
171173
}
172174
}
173-
info!("Verified expired perm partitions are in capacity pool");
175+
assert!(
176+
checked_partitions > 0,
177+
"Expected to verify at least one expired partition, but none were found"
178+
);
179+
info!(
180+
"Verified {} expired perm partitions are in capacity pool",
181+
checked_partitions
182+
);
174183

175184
// --- Assertion 4: User balance unchanged after perm expiry ---
176185
let post_expiry_block = node.get_block_by_height(final_height).await?;
@@ -361,6 +370,7 @@ async fn heavy_perm_and_term_expiry_same_epoch() -> eyre::Result<()> {
361370

362371
// --- Assertion 4: All expired Submit partitions returned to capacity pool ---
363372
let partition_assignments = &epoch_snapshot.partition_assignments;
373+
let mut checked_submit_partitions = 0_usize;
364374
for (slot_index, slot) in submit_slots.iter().enumerate() {
365375
if slot.is_expired {
366376
for partition_hash in &slot.partitions {
@@ -377,12 +387,21 @@ async fn heavy_perm_and_term_expiry_same_epoch() -> eyre::Result<()> {
377387
"Expired submit partition {:?} at slot {} should be in capacity pool but has ledger_id={:?}",
378388
partition_hash, slot_index, assignment.ledger_id
379389
);
390+
checked_submit_partitions += 1;
380391
}
381392
}
382393
}
383-
info!("Verified expired submit partitions are in capacity pool");
394+
assert!(
395+
checked_submit_partitions > 0,
396+
"Expected to verify at least one expired submit partition, but none were found"
397+
);
398+
info!(
399+
"Verified {} expired submit partitions are in capacity pool",
400+
checked_submit_partitions
401+
);
384402

385403
// --- Assertion 5: All expired non-last Publish partitions returned to capacity pool ---
404+
let mut checked_perm_partitions = 0_usize;
386405
for (slot_index, slot) in perm_slots.iter().enumerate() {
387406
if slot_index < perm_num - 1 && slot.is_expired {
388407
for partition_hash in &slot.partitions {
@@ -399,10 +418,18 @@ async fn heavy_perm_and_term_expiry_same_epoch() -> eyre::Result<()> {
399418
"Expired perm partition {:?} at slot {} should be in capacity pool but has ledger_id={:?}",
400419
partition_hash, slot_index, assignment.ledger_id
401420
);
421+
checked_perm_partitions += 1;
402422
}
403423
}
404424
}
405-
info!("Verified expired perm partitions are in capacity pool");
425+
assert!(
426+
checked_perm_partitions > 0,
427+
"Expected to verify at least one expired perm partition, but none were found"
428+
);
429+
info!(
430+
"Verified {} expired perm partitions are in capacity pool",
431+
checked_perm_partitions
432+
);
406433

407434
info!("Simultaneous perm+term expiry test passed!");
408435
node.stop().await;

0 commit comments

Comments
 (0)