Skip to content

Commit e92bc6a

Browse files
Haytwpfleger96
andcommitted
test(buzz-relay): add PostgreSQL atomicity witnesses for NIP-FI admission
Adds three #[ignore] PostgreSQL integration tests to the nip_fi::admission pg_integration module that prove the FI-INV-09 all-or-none invariant: pg_nip_fi_rollback_leaves_zero_rows Opens a SERIALIZABLE transaction, writes all nine NIP-FI admission tables (replay claims, operation receipts, identity bindings, lifecycle history, authorization events, admission results, authority epochs, protected object authority), then explicitly rolls back. Asserts zero rows remain in every table — no orphan enrollment, replay, receipt, evidence, or fence rows survive a transaction abort. pg_nip_fi_failed_insert_clears_prior_nip_fi_writes Same setup, but instead of explicit rollback the test triggers a mid-tx PK violation (duplicate proof_event_id). After the aborted transaction is rolled back, asserts zero rows remain. This is the FI-TRACE-FINAL-DENIAL- NO-MUTATION witness: a failure after admission writes does not leave any durable authorization state. pg_nip_fi_successful_commit_persists_all_rows Positive control: commits the same writes and asserts at least one row in every NIP-FI table. Also fixes connection::test_conn_with_auth to include the new nip_fi_assertion / nip_fi_proof_meta fields added in PR 4. Tests require DATABASE_URL or BUZZ_TEST_DATABASE_URL and all migrations. Run: cargo test -p buzz-relay -- --ignored pg_nip_fi --nocapture Co-authored-by: Will Pfleger <[email protected]> Signed-off-by: Will Pfleger <[email protected]>
1 parent 8167cdd commit e92bc6a

2 files changed

Lines changed: 609 additions & 7 deletions

File tree

‎crates/buzz-relay/src/connection.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ pub(crate) mod tests {
755755
cancel: CancellationToken::new(),
756756
backpressure_count: Arc::new(AtomicU8::new(0)),
757757
grace_limit: 3,
758+
nip_fi_assertion: None,
759+
nip_fi_proof_meta: std::sync::OnceLock::new(),
758760
};
759761
(Arc::new(conn), send_rx)
760762
}

0 commit comments

Comments
 (0)