Add a test where the "zero" bug causes an incorrect commit
This commit is contained in:
@@ -56,7 +56,7 @@ def test_conflict_set():
|
|||||||
assert cs.check(read(0, key), read(1, key)) == [Result.TOO_OLD, Result.COMMIT]
|
assert cs.check(read(0, key), read(1, key)) == [Result.TOO_OLD, Result.COMMIT]
|
||||||
|
|
||||||
|
|
||||||
def test_update_zero():
|
def test_update_zero_should_commit():
|
||||||
with DebugConflictSet() as cs1:
|
with DebugConflictSet() as cs1:
|
||||||
with DebugConflictSet() as cs2:
|
with DebugConflictSet() as cs2:
|
||||||
cs1.addWrites(2, write(b""))
|
cs1.addWrites(2, write(b""))
|
||||||
@@ -70,6 +70,20 @@ def test_update_zero():
|
|||||||
cs2.check(read(0, b"\x00", bytes([256 - 17])))
|
cs2.check(read(0, b"\x00", bytes([256 - 17])))
|
||||||
|
|
||||||
|
|
||||||
|
def test_update_zero_should_conflict():
|
||||||
|
with DebugConflictSet() as cs1:
|
||||||
|
with DebugConflictSet() as cs2:
|
||||||
|
cs1.addWrites(2**32)
|
||||||
|
cs1.setOldestVersion(2**32)
|
||||||
|
cs2.addWrites(2**31 + 100)
|
||||||
|
cs2.setOldestVersion(2**31 + 100)
|
||||||
|
# "zero" is now 2**31 + 100
|
||||||
|
cs1.addWrites(2**32 + 101, write(b"", b"\x02"), write(b"\x01"))
|
||||||
|
# rangeVersion of \x01 is now 2**31 + 100 ("max" of (2**31 + 100, 2**32 + 101))
|
||||||
|
cs1.check(read(2**32 + 1, b"\x00"))
|
||||||
|
# but 2**32 + 1 ">" 2**31 + 100 , and it incorrectly commits
|
||||||
|
|
||||||
|
|
||||||
def test_inner_full_words():
|
def test_inner_full_words():
|
||||||
with DebugConflictSet() as cs:
|
with DebugConflictSet() as cs:
|
||||||
cs.addWrites(1, write(b"\x3f\x61"), write(b"\x81\x61"))
|
cs.addWrites(1, write(b"\x3f\x61"), write(b"\x81\x61"))
|
||||||
|
Reference in New Issue
Block a user