Nearly workign
This commit is contained in:
@@ -25,6 +25,33 @@ 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(_a.clone());
|
||||
crdt2.apply(_b);
|
||||
crdt2.apply(_c);
|
||||
crdt2.apply(_a);
|
||||
let _d = crdt2.doc.list.insert(_d.id(), 'c').sign(&key); // fix this in the morning
|
||||
|
||||
// Ok something is seriously wrong here.
|
||||
assert_eq!(crdt2.doc.list.view(), crdt.doc.list.view());
|
||||
}
|
||||
|
||||
// case 2a + 2b
|
||||
#[test]
|
||||
fn test_equivocation() {
|
||||
|
||||
Reference in New Issue
Block a user