def test_invalid_op(): crdt = CRDT() operation = Operation(ts=datetime.utcnow().timestamp(), key='a', value=1, op=-1) # Append should fail if the operation is invalid try: crdt.append(operation) assert False except AssertionError as e: assert str(e) == INVALID_OP
def test_out_of_order_append(): crdt = CRDT() crdt.add('a', 1) inserted = crdt.log[-1] operation = Operation(ts=inserted.ts - 1, key=inserted.key, value=inserted.value, op=inserted.op) # Append should fail if the timestamp of the operation is earlier than the last inserted operation try: crdt.append(operation) assert False except AssertionError as e: assert str(e) == INVALID_TS