aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md9
-rw-r--r--docs/guides/federation/proposing-and-voting.md38
-rw-r--r--share/bash-completion/completions/continuum-party16
-rw-r--r--src/federation/client.rs65
-rw-r--r--src/federation/party.rs312
5 files changed, 423 insertions, 17 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index de8582e..5a9ba55 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,15 @@ it from the release before ([`docs/operations.md`](docs/operations.md),
## Unreleased
+* Before a vote, `continuum-party` holds the record against the party's votes the node
+ shows, refusing where another record voted, and says what may keep votes away: the
+ party's nodes, or a third of the parties, not heard from lately (`heard` in
+ `GET /events/counts`); it waits a few seconds and asks again before it casts
+ (`--wait`). `restore` takes the party's votes from the node into a record, best effort
+ ([`docs/guides/federation/proposing-and-voting.md`](docs/guides/federation/proposing-and-voting.md),
+ [Voting](docs/guides/federation/proposing-and-voting.md#voting);
+ [`src/federation/party.rs`](src/federation/party.rs)).
+
* `continuum-party get PATH` reads what counts as JSON: a place's value, or what lies
under a path as one object, within places' values too; `-r` a string as it is
([`docs/guides/federation/writing-and-reading.md`](docs/guides/federation/writing-and-reading.md),
diff --git a/docs/guides/federation/proposing-and-voting.md b/docs/guides/federation/proposing-and-voting.md
index b58a926..48ec03c 100644
--- a/docs/guides/federation/proposing-and-voting.md
+++ b/docs/guides/federation/proposing-and-voting.md
@@ -127,7 +127,24 @@ quiet binds the party on this version for good, unless the proposal passes.
A party votes from one client, with one record: two clients backing two proposals at once
is voting twice, and shows ([`federation.md`](../../federation.md),
-[Changing the policy](../../federation.md#changing-the-policy)). A party whose node votes
+[Changing the policy](../../federation.md#changing-the-policy)). Before it casts, the
+client holds the record against the votes of its party the node shows on the current
+version, and says nothing where they agree:
+
+* a vote the node shows that the record lacks refuses the vote: another record votes for
+ the party, or this one was begun anew, and casting beside it may be voting twice;
+ `restore` (below) takes it into the record;
+* a vote the record holds that the node doesn't show yet is said: on its way, or held
+ back where it was put;
+* the party's nodes the node hasn't heard from in five minutes are said, as a vote put
+ through one of them may not have reached it, and so are the parties none of whose nodes
+ it heard from lately, where they are a third of those with nodes or more: a part of the
+ swarm may be cut off, its votes not here (`heard` in `GET /events/counts`).
+
+It then waits five seconds (`--wait SECONDS`, 0 not at all), asks the node again, and
+casts only where nothing came meanwhile: a vote cast elsewhere just before arrives first.
+A vote cast elsewhere at the same moment, or held back by a cut, it can't see: one place
+votes for a party. A party whose node votes
for it by itself votes by hand only through that node, which keeps its one record:
```sh
@@ -135,9 +152,22 @@ continuum-party --node http://tv:secret@localhost:3000 vote 8d02… yes --throug
```
A party that lost its record begins a new one at a node (`continuum-party init`); it
-casts nothing on the current version, and votes again from the next one. A party that
-never voted may begin its record from the root (`init --root`), and casts on every
-version.
+casts nothing on the current version, and votes again from the next one. Or it restores
+one, best effort: `restore` takes the party's votes on the current version, as the node
+holds them, into the record, a new one where there is none (with `--party`), which then
+casts on the current version by them:
+
+```sh
+continuum-party --party tv --record tv.record restore
+# took 1 vote of tv on version 3 into tv.record, as the node holds them; one on its way
+# from elsewhere isn't among them
+```
+
+A vote held back somewhere, or still on its way, isn't among them: restore where the node
+hears from every party's nodes, and give a vote cast before the loss time to arrive. What
+the party signs again after a move (`again`) a restored record doesn't know, nor the nays
+that freed its earlier `true`, which its old record kept. A party that never voted may
+begin its record from the root (`init --root`), and casts on every version.
## Counting support first
diff --git a/share/bash-completion/completions/continuum-party b/share/bash-completion/completions/continuum-party
index 7834536..72c6a6f 100644
--- a/share/bash-completion/completions/continuum-party
+++ b/share/bash-completion/completions/continuum-party
@@ -78,10 +78,10 @@ _continuum_party()
prev=${words[cword - 1]}
fi
- local global_options='--node --token --key --record --federation --config --unset
- --help --version'
- local commands='init write keys nodes next propose vote again found root fork check
- judge proposals show status values get twice help'
+ local global_options='--node --token --key --record --party --federation --config
+ --unset --help --version'
+ local commands='init write keys nodes next propose vote again restore found root fork
+ check judge proposals show status values get twice help'
local intents='admit remove give take keys nodes checkpoint revision'
# The command, the intent of `propose` and `fork`, and the arguments after them that
@@ -93,7 +93,7 @@ _continuum_party()
word=${words[i]}
if [[ -z $command ]]; then
case $word in
- --node | --token | --key | --record | --federation | --config | --unset)
+ --node | --token | --key | --record | --party | --federation | --config | --unset)
_continuum_party_client+=("$word" "${words[i + 1]}")
((i++))
;;
@@ -146,7 +146,7 @@ _continuum_party()
[[ $command == keys ]] && _continuum_party_files
return
;;
- --node | --token | --unset | --nodes | --founder | --rule | --at)
+ --node | --token | --unset | --nodes | --founder | --rule | --at | --wait | --party)
return
;;
esac
@@ -165,7 +165,7 @@ _continuum_party()
propose | fork)
local own
if [[ $command == propose ]]; then
- own='--yes --print'
+ own='--yes --print --wait'
else
own='--at --founder'
fi
@@ -203,7 +203,7 @@ _continuum_party()
;;
vote)
if [[ $cur == -* ]]; then
- _continuum_party_words '--through'
+ _continuum_party_words '--through --wait'
elif ((n == 0)); then
_continuum_party_words "$(_continuum_party_proposals)"
elif ((n == 1)); then
diff --git a/src/federation/client.rs b/src/federation/client.rs
index 846d29c..b95cb3c 100644
--- a/src/federation/client.rs
+++ b/src/federation/client.rs
@@ -264,6 +264,42 @@ impl Record {
.collect()
}
+ /// Its votes on `on`, each by its proposal's hash and whether it is `true`.
+ pub(crate) fn votes_cast(&self, on: &Id) -> Vec<(Id, bool)> {
+ self.votes_on(on)
+ .into_iter()
+ .map(|vote| (vote.proposal, vote.yes))
+ .collect()
+ }
+
+ /// Takes in its party's votes on `current` among `votes`, each as signed, as a node
+ /// holds them, that it lacks (`continuum-party restore`): best effort, as one on its
+ /// way from elsewhere isn't among them. A record begun on `current` casts on it then,
+ /// by them. How many it took.
+ pub(crate) fn restore(&mut self, current: &Version, votes: &[Vec<u8>]) -> usize {
+ let mut taken = 0;
+ for bytes in votes {
+ let Some(vote) = Vote::read(bytes, true) else {
+ continue;
+ };
+ if vote.party != self.party || vote.on != current.hash {
+ continue;
+ }
+ if self
+ .votes
+ .contains(&String::from_utf8_lossy(bytes).into_owned())
+ {
+ continue;
+ }
+ self.cast(current, bytes, Vec::new());
+ taken += 1;
+ }
+ if self.began == current.hash.to_string() {
+ self.began = String::new();
+ }
+ taken
+ }
+
/// Its votes on `on`, as it cast them.
fn votes_on(&self, on: &Id) -> Vec<Vote> {
self.votes
@@ -980,6 +1016,35 @@ mod tests {
assert!(json(&serde_json::json!(1u64 << 60)).is_err());
}
+ /// A record restored from a node's votes takes its party's on the current version that
+ /// it lacks, none of another party's or version, none twice; one begun on the current
+ /// version casts on it then, by them.
+ #[test]
+ fn a_record_restored_from_the_votes_a_node_holds() {
+ let (tv, lass, _, first, current, one, two) = three();
+ let root = Id::of(b"root");
+ let mut record = Record::begin(root, "tv", &current);
+ let mine = tv.vote(&[root], first.hash(), one.hash(), true);
+ let theirs = lass.vote(&[root], first.hash(), one.hash(), true);
+ let elsewhere = tv.vote(&[root], one.hash(), two.hash(), true);
+ let votes = [mine.clone(), theirs, elsewhere, mine];
+ assert_eq!(record.restore(&current, &votes), 1);
+ assert_eq!(record.votes_cast(&current.hash), [(one.hash(), true)]);
+ assert_eq!(record.began, "");
+ assert_eq!(record.restore(&current, &votes), 0);
+ // By what it took: never `false` beside that `true`, nor another `true` beside it.
+ assert!(
+ record
+ .may_vote(&current, one.hash(), &one.json(), false, &[])
+ .is_err()
+ );
+ assert!(
+ record
+ .may_vote(&current, two.hash(), &two.json(), true, &[])
+ .is_err()
+ );
+ }
+
#[test]
fn a_record_votes_one_true_at_a_time_and_never_both() {
let (tv, lass, makefu, first, current, one, two) = three();
diff --git a/src/federation/party.rs b/src/federation/party.rs
index 4902f0f..a1eb6a0 100644
--- a/src/federation/party.rs
+++ b/src/federation/party.rs
@@ -29,6 +29,8 @@
//! version, by the record; with `--through`, through the node that votes for the
//! party by itself and keeps its record, as such a party votes by hand;
//! * `again`: signs again what a move refused;
+//! * `restore`: takes the party's votes on the current version, as the node holds them,
+//! into its record, or a new one (`Record::restore`), best effort;
//! * `twice RECORD...`: names, from the records of parties' clients, a party that voted
//! twice;
//! * `proposals`: the proposals on the current version at the node, each with whether it
@@ -188,9 +190,14 @@ fn command() -> Command {
.long("through")
.action(ArgAction::SetTrue)
.help("Through the node, which votes for the party and keeps its record"),
- ),
+ )
+ .arg(waiting()),
)
.subcommand(Command::new("again").about("Signs again what a move refused"))
+ .subcommand(Command::new("restore").about(
+ "Takes into the party's record, or a new one, its votes on the current version as \
+ the node holds them: best effort, as one on its way from elsewhere isn't among them",
+ ))
.subcommand(
Command::new("found")
.about(
@@ -328,9 +335,24 @@ fn command() -> Command {
)
}
+/// How long a vote waits before it is cast, and asks the node again whether another of
+/// its party's came meanwhile (`vote`).
+fn waiting() -> Arg {
+ Arg::new("wait")
+ .long("wait")
+ .value_name("SECONDS")
+ .default_value("5")
+ .value_parser(clap::value_parser!(u64))
+ .help(
+ "Before casting, waits so long and asks the node again for its party's votes, so \
+ that one cast elsewhere just before arrives first",
+ )
+}
+
/// `propose`'s own options, and each of its subcommands'.
-fn proposing() -> [Arg; 2] {
+fn proposing() -> [Arg; 3] {
[
+ waiting(),
Arg::new("yes")
.long("yes")
.action(ArgAction::SetTrue)
@@ -860,6 +882,9 @@ pub(crate) async fn main() -> Result<()> {
println!("began a record of {party}, of the store {}", record.store);
return Ok(());
}
+ if name == "restore" {
+ return restore(&node, &path, party.as_deref()).await;
+ }
let mut record = Record::load(&path).map_err(|why| anyhow!(why))?;
// The party's key set or node list as it counts, given no change: no key needed.
if matches!(name, "keys" | "nodes") && !sub.contains_id("changes") {
@@ -964,6 +989,7 @@ pub(crate) async fn main() -> Result<()> {
marked(&proposed.hash.to_string(), &proposal_hashes(&counts))
);
if yes {
+ let wait = waited(proposing_flags(sub));
vote(
&node,
&signer,
@@ -972,6 +998,7 @@ pub(crate) async fn main() -> Result<()> {
proposed.hash,
true,
false,
+ wait,
)
.await?;
}
@@ -980,7 +1007,17 @@ pub(crate) async fn main() -> Result<()> {
("vote", sub) => {
let proposal = proposal_named(&node.counts().await?, sub)?;
let yes = sub.get_one::<String>("yes").map(String::as_str) == Some("yes");
- vote(&node, &signer, &mut record, &path, proposal, yes, true).await
+ vote(
+ &node,
+ &signer,
+ &mut record,
+ &path,
+ proposal,
+ yes,
+ true,
+ waited(sub),
+ )
+ .await
}
("again", _) => again(&node, &signer, &mut record, &path).await,
_ => unreachable!("every subcommand handled"),
@@ -1006,6 +1043,11 @@ fn proposal_named(counts: &JsonValue, sub: &ArgMatches) -> Result<Id> {
client::named(given, &hashes, "proposal").map_err(|why| anyhow!(why))
}
+/// `--wait` of `matches`.
+fn waited(matches: &ArgMatches) -> std::time::Duration {
+ std::time::Duration::from_secs(matches.get_one::<u64>("wait").copied().unwrap_or(5))
+}
+
/// The matches of `propose` holding `--yes` and `--print`: its subcommand's, where it has
/// one.
fn proposing_flags(sub: &ArgMatches) -> &ArgMatches {
@@ -1380,8 +1422,12 @@ async fn sign(
node.put(&event).await
}
-/// A vote, by the record: written to it before it is sent. With `ask`, what it votes on is
-/// said first, and asked about on a terminal (`confirmed`); without, that was done.
+/// A vote, by the record: written to it before it is sent. Refused where the node shows a
+/// vote of its party on the current version that the record lacks (`consistent`); what
+/// may keep another from the node said (`cut_off`). With `ask`, what it votes on is said
+/// first, and asked about on a terminal (`confirmed`); without, that was done. It waits
+/// `wait` before it casts, and asks the node again.
+#[allow(clippy::too_many_arguments)]
async fn vote(
node: &Node,
signer: &Signer,
@@ -1390,10 +1436,15 @@ async fn vote(
proposal: Id,
yes: bool,
ask: bool,
+ wait: std::time::Duration,
) -> Result<()> {
let counts = node.counts().await?;
let current = current(&counts)?;
signer.named_by(&current)?;
+ consistent(&counts, &current, record)?;
+ for line in cut_off(&counts, &record.party) {
+ eprintln!("Warning: {line}");
+ }
let ballots = &counts["proposals"];
let ids = |hash: &Id, what: &str| -> Vec<Id> {
ballots[hash.to_string()][what]
@@ -1506,12 +1557,193 @@ async fn vote(
println!("nothing cast");
return Ok(());
}
+ if !wait.is_zero() {
+ tokio::time::sleep(wait).await;
+ let again = node.counts().await?;
+ if self::current(&again)?.hash != current.hash {
+ bail!(
+ "a version passed meanwhile: the proposal lapsed with version {}",
+ current.number
+ );
+ }
+ consistent(&again, &current, record)?;
+ }
let cast = signer.sign(&on, event::vote(current.hash, proposal, yes))?;
record.cast(&current, &cast, kept);
record.save(path).map_err(|why| anyhow!(why))?;
node.put(&cast).await
}
+/// How long ago a node heard from another for it to count as heard from lately (`cut_off`).
+const LATELY: u64 = 5 * 60;
+
+/// Refuses where the node shows a vote of `record`'s party on `current`, by `counts`, that
+/// the record lacks (`unrecorded`): another record votes for the party, or this one was
+/// begun anew. Of the record's votes the node lacks, says that they may be on their way.
+fn consistent(counts: &JsonValue, current: &Version, record: &Record) -> Result<()> {
+ let party = &record.party;
+ let (theirs, ours) = unrecorded(counts, current, record);
+ if !theirs.is_empty() {
+ bail!(
+ "the node shows votes of {party} on version {} that this record lacks: {}. Another \
+ record votes for {party}, or this one was begun anew: casting beside them may be \
+ voting twice. `continuum-party restore` takes them into this record; then vote",
+ current.number,
+ theirs.join(", ")
+ );
+ }
+ if !ours.is_empty() {
+ eprintln!(
+ "Note: the node doesn't show this record's {} yet: on their way, or held back where \
+ they were put",
+ ours.join(", ")
+ );
+ }
+ Ok(())
+}
+
+/// How the party's votes on `current` that `counts` shows differ from `record`'s: those the
+/// node shows that the record lacks, and those the record holds that the node doesn't show;
+/// each as `true on 8d02…`.
+fn unrecorded(
+ counts: &JsonValue,
+ current: &Version,
+ record: &Record,
+) -> (Vec<String>, Vec<String>) {
+ let party = record.party.as_str();
+ let short = |hash: &str| format!("{}…", hash.get(..12).unwrap_or(hash));
+ let mut shown = Vec::new();
+ for (hash, ballot) in counts["proposals"].as_object().into_iter().flatten() {
+ for (what, yes) in [("yes", true), ("no", false)] {
+ let voted = ballot[what]
+ .as_array()
+ .is_some_and(|parties| parties.iter().any(|of| of.as_str() == Some(party)));
+ if voted {
+ shown.push((hash.clone(), yes));
+ }
+ }
+ }
+ let held: Vec<(String, bool)> = record
+ .votes_cast(&current.hash)
+ .into_iter()
+ .map(|(proposal, yes)| (proposal.to_string(), yes))
+ .collect();
+ let spelled = |(hash, yes): &(String, bool)| format!("`{yes}` on {}", short(hash));
+ (
+ shown
+ .iter()
+ .filter(|vote| !held.contains(vote))
+ .map(spelled)
+ .collect(),
+ held.iter()
+ .filter(|vote| !shown.contains(vote))
+ .map(spelled)
+ .collect(),
+ )
+}
+
+/// What may keep a vote of `party`'s from the node, by `counts`: the party's nodes the node
+/// didn't hear from within `LATELY`, through which another of its votes may have gone; and,
+/// where those are a third of the parties with nodes or more, the parties none of whose
+/// nodes it heard from within it, which a part of the swarm cut off would be. A line each.
+fn cut_off(counts: &JsonValue, party: &str) -> Vec<String> {
+ let parties = counts["parties"].as_object();
+ let quiet = |of: &JsonValue| -> Vec<String> {
+ let names = &of["names"];
+ of["nodes"]
+ .as_array()
+ .into_iter()
+ .flatten()
+ .filter_map(JsonValue::as_str)
+ .filter(|node| of["heard"][*node].as_u64().is_none_or(|ago| ago > LATELY))
+ .map(|node| match names[node].as_str() {
+ Some(name) => format!("{node} ({name})"),
+ None => node.to_owned(),
+ })
+ .collect()
+ };
+ let mut lines = Vec::new();
+ if let Some(own) = parties.and_then(|parties| parties.get(party)) {
+ let quiet = quiet(own);
+ if !quiet.is_empty() {
+ lines.push(format!(
+ "the node hasn't heard from these nodes of {party} lately: {}: a vote of \
+ {party} put through one of them may not have reached it",
+ quiet.join(", ")
+ ));
+ }
+ }
+ let with_nodes: Vec<(&String, &JsonValue)> = parties
+ .into_iter()
+ .flatten()
+ .filter(|(_, of)| {
+ of["nodes"]
+ .as_array()
+ .is_some_and(|nodes| !nodes.is_empty())
+ })
+ .collect();
+ let unheard: Vec<&str> = with_nodes
+ .iter()
+ .filter(|(_, of)| quiet(of).len() == of["nodes"].as_array().map_or(0, Vec::len))
+ .map(|(name, _)| name.as_str())
+ .collect();
+ if !unheard.is_empty() && 3 * unheard.len() >= with_nodes.len() {
+ lines.push(format!(
+ "the node hasn't heard from any node of {} lately: a part of the swarm may be cut \
+ off, and its votes not here",
+ unheard.join(", ")
+ ));
+ }
+ lines
+}
+
+/// Takes into the record at `path`, or a new one of `party`, the party's votes on the current
+/// version as the node holds them (`Record::restore`): best effort, as one on its way from
+/// elsewhere isn't among them. What it signs anew after a move (`again`) it doesn't learn.
+async fn restore(node: &Node, path: &Path, party: Option<&str>) -> Result<()> {
+ let (store, _) = node.summary().await?;
+ let counts = node.counts().await?;
+ let current = current(&counts)?;
+ let mut record = if path.exists() {
+ Record::load(path).map_err(|why| anyhow!(why))?
+ } else {
+ let party = party.context("no record, and no --party saying whose votes to take")?;
+ Record::before(store, party)
+ };
+ if record.store != store.to_string() {
+ bail!("{} is a record of another store", path.display());
+ }
+ let began_here = record.began == current.hash.to_string();
+ let mut votes = Vec::new();
+ for hash in proposal_hashes(&counts) {
+ for id in counts["proposals"][&hash]["votes"]
+ .as_array()
+ .into_iter()
+ .flatten()
+ .filter_map(|id| id.as_str().and_then(Id::from_hex))
+ {
+ votes.push(node.event(&id).await?);
+ }
+ }
+ let taken = record.restore(&current, &votes);
+ record.save(path).map_err(|why| anyhow!(why))?;
+ println!(
+ "took {taken} vote{} of {} on version {} into {}, as the node holds them; one on its \
+ way from elsewhere isn't among them",
+ if taken == 1 { "" } else { "s" },
+ record.party,
+ current.number,
+ path.display()
+ );
+ if began_here {
+ println!("it casts on version {} now, by them", current.number);
+ }
+ for line in cut_off(&counts, &record.party) {
+ eprintln!("Warning: {line}");
+ }
+ Ok(())
+}
+
/// Warns of the nodes not known to know `revision`, by `counts` (`client::unready`).
fn warn_unready(counts: &JsonValue, revision: Revision) {
let behind = client::unready(counts, revision);
@@ -3057,6 +3289,76 @@ mod tests {
assert_eq!(get("").unwrap()["home"]["tvx"]["motd"], "beside");
}
+ /// Before a vote, the party's votes the node shows are held against the record's: one
+ /// the node shows that the record lacks refuses the vote, one the record holds that
+ /// the node doesn't show is said; nothing where they agree.
+ #[test]
+ fn a_record_held_against_the_votes_a_node_shows() {
+ use crate::federation::client::Record;
+ use crate::federation::harness::{Party, Spec};
+ use crate::federation::store::Id;
+ use crate::federation::version::Version;
+ let (tv, lass) = (Party::new("tv", 1), Party::new("lass", 2));
+ let first = Spec::first(&[&tv, &lass], &[]);
+ let current = Version::read(&first.json()).unwrap();
+ let (one, two) = (Id::of(b"one"), Id::of(b"two"));
+ let mut record = Record::before(Id::of(b"root"), "tv");
+ record.cast(
+ &current,
+ &tv.vote(&[Id::of(b"root")], first.hash(), one, true),
+ Vec::new(),
+ );
+ let counts = |yes_one: &[&str], no_two: &[&str]| {
+ serde_json::json!({"proposals": {
+ one.to_string(): {"yes": yes_one, "no": []},
+ two.to_string(): {"yes": [], "no": no_two},
+ }})
+ };
+ let agreeing = counts(&["tv", "lass"], &[]);
+ assert_eq!(
+ super::unrecorded(&agreeing, &current, &record),
+ (Vec::new(), Vec::new())
+ );
+ assert!(super::consistent(&agreeing, &current, &record).is_ok());
+ let elsewhere = counts(&["tv"], &["tv"]);
+ let (theirs, ours) = super::unrecorded(&elsewhere, &current, &record);
+ assert_eq!(theirs.len(), 1);
+ assert!(theirs[0].starts_with("`false` on "), "{theirs:?}");
+ assert!(ours.is_empty());
+ assert!(super::consistent(&elsewhere, &current, &record).is_err());
+ let behind = counts(&["lass"], &[]);
+ let (theirs, ours) = super::unrecorded(&behind, &current, &record);
+ assert!(theirs.is_empty());
+ assert_eq!(ours.len(), 1);
+ assert!(super::consistent(&behind, &current, &record).is_ok());
+ }
+
+ /// What may keep a vote from the node: the party's own nodes not heard from lately;
+ /// and parties none of whose nodes were, where they are a third of those with nodes.
+ #[test]
+ fn nodes_cut_off_are_said() {
+ let ago = super::LATELY + 1;
+ let counts = |lass_heard: Option<u64>| {
+ let lass = match lass_heard {
+ Some(ago) => serde_json::json!({"n3": ago}),
+ None => serde_json::json!({}),
+ };
+ serde_json::json!({"parties": {
+ "tv": {"nodes": ["n1", "n2"], "names": {"n2": "beta"}, "heard": {"n1": 0, "n2": ago}},
+ "lass": {"nodes": ["n3"], "names": {}, "heard": lass},
+ "makefu": {"nodes": ["n4"], "names": {}, "heard": {"n4": 3}},
+ "krebs": {"nodes": [], "names": {}, "heard": {}},
+ }})
+ };
+ let lines = super::cut_off(&counts(Some(10)), "tv");
+ assert_eq!(lines.len(), 1);
+ assert!(lines[0].contains("n2 (beta)"), "{lines:?}");
+ let lines = super::cut_off(&counts(None), "makefu");
+ assert_eq!(lines.len(), 1);
+ assert!(lines[0].contains("any node of lass"), "{lines:?}");
+ assert!(super::cut_off(&counts(Some(10)), "makefu").is_empty());
+ }
+
/// `values` shows a place and those under it, not those beside it.
#[test]
fn places_under_a_path() {