Moving crdt tests into side-node so we can test serialization with real transactions

This commit is contained in:
Dave Hrycyszyn
2024-06-13 11:35:07 +01:00
parent 481b041554
commit 324aaa109f
2 changed files with 45 additions and 35 deletions

View File

@@ -25,41 +25,6 @@ struct ListExample {
list: ListCrdt<char>,
}
// case 1 - send valid updates
#[test]
fn test_valid_updates() {
// Insert to crdt.doc on local node, test applying the same operation to a remote node
// and check that the view is the same
let key = make_keypair();
let mut crdt = BaseCrdt::<ListExample>::new(&key);
let _a = crdt.doc.list.insert(ROOT_ID, 'a').sign(&key);
let _b = crdt.doc.list.insert(_a.id(), 'b').sign(&key);
let _c = crdt.doc.list.insert(_b.id(), 'c').sign(&key);
assert_eq!(crdt.doc.list.view(), vec!['a', 'b', 'c']);
let key2 = make_keypair();
let mut crdt2 = BaseCrdt::<ListExample>::new(&key2);
crdt2.apply(_a.clone());
crdt2.apply(_b);
crdt2.apply(_c.clone());
assert_eq!(
crdt2.doc.list.view(),
crdt.doc.list.view(),
"views should be equal"
);
crdt2.apply(_a.clone());
crdt2.apply(_a);
assert_eq!(
crdt.doc.list.view(),
crdt2.doc.list.view(),
"views are still equal after repeated applies"
);
}
// case 2a + 2b
#[test]
fn test_equivocation() {