Skip to content

Commit

Permalink
Use vm.expectRevert("") instead of vm.expectRevert()
Browse files Browse the repository at this point in the history
  • Loading branch information
garyghayrat committed Feb 5, 2024
1 parent de46488 commit fc2a267
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions test/ERC6538Registry.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ contract ERC6538RegistryTest is Test, Deploy {
(uint8 v, bytes32 r, bytes32 s) = vm.sign(_registrantPrivateKey, _hash);
_signature = abi.encodePacked(r, s, v);
}

function _notVmOrConsole(address _address) public pure {
// This function is used to avoid calling the VM or the console, which would return error
// messages. It is used in tests where we want assert a function reverts without a message.
vm.assume(_address != address(vm));
vm.assume(_address != address(address(0x000000000000000000636F6e736F6c652e6c6f67)));
}
}

// Test harness to expose internal contract methods for test purpose only
Expand Down Expand Up @@ -228,10 +235,11 @@ contract RegisterKeysOnBehalf is ERC6538RegistryTest {
) external {
(address notRegistrant, uint256 notRegistrantPrivateKey) = makeAddrAndKey(seed);
vm.assume(notRegistrant != registrant);
_notVmOrConsole(registrant);
bytes memory signature =
_generateRegistrationSignature(notRegistrantPrivateKey, schemeId, stealthMetaAddress, 0);

vm.expectRevert();
vm.expectRevert(bytes(""));
registry.registerKeysOnBehalf(registrant, schemeId, signature, stealthMetaAddress);
}

Expand All @@ -247,7 +255,7 @@ contract RegisterKeysOnBehalf is ERC6538RegistryTest {
bytes memory signature =
_generateRegistrationSignature(registrantPrivateKey, wrongSchemeId, stealthMetaAddress, 0);

vm.expectRevert();
vm.expectRevert(bytes(""));
registry.registerKeysOnBehalf(registrant, schemeId, signature, stealthMetaAddress);
}

Expand All @@ -263,7 +271,7 @@ contract RegisterKeysOnBehalf is ERC6538RegistryTest {
bytes memory signature =
_generateRegistrationSignature(registrantPrivateKey, schemeId, wrongStealthAMetaAddress, 0);

vm.expectRevert();
vm.expectRevert(bytes(""));
registry.registerKeysOnBehalf(registrant, schemeId, signature, stealthMetaAddress);
}

Expand All @@ -278,7 +286,7 @@ contract RegisterKeysOnBehalf is ERC6538RegistryTest {
bytes memory signature =
_generateRegistrationSignature(registrantPrivateKey, schemeId, stealthMetaAddress, nonce);

vm.expectRevert();
vm.expectRevert(bytes(""));
registry.registerKeysOnBehalf(registrant, schemeId, signature, stealthMetaAddress);
}

Expand All @@ -293,7 +301,7 @@ contract RegisterKeysOnBehalf is ERC6538RegistryTest {

registry.registerKeysOnBehalf(registrant, schemeId, signature, stealthMetaAddress);

vm.expectRevert();
vm.expectRevert(bytes(""));
registry.registerKeysOnBehalf(registrant, schemeId, signature, stealthMetaAddress);
}

Expand All @@ -314,7 +322,8 @@ contract RegisterKeysOnBehalf is ERC6538RegistryTest {
uint256 schemeId,
bytes memory stealthMetaAddress
) external {
vm.expectRevert();
_notVmOrConsole(registrant);
vm.expectRevert(bytes(""));
registry.registerKeysOnBehalf(registrant, schemeId, "", stealthMetaAddress);
}
}
Expand Down

0 comments on commit fc2a267

Please sign in to comment.