Skip to content

Commit 8a67be1

Browse files
committed
test(auth): after a prune, signing resumes from the anchor when no checkpoint verifies
1 parent cefd45f commit 8a67be1

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

‎apps/auth-service/src/audit/tests.rs‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,31 @@ async fn pruning_refuses_broken_chains_and_leaves_a_working_anchor() {
472472
assert_eq!(pruned.len(), 2);
473473
}
474474

475+
/// After a prune, a chain none of whose checkpoints verify, as when the key that
476+
/// signed them was removed, is recomputed from the anchor rather than the first
477+
/// position, which pruning deleted, so signing resumes.
478+
#[tokio::test]
479+
#[ignore = "requires TEST_DATABASE_URL"]
480+
async fn signing_resumes_from_the_anchor_when_no_checkpoint_verifies() {
481+
let mut fixture = Fixture::sealed_six().await;
482+
AdminService::new(fixture.database.clone(), false)
483+
.prune_audit_chain(&operator(), &fixture.keys, 3)
484+
.await
485+
.expect("prune");
486+
let key = NoteKey::generate("auth.example/audit").expect("new key");
487+
let audit = AuditConfig::new(&Fixture::origin(), key).expect("audit configuration");
488+
fixture.sealer = Sealer::eager(&audit);
489+
fixture.record(1).await;
490+
fixture.seal().await;
491+
let latest = fixture
492+
.database
493+
.audit()
494+
.newest_checkpoints(None, 1)
495+
.await
496+
.expect("latest");
497+
assert_eq!(latest.first().map(|latest| latest.position), Some(8));
498+
}
499+
475500
/// The dashboard's audit page verifies nothing: it shows the newest verification
476501
/// recorded, so a break shows only once an operator verifies again, and judges each
477502
/// checkpoint by `audit prune`'s rules against that verification. Once pruned, the

0 commit comments

Comments
 (0)