---
last_verified: 2026-05-30
verified_version: 0.1.48
owner: qa
freshness_days: 30
---

# Testing Patterns

---

## #1 Deterministic crypto test vectors

**Severity**: CRITICAL

### Rule
Every handshake/ratchet step has committed, reproducible test vectors (fixed RNG seeds). Output must match byte-for-byte.

### Correct
```rust
#[test]
fn test_handshake_vector_matches_committed() {
    let out = handshake(seed(KAT_SEED), &alice_kp, &bob_pub);
    assert_eq!(out.transcript_hash, hex!("…committed…"));
}
```
### Verification
```bash
cargo test --test vectors
```

---

## #2 Ratchet survives out-of-order / dropped / reconnect

**Severity**: CRITICAL

### Rule
The #1 correctness target (BUILD_PLAN M1). A session MUST decrypt after reordering, skipped/dropped messages, and a
reconnect — without desync or message loss.

### Correct
```rust
proptest! {
    #[test]
    fn ratchet_handles_reordering(perm in 0..1000u32) {
        let mut a = Session::new(); let mut b = Session::new();
        // send N, deliver in permuted order, assert all decrypt exactly once
    }
}
```
### Verification
```bash
cargo test ratchet_ && cargo test --release proptest
```
