diff options
| author | tv <tv@krebsco.de> | 2026-11-24 18:52:02 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-24 18:52:02 +0000 |
| commit | c105463a8f4d080c28f39fa07d170e47e8d1eb8e (patch) | |
| tree | b69ae1fc1ccfd83e05d0ca0727b8d158be3733b2 /src/federation/vote.rs | |
| parent | c386d753054ed38bc4516c945ff8aa315f0e23b9 (diff) | |
store: what heads leave out is what a move to them refuses
left_out, the voters' rule's and a fork's check, took an event for above
the heads where it had them all in its history. A move asks more: each
of its dependencies among the heads or above them (above, beside). So an
event built on the heads and on something beside them passed the rule,
and the move refused it, with all built on it.
A followed key used that: it signs what will be its heads and a proposal
beside them, clients build on both as on every head they hold, and a
checkpoint proposed there later leaves out nothing by the rule, and
refuses every write, key set and node list since.
Now left_out asks what the move asks.
Diffstat (limited to 'src/federation/vote.rs')
| -rw-r--r-- | src/federation/vote.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/federation/vote.rs b/src/federation/vote.rs index 7000b40..a633b0e 100644 --- a/src/federation/vote.rs +++ b/src/federation/vote.rs @@ -520,6 +520,45 @@ mod tests { } } + /// The voters' rule backs no checkpoint whose move refuses what the node held for a + /// while: a write built on the heads and on something beside them, a proposal say, as + /// clients build on every head they hold, has the heads in its history, and the move + /// refuses it all the same. + #[test] + fn a_node_backs_no_checkpoint_that_refuses_what_it_held() { + let (tv, lass, _, first, mut store) = three(); + let root = store.id(); + let head = taken( + &mut store, + tv.write(&[root], "home/tv/a", harness::str("1")), + ); + let mut junk = first.after(first.hash()); + junk.rules.push(("names/x".to_owned(), harness::str("tv"))); + let beside = taken(&mut store, tv.propose(&[root], &junk.json())); + let write = taken( + &mut store, + lass.write(&[head, beside], "home/lass/b", harness::str("2")), + ); + let mut checkpoint = first.after(first.hash()); + checkpoint.checkpoint = Some(vec![head]); + let version = Version::read(&checkpoint.json()).unwrap(); + let rules = Rules { + held_for: Duration::from_secs(60), + ..Rules::default() + }; + let long = |_: &Id| Some(Duration::from_secs(3600)); + let seen = Seen { + store: &store, + held: &long, + since_move: Duration::from_secs(86400), + }; + let current = store.state().current().clone(); + let why = backs_checkpoint(&seen, &rules, ¤t, &version, Duration::ZERO) + .expect_err("its move refuses a write held for a while"); + assert!(why.contains(&write.to_string()), "{why}"); + assert_eq!(store.beside(&[head]), vec![beside, write]); + } + #[test] fn a_node_follows_a_party_on_checkpoints() { let (tv, lass, _, first, mut store) = three(); |
