diff options
| author | tv <tv@krebsco.de> | 2026-11-13 03:34:43 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-13 03:34:43 +0000 |
| commit | 519e0a1019b9f74ce8a12773a47d613a05aecdf8 (patch) | |
| tree | db3f1f176af342fe02ca08f62bef0db4143c8a15 /src/document | |
| parent | 52e40764cf4441dfb507efeef5f32644eae94993 (diff) | |
changes: test what transactions never write against a document ready for it
`what_transactions_never_write_is_refused` checked changes built on
the insert against a document without the deletion the insert builds
on. Such a change isn't ready, and nothing is asked of it: the honest
insert passed for that reason, and the two crafted from it weren't
refused. Each is checked now against a document that holds what it
builds on.
Diffstat (limited to 'src/document')
| -rw-r--r-- | src/document/changes.rs | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/document/changes.rs b/src/document/changes.rs index 5569995..1e674dc 100644 --- a/src/document/changes.rs +++ b/src/document/changes.rs @@ -1256,9 +1256,13 @@ mod tests { let delete = theirs.get_last_local_change().unwrap(); change(&mut theirs, |doc| doc.insert(&list, 0, "b").unwrap()); let insert = theirs.get_last_local_change().unwrap(); - for honest in [&delete, &insert] { + // The insert builds on the delete: checked against a document that holds it, + // or it isn't ready, and nothing is asked of it. + let mut with_delete = ours.clone(); + with_delete.apply_changes([delete.clone()]).unwrap(); + for (doc, honest) in [(&ours, &delete), (&with_delete, &insert)] { assert_eq!( - Written::default().check(&ours, honest, &honest.decode()), + Written::default().check(doc, honest, &honest.decode()), None ); } @@ -1273,12 +1277,13 @@ mod tests { let mark_end = crafted(&insert, |change| { change.operations[0].action = OpType::MarkEnd(false); }); - for crafted in [nothing_replaced, at_head, mark_end] { - assert!( - Written::default() - .check(&ours, &crafted, &crafted.decode()) - .is_some() - ); + for (doc, crafted) in [ + (&ours, nothing_replaced), + (&with_delete, at_head), + (&with_delete, mark_end), + ] { + let why = Written::default().check(doc, &crafted, &crafted.decode()); + assert!(why.is_some(), "{:?}", crafted.decode().operations[0]); } } |
