Skip to content

Commit

Permalink
🚨 solve linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
qd-qd committed Apr 2, 2024
1 parent 67d106d commit 4c84455
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 31 deletions.
4 changes: 2 additions & 2 deletions test/integration/SignerVault/signerVault.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ contract SignerVault is BaseTest {
implementation = new SignerVaultTestWrapper();
}

function test_AllHaveDifferentRootSlots() external {
function test_AllHaveDifferentRootSlots() external view {
// it should all have different root slot

assertNotEq(implementation.webAuthnP256R1Root(), implementation.vanillaP256K1Root());
}

function test_AllDerivateToADifferentAddressGivenTheSameKey(bytes32 clientIdHash, address signer) external {
function test_AllDerivateToADifferentAddressGivenTheSameKey(bytes32 clientIdHash, address signer) external view {
// it should all derivate to a different address given the same key

vm.assume(clientIdHash != keccak256(""));
Expand Down
9 changes: 5 additions & 4 deletions test/unit/utils/Signature.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ import { MessageHashUtils } from "@openzeppelin/utils/cryptography/MessageHashUt
import { VmSafe } from "forge-std/Vm.sol";

contract Signature_Test is BaseTest {
function test_Return0ForASuccessfulSignatureVerification() external {
function test_Return0ForASuccessfulSignatureVerification() external pure {
// it return 0 for a successful signature verification as specificied in the EIP-4337
assertEq(Signature.State.SUCCESS, 0);
}

function test_Return1ForAFailedSignatureVerification() external {
function test_Return1ForAFailedSignatureVerification() external pure {
// it return 1 for a failed signature verification as specificied in the EIP-4337
assertEq(Signature.State.FAILURE, 1);
}

function test_Return0ForACreationSignature() external {
function test_Return0ForACreationSignature() external pure {
// it return 0 for a creation signature. This must never change!
assertEq(Signature.Type.CREATION, bytes1(0x00));
}

function test_Return1ForAWebauthnP256r1Signature() external {
function test_Return1ForAWebauthnP256r1Signature() external pure {
// it return 1 for a webauthn p256r1 signature. This must never change!
assertEq(Signature.Type.WEBAUTHN_P256R1, bytes1(0x01));
}
Expand Down Expand Up @@ -57,6 +57,7 @@ contract Signature_Test is BaseTest {
bytes calldata signature
)
external
pure
{
// it return false if the signature is incorrectly recovered
assertEq(Signature.recover(expectedSigner, message, signature), false);
Expand Down
6 changes: 3 additions & 3 deletions test/unit/utils/SignerVault/signerVaultVanillaK1.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ contract SignerVault__VanillaP256K1 is BaseTest {
assertEq(signerStored, signer);
}

function test_DoesNotStoreTwoSignersToTheSameStorageSlots(address signer1, address signer2) external {
function test_DoesNotStoreTwoSignersToTheSameStorageSlots(address signer1, address signer2) external view {
// it should not store two signers to the same storage slots

signer1 = boundNoPrecompute(signer1);
Expand Down Expand Up @@ -82,7 +82,7 @@ contract SignerVault__VanillaP256K1 is BaseTest {
assertTrue(implementation.has(signer));
}

function test_ReturnFalseIfNoSignerExistsGivenTheOwnerAddress(address signer) external {
function test_ReturnFalseIfNoSignerExistsGivenTheOwnerAddress(address signer) external view {
// it should return false if no signer exists given the owner address

signer = boundNoPrecompute(signer);
Expand All @@ -109,7 +109,7 @@ contract SignerVault__VanillaP256K1 is BaseTest {
assertFalse(implementation.has(signer));
}

function test_AlwaysUseTheSameRoot() external {
function test_AlwaysUseTheSameRoot() external view {
// it should always use the same root

assertEq(implementation.root(), 0x4af245f3834b267909e0839a9d1bd5a4d800d78cbc580638b0487080d20b0900);
Expand Down
16 changes: 11 additions & 5 deletions test/unit/utils/SignerVault/signerVaultWebAuthnP256R1.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,13 @@ contract SignerVault__WebAuthnP256R1 is BaseTest {
assertEq(loadSSxU(startingSlot, SIGNER.PUBKEY_Y), pubkeyY);
}

function test_DoesNotStoreTwoSignersToTheSameStorageSlots(bytes32 clientIdHash1, bytes32 clientIdHash2) external {
function test_DoesNotStoreTwoSignersToTheSameStorageSlots(
bytes32 clientIdHash1,
bytes32 clientIdHash2
)
external
view
{
// it should not store two signers to the same storage slots

// bound the fuzzed arguments to have coherent values
Expand Down Expand Up @@ -167,7 +173,7 @@ contract SignerVault__WebAuthnP256R1 is BaseTest {
assertEq(pubYStored, pubkeyY);
}

function test_ReturnAnEmptySignerIfNotFoundGivenAClientId(bytes calldata clientId) external {
function test_ReturnAnEmptySignerIfNotFoundGivenAClientId(bytes calldata clientId) external view {
// it should return an empty signer if not found given a client id

// retrieve the signer for the given client id
Expand Down Expand Up @@ -206,7 +212,7 @@ contract SignerVault__WebAuthnP256R1 is BaseTest {
assertTrue(implementation.exposed_has(clientIdHash));
}

function test_ReturnFalseIfNoSignerExistsGivenAClientIdHash(bytes32 clientIdHash) external {
function test_ReturnFalseIfNoSignerExistsGivenAClientIdHash(bytes32 clientIdHash) external view {
// it should return false if no signer exists given a client id hash

// ensure the signer exists
Expand All @@ -233,7 +239,7 @@ contract SignerVault__WebAuthnP256R1 is BaseTest {
assertTrue(implementation.exposed_has(clientId));
}

function test_ReturnFalseIfNoSignerExistsGivenAClientId(bytes calldata clientId) external {
function test_ReturnFalseIfNoSignerExistsGivenAClientId(bytes calldata clientId) external view {
// it should return false if no signer exists given a client id

// ensure the signer exists
Expand Down Expand Up @@ -412,7 +418,7 @@ contract SignerVault__WebAuthnP256R1 is BaseTest {
}

/// @dev The root value must never change. Never.
function test_AlwaysUseTheSameRoot() external {
function test_AlwaysUseTheSameRoot() external view {
// it should always use the same root

assertEq(implementation.exposed_root(), 0x766490bc3db2290d3ce2c7c2b394a53399f99517ba4974536d11869c06dc8900);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/v1/Account/getNonce.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract SmartAccount__GetNonce is BaseTest {
assertEq(acc.getNonce(), 1);
}

function test_Return0ForInactiveAccount() external {
function test_Return0ForInactiveAccount() external view {
// it return 0 for a never used account

assertEq(acc.getNonce(), 0);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/v1/Account/removeWebAuthnP256R1Signer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ contract SmartAccount__RemoveWebAuthnP256R1Signer is BaseTest {
assertEq(storedPubkeyY, 0);
}

function test_DoNotCheckIfTheSignerExists() external {
function test_DoNotCheckIfTheSignerExists() external view {
// it do not check if the signer exists

// 1. we remove an unset signer -- it should not revert
Expand Down
6 changes: 3 additions & 3 deletions test/unit/v1/Account/validateCreationSignature.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ contract SmartAccount__ValidateCreationSignature is BaseTest {
account.exposed_validateCreationSignature(signature, invalidInitCode);
}

function test_FailsIfTheUseropFactoryIsNotCorrect(address incorrectFactory) external {
function test_FailsIfTheUseropFactoryIsNotCorrect(address incorrectFactory) external view {
// it fails if the userop factory is not correct

vm.assume(incorrectFactory != address(factory));
Expand Down Expand Up @@ -142,7 +142,7 @@ contract SmartAccount__ValidateCreationSignature is BaseTest {
assertEq(account.exposed_validateCreationSignature(invalidSignature, initCode), Signature.State.FAILURE);
}

function test_FailsIfSignatureTypeMissing() external {
function test_FailsIfSignatureTypeMissing() external view {
// it fails if the passed signature is not correct

// 1. get valid initcode and signature
Expand Down Expand Up @@ -211,7 +211,7 @@ contract SmartAccount__ValidateCreationSignature is BaseTest {
assertEq(account.exposed_validateCreationSignature(signature, initCode), Signature.State.FAILURE);
}

function test_SucceedIfTheSignatureRecoveryIsCorrect() external {
function test_SucceedIfTheSignatureRecoveryIsCorrect() external view {
// it succeed if the signature recovery is correct

// 1. get valid initcode and signature
Expand Down
2 changes: 1 addition & 1 deletion test/unit/v1/Account/versionning.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ contract SmartAccount__Versionning is BaseTest {
account = new SmartAccount(makeAddr("entrypoint"), makeAddr("verifier"));
}

function test_AllowVersionFetching() external {
function test_AllowVersionFetching() external view {
// it allow version fetching

assertEq(account.version(), Metadata.VERSION);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/v1/AccountFactory/getAddress.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ contract AccountFactory__GetAddress is BaseTest {
return (credId, credIdHash, pubX, pubY);
}

function test_CalculateSameAddressUsingBothMethods() external {
function test_CalculateSameAddressUsingBothMethods() external view {
// it calculate same address using both methods

// 1. extract the signer from the authenticatorData
Expand Down
10 changes: 5 additions & 5 deletions test/unit/v1/AccountFactory/nameServiceSignatureRecovery.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ contract AccountFactory__RecoverNameServiceSignature is BaseTest {
);
}

function test_ReturnTrueIfTheSignatureIsValid() external {
function test_ReturnTrueIfTheSignatureIsValid() external view {
// it return true if the signature is valid

// 1. calculate the future address of the account
Expand Down Expand Up @@ -43,7 +43,7 @@ contract AccountFactory__RecoverNameServiceSignature is BaseTest {
assertFalse(factory.exposed_isSignatureLegit(accountAddress, createFixtures.response.authData, signature));
}

function test_ReturnFalseIfNotTheCorrectAuthData(bytes calldata fakeAuthData) external {
function test_ReturnFalseIfNotTheCorrectAuthData(bytes calldata fakeAuthData) external view {
// it return false if not the correct pubKey

// 1. calculate the future address of the account
Expand All @@ -55,7 +55,7 @@ contract AccountFactory__RecoverNameServiceSignature is BaseTest {
assertFalse(factory.exposed_isSignatureLegit(accountAddress, fakeAuthData, signature));
}

function test_ReturnFalseIfNotTheCorrectAccountAddress(address incorrectAddr) external {
function test_ReturnFalseIfNotTheCorrectAccountAddress(address incorrectAddr) external view {
// it return false if not the correct AccountAddress

// 1. make sure the fuzzed address is not correct
Expand All @@ -68,7 +68,7 @@ contract AccountFactory__RecoverNameServiceSignature is BaseTest {
assertFalse(factory.exposed_isSignatureLegit(incorrectAddr, createFixtures.response.authData, signature));
}

function test_ReturnFalseIfNotTheCorrectSignature(bytes32 hash) external {
function test_ReturnFalseIfNotTheCorrectSignature(bytes32 hash) external view {
// it return false if not the correct signature

// 1. calculate the future address of the account
Expand All @@ -81,7 +81,7 @@ contract AccountFactory__RecoverNameServiceSignature is BaseTest {
);
}

function test_ReturnFalseIfNotTheCorrectSignatureLength(bytes32 r, bytes32 s) external {
function test_ReturnFalseIfNotTheCorrectSignatureLength(bytes32 r, bytes32 s) external view {
// it return false if not the correct signature length

// NOTE: A valid ecdsa signature is 65 bytes long. We add a 1 byte type to it meaning
Expand Down
2 changes: 1 addition & 1 deletion test/unit/v1/AccountFactory/ownership.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ contract AccountFactory__Ownership is BaseTest {
factory = deployFactoryInstance(factoryImplementation, makeAddr("proxy_owner"), owner);
}

function test_ReturnTheOwner() external {
function test_ReturnTheOwner() external view {
// it return the owner

assertEq(factory.owner(), owner);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/v1/AccountFactory/versionning.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ contract AccountFactory__Versionning is BaseTest {
);
}

function test_AllowVersionFetching() external {
function test_AllowVersionFetching() external view {
// it allow version fetching

assertEq(factory.version(), Metadata.VERSION);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/v1/Paymaster/operator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ contract Paymaster__Operator is BaseTest {
assertEq(paymaster.operator(), newOperator);
}

function test_AllowOperatorToBeFetch() external {
function test_AllowOperatorToBeFetch() external view {
// it allow operator to be fetch

assertEq(paymaster.operator(), operator);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/v1/Paymaster/ownership.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ contract Paymaster__Ownership is BaseTest {
paymaster = new Paymaster(entrypoint, owner, operator);
}

function test_ReturnTheOwner() external {
function test_ReturnTheOwner() external view {
// it return the owner

assertEq(paymaster.owner(), owner);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/v1/Paymaster/versionning.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ contract Paymaster__Versionning is BaseTest {
paymaster = new Paymaster(entrypoint, owner, operator);
}

function test_AllowVersionFetching() external {
function test_AllowVersionFetching() external view {
// it allow version fetching

assertEq(paymaster.version(), Metadata.VERSION);
Expand Down

0 comments on commit 4c84455

Please sign in to comment.