Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
daejunpark committed Dec 12, 2024
1 parent 51d9977 commit b022fcd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/halmos/sevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,9 +856,9 @@ def __init__(self):
self._mapping = defaultdict(lambda: defaultdict(dict))

def digest(self) -> bytes:
# NOTE: 256-bit size is used, as the first key (slot) can be 256-bit.
m = hashlib.sha3_256()
for keys, val in self._mapping.items():
# NOTE: 256-bit size is used, as the first key (slot) can be 256-bit.
for key in keys:
m.update(int.to_bytes(key, length=32))
m.update(int.to_bytes(val.get_id(), length=32))
Expand All @@ -871,9 +871,9 @@ def __init__(self):
self._mapping = {}

def digest(self) -> bytes:
# NOTE: 256-bit size is used for consistency with SolidityStorageData
m = hashlib.sha3_256()
for key, val in self._mapping.items():
# NOTE: 256-bit size is used for consistency with SolidityStorageData
m.update(int.to_bytes(key, length=32))
m.update(int.to_bytes(val.get_id(), length=32))
return m.digest()
Expand Down
3 changes: 3 additions & 0 deletions tests/regression/test/Snapshot.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ contract SnapshotTest is SymTest, Test {
c = new C();
}

/// @custom:halmos --storage-layout solidity
function check_snapshot() public {
uint storage0 = svm.snapshotStorage(address(c));
uint state0 = vm.snapshotState();
Expand All @@ -45,6 +46,7 @@ contract SnapshotTest is SymTest, Test {
console.log(storage2);
console.log(state2);

// NOTE: failed with the generic storage layout, as the whole storage is an smt array
assertEq(storage1, storage2);
assertEq(state1, state2);

Expand All @@ -65,6 +67,7 @@ contract SnapshotTest is SymTest, Test {
console.log(storage4);
console.log(state4);

// NOTE: failed with the generic storage layout, as the whole storage is an smt array
assertEq(storage2, storage4);
assertEq(state2, state4);
}
Expand Down

0 comments on commit b022fcd

Please sign in to comment.