Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/synapse/blob/main/evidence/b4-revision-states/red-green/b89-red.txt # synapse A component of the AienOS ecosystem. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `synapse / evidence / b4-revision-states / red-green / b89-red.txt` 89 lines ยท 3491 bytes Raw Blame History 1 # Issue #89 red: PR #88 head `cf3879f` plus only the test below (git diff), run with 2 # nice -n 19 cargo test --locked -p synapse-store -j 4 --lib b89_ 3 4 diff --git a/crates/synapse-store/src/revision.rs b/crates/synapse-store/src/revision.rs 5 index `87dd68f`..`73cfb60` 100644 6 --- a/crates/synapse-store/src/revision.rs 7 +++ b/crates/synapse-store/src/revision.rs 8 @@ -995,4 +995,59 @@ mod b4_tests { 9 "kept in the log, applied as no-ops" 10 ); 11 } 12 + 13 + /// Issue #89 red test on the #88 head: a forged owner move (`Private -> Draft` under the 14 + /// owner's chain), written straight into the WAL through the store's own framing (valid 15 + /// CRC32C and hash chain, so a resealed forgery) without the owner's key, must change 16 + /// nothing on replay. 17 + #[test] 18 + fn b89_forged_owner_move_resealed_in_the_wal_changes_nothing_on_replay() { 19 + use crate::{FsyncPolicy, RecoveryPolicy, StoreLimits, SynapseStore}; 20 + let dir = std::env::temp_dir().join(format!("synapse-b89-red-{}", std::process::id())); 21 + let _ = std::fs::remove_dir_all(&dir); 22 + let open = || { 23 + SynapseStore::open( 24 + &dir, 25 + FsyncPolicy::EveryCommit, 26 + RecoveryPolicy::TruncateTornTail, 27 + StoreLimits::default(), 28 + ) 29 + .unwrap() 30 + }; 31 + let mut s = open(); 32 + let mut rng = SplitMix64(0xB89); 33 + let (envelope, owner) = match admission(&mut rng, 1) { 34 + WalRecord::RevisionAdmitted { envelope, chain, .. } => (envelope, chain), 35 + _ => unreachable!(), 36 + }; 37 + let body = 1u32.to_le_bytes(); 38 + let blobs = vec![(BlobDigest::compute(&body), body.to_vec())]; 39 + let id = envelope.changeset_id(); 40 + s.admit_revision( 41 + envelope, 42 + &blobs, 43 + crate::AdmissionAuthority { 44 + chain: owner.clone(), 45 + change_scope: Vec::new(), 46 + }, 47 + 5_000, 48 + ) 49 + .unwrap(); 50 + let forged = WalRecord::RevisionStateMoved { 51 + repo_id: repo(), 52 + changeset_id: id, 53 + to: RevisionState::Draft, 54 + chain: owner, 55 + moved_at_ms: 6_000, 56 + }; 57 + s.append_revision_record(forged, &[]).unwrap(); 58 + drop(s); 59 + let s = open(); 60 + assert_eq!( 61 + s.get_revision(&repo(), id).unwrap().state, 62 + RevisionState::Private, 63 + "a forged, resealed owner move must change nothing on replay" 64 + ); 65 + let _ = std::fs::remove_dir_all(&dir); 66 + } 67 } 68 69 70 running 1 test 71 test revision::b4_tests::b89_forged_owner_move_resealed_in_the_wal_changes_nothing_on_replay ... FAILED 72 73 failures: 74 75 ---- revision::b4_tests::b89_forged_owner_move_resealed_in_the_wal_changes_nothing_on_replay stdout ---- 76 77 thread 'revision::b4_tests::b89_forged_owner_move_resealed_in_the_wal_changes_nothing_on_replay' (571453) panicked at crates/synapse-store/src/revision.rs:1046:9: 78 assertion `left == right` failed: a forged, resealed owner move must change nothing on replay 79 left: Draft 80 right: Private 81 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace 82 83 84 failures: 85 revision::b4_tests::b89_forged_owner_move_resealed_in_the_wal_changes_nothing_on_replay 86 87 test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 55 filtered out; finished in 0.02s 88 89 error: test failed, to rerun pass `-p synapse-store --lib`