diff options
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(); |
