Skip to content

Commit

Permalink
ethereum: fix some intermittently failing tests
Browse files Browse the repository at this point in the history
Fix the assumptions to match the storage layout correctly.
  • Loading branch information
SEJeff committed Sep 11, 2023
1 parent 049ca97 commit d9aacf1
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions ethereum/forge-test/Governance.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -506,12 +506,19 @@ contract TestGovernance is TestUtils {
unchangedStorage(address(proxied), storageSlot)
{
vm.assume(storageSlot != hashedLocationOffset(0, GUARDIANSETS_SLOT, 1));
vm.assume(storageSlot != hashedLocationOffset(0, GUARDIANSETS_SLOT, 0));

// New GuardianSet array length should be initialized from zero to non-zero
vm.assume(storageSlot != hashedLocationOffset(1, GUARDIANSETS_SLOT, 0));

vm.assume(storageSlot != GUARDIANSETINDEX_SLOT);
vm.assume(0 < newGuardianSet.length);
vm.assume(newGuardianSet.length < 20);
for(uint8 i = 0; i < newGuardianSet.length; i++)

for(uint8 i = 0; i < newGuardianSet.length; i++) {
vm.assume(newGuardianSet[i] != address(0));
// New GuardianSet key array elements should be initialized from zero to non-zero
vm.assume(storageSlot != bytes32(uint256(keccak256(abi.encodePacked(hashedLocationOffset(1, GUARDIANSETS_SLOT, 0)))) + i));
}

vm.chainId(EVMCHAINID);

Expand Down Expand Up @@ -751,12 +758,20 @@ contract TestGovernance is TestUtils {
unchangedStorage(address(proxied), storageSlot)
{
vm.assume(storageSlot != hashedLocationOffset(0, GUARDIANSETS_SLOT, 1));
vm.assume(storageSlot != hashedLocationOffset(0, GUARDIANSETS_SLOT, 0));

// New GuardianSet array length should be initialized from zero to non-zero
vm.assume(storageSlot != hashedLocationOffset(1, GUARDIANSETS_SLOT, 0));

vm.assume(storageSlot != GUARDIANSETINDEX_SLOT);
vm.assume(0 < newGuardianSet.length);
vm.assume(newGuardianSet.length < 20);
for(uint8 i = 0; i < newGuardianSet.length; i++)

for(uint8 i = 0; i < newGuardianSet.length; i++) {
vm.assume(newGuardianSet[i] != address(0));
// New GuardianSet key array elements should be initialized from zero to non-zero
vm.assume(storageSlot != bytes32(uint256(keccak256(abi.encodePacked(hashedLocationOffset(1, GUARDIANSETS_SLOT, 0)))) + i));
}

vm.chainId(EVMCHAINID);

bytes memory payload = payloadSubmitNewGuardianSet(MODULE, CHAINID, 1, newGuardianSet);
Expand Down

0 comments on commit d9aacf1

Please sign in to comment.