diff --git a/conflict_set.py b/conflict_set.py index 0cc250c..10c68fa 100644 --- a/conflict_set.py +++ b/conflict_set.py @@ -58,6 +58,9 @@ _lib.ConflictSet_setOldestVersion.argtypes = (ctypes.c_void_p, ctypes.c_int64) _lib.ConflictSet_destroy.argtypes = (ctypes.c_void_p,) +_lib.ConflictSet_getBytes.argtypes = (ctypes.c_void_p,) +_lib.ConflictSet_getBytes.restype = ctypes.c_int64 + class Result(enum.Enum): COMMIT = 0 @@ -106,6 +109,9 @@ class ConflictSet: def setOldestVersion(self, version: int) -> None: _lib.ConflictSet_setOldestVersion(self.p, version) + def getBytes(self) -> int: + return _lib.ConflictSet_getBytes(self.p) + def __enter__(self): return self diff --git a/test_conflict_set.py b/test_conflict_set.py index 7d45336..ef2aa9e 100644 --- a/test_conflict_set.py +++ b/test_conflict_set.py @@ -3,7 +3,10 @@ from conflict_set import * def test_conflict_set(): with ConflictSet() as cs: - cs.addWrites(1, write(b"")) - assert cs.check(read(0, b"")) == [Result.CONFLICT] + before = cs.getBytes() + key = b"a key" + cs.addWrites(1, write(key)) + assert cs.getBytes() - before > 0 + assert cs.check(read(0, key)) == [Result.CONFLICT] cs.setOldestVersion(1) - assert cs.check(read(0, b"")) == [Result.TOO_OLD] + assert cs.check(read(0, key)) == [Result.TOO_OLD]