diff --git a/storage/tests/python/src/consts.py b/storage/tests/python/src/consts.py index a02d6a72fa..39e0a186d2 100644 --- a/storage/tests/python/src/consts.py +++ b/storage/tests/python/src/consts.py @@ -70,7 +70,6 @@ WIPE_CODE_TAG_SIZE = 8 WIPE_CODE_EMPTY = "\0\0\0\0" # Size of counter. 4B integer and 8B tail. -COUNTER_TAIL = 12 COUNTER_TAIL_SIZE = 8 COUNTER_MAX_TAIL = 64 diff --git a/storage/tests/python/src/norcow.py b/storage/tests/python/src/norcow.py index f3c9510d57..f7cbb4ad4d 100644 --- a/storage/tests/python/src/norcow.py +++ b/storage/tests/python/src/norcow.py @@ -22,11 +22,21 @@ class Norcow: for sector in range(consts.NORCOW_SECTOR_COUNT): if self.sectors[sector][:8] == consts.NORCOW_MAGIC_AND_VERSION: self.active_sector = sector - self.active_offset = len(consts.NORCOW_MAGIC_AND_VERSION) + self.active_offset = self.find_free_offset() break else: self.wipe() + def find_free_offset(self): + offset = len(consts.NORCOW_MAGIC_AND_VERSION) + while True: + try: + k, v = self._read_item(offset) + except ValueError: + break + offset = offset + self._norcow_item_length(v) + return offset + def wipe(self, sector: int = None): if sector is None: sector = self.active_sector diff --git a/storage/tests/tests/test_set_get.py b/storage/tests/tests/test_set_get.py index 5fce933641..b2a03b0eb9 100644 --- a/storage/tests/tests/test_set_get.py +++ b/storage/tests/tests/test_set_get.py @@ -165,8 +165,8 @@ def test_set_locked(): assert common.memory_equals(sc, sp) for s in (sc, sp): - s.get(0xC001) == b"Ahoj" - s.get(0xC003) == b"test" + assert s.get(0xC001) == b"Ahoj" + assert s.get(0xC003) == b"test" def test_counter():