aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-17 01:33:05 +0000
committertv <tv@krebsco.de>2026-11-17 02:42:58 +0100
commitd44bcb356053fef3b41110b68c33415fb0583db8 (patch)
treecab733262b5d0d904d06da17877f5c505bde685c
parent012fb7f3d948cd87517424f737f9e0d3c6f71ce5 (diff)
federation: the changes founding a swarm, fixed
The changes founding the swarm of the vectors' first version's root, and those founding the fork whose root is the fork vector's, keeping tv's write, each by its hash and its bytes, as a run of this code printed them: Automerge encodes them, so no script apart computes them. Checked apart so far: each hash the SHA-256 of its change's chunk, each writer the first 16 bytes of its root's ID, the fork's second change built on its first.
-rw-r--r--src/federation/vectors.rs84
1 files changed, 55 insertions, 29 deletions
diff --git a/src/federation/vectors.rs b/src/federation/vectors.rs
index 10ce679..c905547 100644
--- a/src/federation/vectors.rs
+++ b/src/federation/vectors.rs
@@ -146,12 +146,27 @@ fn events_at_federation_1s_sizes_and_just_past_them() {
}
/// The changes founding the swarm of `first`'s root, and those founding the fork whose
-/// root is `FORK_ROOT`, keeping tv's write: printed, each by its hash and its bytes, to be
-/// fixed as vectors (`cargo test --features federation changes_to_fix -- --ignored
-/// --nocapture`). Automerge encodes them, so no script apart computes them.
+/// root is `FORK_ROOT`, keeping tv's write: each its hash and its bytes. Automerge encodes
+/// them, so no script apart computes them; a run of this code printed them, and they were
+/// checked apart only so far: each hash the SHA-256 of its change's chunk, each writer the
+/// first 16 bytes of its root's ID, the fork's second change built on its first.
+const ROOT_FOUNDING: [(&str, &str); 1] = [(
+ "bc51bc12324a4746892758a11f5349ea1d3f674de71229ef7e99c427851b3ca7",
+ "856f4a83bc51bc1201ac060010f65d862fb679df035b4c7bb5debfb69f0101000000080104020b157634014207560b57e90470020001070000017e0102020302017f07780a5f636f6e74696e75756d0661636365737306706f6c6963790573746f72650776657273696f6e05737761726d066576656e7473406636356438363266623637396466303335623463376262356465626662363966356662623839353735666266376631636138376534633530373837393963643408030003017e000103007ba60114860800e74366656465726174696f6e02663635643836326662363739646630333562346337626235646562666236396635666262383935373566626637663163613837653463353037383739396364347b226174223a5b5d2c226b65657073223a5b5d2c2276657273696f6e223a7b226368616e676573223a6e756c6c2c2266656465726174696f6e223a312c226b657973223a7b226c617373223a7b226b657973223a5b227373682d65643235353139204141414143334e7a6143316c5a4449314e54453541414141494945356477366f6652646656714e555a734e4d66737a4c6a597152744f34336f6c33324431755079624f55225d2c2273696e6365223a307d2c227476223a7b226b657973223a5b227373682d65643235353139204141414143334e7a6143316c5a4449314e544535414141414949714934393130436647562f564c624c54793658584c4b5a776d2f485a5153472f4e306941473044323963225d2c2273696e6365223a307d7d2c226e6f646573223a7b226c617373223a7b226e6f646573223a5b5d2c2273696e6365223a307d2c227476223a7b226e6f646573223a5b22636f6e74696e75756d3a65353638376236643131636366623633326162626166653834346638663136393364313630616135383231353665643636656561333861623565376431653132225d2c2273696e6365223a307d7d2c226e756d626572223a302c2272756c6573223a5b7b2270617468223a22686f6d652f7b70617274797d2f2a2a222c22777269746572223a227b70617274797d227d2c7b2270617468223a226e616d65732f722f77696b69222c22777269746572223a226c617373227d5d7d7d0800",
+)];
+const FORK_FOUNDING: [(&str, &str); 2] = [
+ (
+ "bca451324eb8432e7ac1deb1add1e4382208ccdceee356f1f38cc4c58e05edcd",
+ "856f4a83bca4513201ee070010b486c164b5050c555863d9d85f36fc820101000000080104020b157634014207560b57ab0670020001070000017e0102020302017f07780a5f636f6e74696e75756d0661636365737306706f6c6963790573746f72650776657273696f6e05737761726d066576656e7473406234383663313634623530353063353535383633643964383566333666633832663135386465326439643037633961313738353336336630656339343439393108030003017e000103007ba60114860800875c66656465726174696f6e02623438366331363462353035306335353538363364396438356633366663383266313538646532643964303763396131373835333633663065633934343939317b226174223a5b2266633037343166643561356265316433653538303032623731373539316664653530646534323561383435306237323561636133636633336638316564613466225d2c226b65657073223a5b2266633037343166643561356265316433653538303032623731373539316664653530646534323561383435306237323561636133636633336638316564613466225d2c2276657273696f6e223a7b226368616e676573223a2233336262613833646534323963353737643934656566356236623365633233356131626338363934666338333461383637323161643637373730656264343766222c2266656465726174696f6e223a312c226b657973223a7b226c617373223a7b226b657973223a5b227373682d65643235353139204141414143334e7a6143316c5a4449314e54453541414141494945356477366f6652646656714e555a734e4d66737a4c6a597152744f34336f6c33324431755079624f55225d2c2273696e6365223a307d2c227476223a7b226b657973223a5b227373682d65643235353139204141414143334e7a6143316c5a4449314e544535414141414949714934393130436647562f564c624c54793658584c4b5a776d2f485a5153472f4e306941473044323963225d2c2273696e6365223a307d7d2c226e6f646573223a7b226c617373223a7b226e6f646573223a5b5d2c2273696e6365223a307d2c227476223a7b226e6f646573223a5b22636f6e74696e75756d3a65353638376236643131636366623633326162626166653834346638663136393364313630616135383231353665643636656561333861623565376431653132225d2c2273696e6365223a307d7d2c226e756d626572223a312c2272756c6573223a5b7b2270617468223a22686f6d652f7b70617274797d2f2a2a222c22777269746572223a227b70617274797d227d2c7b2270617468223a226e616d65732f722f77696b69222c22777269746572223a226c617373227d5d7d7d0800",
+ ),
+ (
+ "4fec79c30ebc17a011f4340d3f4280992bc84c8b13d8ef2fa5d2c0b6abdb3ceb",
+ "856f4a834fec79c3018a0501bca451324eb8432e7ac1deb1add1e4382208ccdceee356f1f38cc4c58e05edcd10b486c164b5050c555863d9d85f36fc8202090000000801020202154234014202560357f30370027f007f077f4066633037343166643561356265316433653538303032623731373539316664653530646534323561383435306237323561636133636633336638316564613466017f017fb73e7b2264657073223a5b2264636533643865343234343330373933363661636538633038616466336232666138373464393663306364383230373737383434323566373230303965346532225d2c226b6579223a227373682d65643235353139204141414143334e7a6143316c5a4449314e544535414141414949714934393130436647562f564c624c54793658584c4b5a776d2f485a5153472f4e306941473044323963222c227061727479223a227476222c22736967223a2255314e4955306c48414141414151414141444d414141414c63334e6f4c57566b4d6a55314d546b4141414167696f6a6a3358514a385a583955747374504c70646373706e436238646c424962383353494162515062317741414141555932397564476c75645856744c575a6c5a47567959585270623234414141414141414141426e4e6f595455784d67414141464d414141414c63334e6f4c57566b4d6a55314d546b41414142412f765733796c33614d596f785a55516c4d444b576e69392f4c48544e4a617a532f4332346841355532747a636737693435577a4f616866644853596e6e38722b657978636b756856574769695a322f516564775044673d3d222c227772697465223a7b2270617468223a22686f6d652f74762f6c6170746f70222c2276616c7565223a2231302e3234332e372e33227d7d7f00",
+ ),
+];
+
#[test]
-#[ignore]
-fn changes_to_fix() {
+fn the_changes_founding_a_swarm() {
use super::fold::Federation;
use super::store::Fold;
let root = Checkpoint {
@@ -160,28 +175,39 @@ fn changes_to_fix() {
version: Version::read(&first().json()).expect("a version"),
}
.bytes();
- let founding = [
- (
- "root",
- crate::document::events::founding(Federation::NAME, &root, &[]),
- ),
- (
- "fork",
- crate::document::events::founding(
- Federation::NAME,
- FORK_ROOT.as_bytes(),
- &[WRITE.as_bytes().to_vec()],
- ),
- ),
- ];
- for (name, changes) in founding {
- for change in changes {
- let bytes: String = change
- .raw_bytes()
- .iter()
- .map(|byte| format!("{byte:02x}"))
- .collect();
- println!("{name} {} {bytes}", change.hash());
- }
- }
+ let fixed = |changes: Vec<crate::document::Change>| -> Vec<(String, String)> {
+ changes
+ .iter()
+ .map(|change| {
+ let bytes: String = change
+ .raw_bytes()
+ .iter()
+ .map(|byte| format!("{byte:02x}"))
+ .collect();
+ (change.hash().to_string(), bytes)
+ })
+ .collect()
+ };
+ let expected = |vectors: &[(&str, &str)]| -> Vec<(String, String)> {
+ vectors
+ .iter()
+ .map(|(hash, bytes)| ((*hash).to_owned(), (*bytes).to_owned()))
+ .collect()
+ };
+ assert_eq!(
+ fixed(crate::document::events::founding(
+ Federation::NAME,
+ &root,
+ &[]
+ )),
+ expected(&ROOT_FOUNDING)
+ );
+ assert_eq!(
+ fixed(crate::document::events::founding(
+ Federation::NAME,
+ FORK_ROOT.as_bytes(),
+ &[WRITE.as_bytes().to_vec()],
+ )),
+ expected(&FORK_FOUNDING)
+ );
}