Skip to content

Commit

Permalink
Clearer fuzz test values to skip
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpop committed Nov 22, 2024
1 parent 324ecc8 commit 6b3bfd1
Showing 1 changed file with 36 additions and 22 deletions.
58 changes: 36 additions & 22 deletions test/EncryptionRegistry.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,7 @@ contract EncryptionRegistryTest is AragonTest {
}

function testFuzz_ShouldRegisterMemberPublicKeys(address appointedWallet) public {
if (
appointedWallet == address(0) || appointedWallet == alice || appointedWallet == bob
|| appointedWallet == carol || appointedWallet == david
) return;
else if (Address.isContract(appointedWallet)) return;
else if (Address.isContract(address(uint160(appointedWallet) + 100))) return;
else if (Address.isContract(address(uint160(appointedWallet) + 200))) return;
else if (Address.isContract(address(uint160(appointedWallet) + 300))) return;
if (skipAppointedWallet(appointedWallet)) return;

address addrValue;
bytes32 bytesValue;
Expand Down Expand Up @@ -222,14 +215,7 @@ contract EncryptionRegistryTest is AragonTest {
}

function testFuzz_ShouldClearPublicKeyAfterAppointing(address appointedWallet) public {
if (
appointedWallet == address(0) || appointedWallet == alice || appointedWallet == bob
|| appointedWallet == carol || appointedWallet == david
) return;
else if (Address.isContract(appointedWallet)) return;
else if (Address.isContract(address(uint160(appointedWallet) + 100))) return;
else if (Address.isContract(address(uint160(appointedWallet) + 200))) return;
else if (Address.isContract(address(uint160(appointedWallet) + 300))) return;
if (skipAppointedWallet(appointedWallet)) return;

address addrValue;
bytes32 bytesValue;
Expand Down Expand Up @@ -577,7 +563,7 @@ contract EncryptionRegistryTest is AragonTest {
}

function testFuzz_ShouldRevertOnSetPublicKeyIfNotAppointed(address appointedWallet) public {
if (Address.isContract(appointedWallet) || Address.isContract(address(uint160(appointedWallet) + 100))) return;
if (skipAppointedWallet(appointedWallet)) return;

address addrValue;
bytes32 bytesValue;
Expand Down Expand Up @@ -624,11 +610,7 @@ contract EncryptionRegistryTest is AragonTest {
}

function testFuzz_ShouldRevertOnSetOwnPublicKeyIfOwnerIsAppointing(address appointedWallet) public {
if (
appointedWallet == address(0) || appointedWallet == alice || appointedWallet == bob
|| appointedWallet == carol || appointedWallet == david
) return;
else if (Address.isContract(appointedWallet)) return;
if (skipAppointedWallet(appointedWallet)) return;

address addrValue;
bytes32 bytesValue;
Expand Down Expand Up @@ -861,4 +843,36 @@ contract EncryptionRegistryTest is AragonTest {
function supportsInterface(bytes4) public pure returns (bool) {
return false;
}

// Internal helpers

function skipAppointedWallet(address appointedWallet) internal view returns (bool) {
if (
appointedWallet == address(0) || appointedWallet == alice || appointedWallet == bob
|| appointedWallet == carol || appointedWallet == david || Address.isContract(appointedWallet)
) return true;

appointedWallet = address(uint160(appointedWallet) + 100);

if (
appointedWallet == address(0) || appointedWallet == alice || appointedWallet == bob
|| appointedWallet == carol || appointedWallet == david || Address.isContract(appointedWallet)
) return true;

appointedWallet = address(uint160(appointedWallet) + 100);

if (
appointedWallet == address(0) || appointedWallet == alice || appointedWallet == bob
|| appointedWallet == carol || appointedWallet == david || Address.isContract(appointedWallet)
) return true;

appointedWallet = address(uint160(appointedWallet) + 100);

if (
appointedWallet == address(0) || appointedWallet == alice || appointedWallet == bob
|| appointedWallet == carol || appointedWallet == david || Address.isContract(appointedWallet)
) return true;

return false;
}
}

0 comments on commit 6b3bfd1

Please sign in to comment.