def test_states_and_deltas_applied_deltas_early(missing_state): state1, state2, delta3, delta4 = missing_state replica = RGA("id") replica.apply(state2) replica.apply(delta3) replica.apply(state1) replica.apply(delta4) assert replica == ["d", "e", "f", "X", "a", "b", "c", "Y"]
def replicas(): replica1 = RGA("test id 1") replica2 = RGA("test id 2") deltas1 = [] deltas1.append(replica1.append("a")) deltas1.append(replica1.append("b")) deltas2 = [] deltas2.append(replica2.append("c")) deltas2.append(replica2.append("d")) return replica1, replica2, deltas1, deltas2
def rga(): return RGA("test id")
def missing_state(): replica1 = RGA("id1") replica1.append("a") replica1.append("b") replica1.append("c") state1 = replica1.state replica2 = RGA("id2") replica2.append("d") replica2.append("e") replica2.append("f") state2 = replica2.state replica3 = RGA("id3") replica3.apply(state1) replica3.apply(state2) delta3 = replica3.insert(3, "X") delta4 = replica3.append("Y") return state1, state2, delta3, delta4
def test_ids_give_consistent_order(): replica1 = RGA("a") replica2 = RGA("b") delta_a = replica1.append("a") replica2.append("b") replica2.apply(delta_a) assert replica2 == ["b", "a"] replica3 = RGA("d") replica4 = RGA("c") replica3.append("d") delta_d = replica4.append("c") replica3.apply(delta_d) assert replica3 == ["d", "c"]