diff --git a/test_conflict_set.py b/test_conflict_set.py index 67a5780..1d97af5 100644 --- a/test_conflict_set.py +++ b/test_conflict_set.py @@ -222,13 +222,18 @@ def test_merge_child_node48(): cs.addWrites(1, write(b"\x00" * 8, b"\x00" * 10)) -def test_fixup_256(): +def test_fixup_256_heterogeneous_versions(): + # Regression test for issue #89: recomputing the maxVersion of a Node256 + # must consider all of its children, not just those with an index < 16. + # Here the highest-version child ("\x10\x50") has an index >= 16, and the + # range write ends at the Node256, which erases that child from the range + # and recomputes the Node256's maxVersion. with DebugConflictSet() as cs: - cs.addWrites(0, write(bytes([1]))) for i in range(256): - cs.addWrites(1, write(bytes([1, i]))) - cs.addWrites(2, write(bytes([0]), bytes([1]))) - cs.check(read(0, bytes([1]), bytes([2]))) + cs.addWrites(1, write(bytes([0x10, i]))) + cs.addWrites(10, write(bytes([0x10, 0x50]))) + cs.addWrites(11, write(bytes([0x05]), bytes([0x10]))) + assert cs.check(read(5, bytes([0x10, 0x50]))) == [Result.CONFLICT] def test_large_removal_buffer():