Skip to content

Commit

Permalink
fix remaining tests and clean up interface function overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
fangting-alchemy committed Jun 24, 2024
1 parent 085bc78 commit 8026eec
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/validators/EcdsaValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ contract EcdsaValidator is IStatelessValidator {
function validate(bytes memory signerData, bytes32 hash, bytes memory signature)
external
view
override
returns (bool isValid, bytes memory result)
{
if (signerData.length == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ contract Erc1271Validator is IStatelessValidator {
function validate(bytes memory signerData, bytes32 hash, bytes memory signature)
external
view
override
returns (bool isValid, bytes memory)
{
if (signerData.length == 0) {
Expand Down
3 changes: 2 additions & 1 deletion src/validators/WebAuthnValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ contract WebAuthnValidator is IStatelessValidator {
function validate(bytes memory signerData, bytes32 hash, bytes memory signature)
external
view
returns (bool isValid, bytes memory result)
override
returns (bool isValid, bytes memory)
{
(
bytes memory authenticatorData,
Expand Down
16 changes: 13 additions & 3 deletions test/account/MultiValidation.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {SingleOwnerPlugin} from "../../src/plugins/owner/SingleOwnerPlugin.sol";
import {ISingleOwnerPlugin} from "../../src/plugins/owner/ISingleOwnerPlugin.sol";

import {AccountTestBase} from "../utils/AccountTestBase.sol";
import {Signer} from "../../src/validators/IStatelessValidator.sol";

contract MultiValidationTest is AccountTestBase {
using ECDSA for bytes32;
Expand All @@ -24,20 +25,23 @@ contract MultiValidationTest is AccountTestBase {

address public owner2;
uint256 public owner2Key;
Signer public signer2;

uint256 public constant CALL_GAS_LIMIT = 50000;
uint256 public constant VERIFICATION_GAS_LIMIT = 1200000;

function setUp() public {
validator2 = new SingleOwnerPlugin();

(owner1, owner1Key) = makeAddrAndKey("owner1");
(owner2, owner2Key) = makeAddrAndKey("owner2");
signer2 = Signer(ecdsaValidator, abi.encode(address(owner2)));
}

function test_overlappingValidationInstall() public {
bytes32 manifestHash = keccak256(abi.encode(validator2.pluginManifest()));
vm.prank(address(entryPoint));
account1.installPlugin(address(validator2), manifestHash, abi.encode(owner2), new FunctionReference[](0));
account1.installPlugin(address(validator2), manifestHash, abi.encode(signer2), new FunctionReference[](0));

FunctionReference[] memory validations = new FunctionReference[](2);
validations[0] = FunctionReferenceLib.pack(
Expand Down Expand Up @@ -123,8 +127,14 @@ contract MultiValidationTest is AccountTestBase {

userOp.nonce = 1;
(v, r, s) = vm.sign(owner1Key, userOpHash.toEthSignedMessageHash());
userOp.signature =
abi.encodePacked(address(validator2), uint8(ISingleOwnerPlugin.FunctionId.VALIDATION_OWNER), r, s, v);
userOp.signature = abi.encodePacked(
address(validator2),
SELECTOR_ASSOCIATED_VALIDATION,
uint8(ISingleOwnerPlugin.FunctionId.VALIDATION_OWNER),
r,
s,
v
);

userOps[0] = userOp;
vm.expectRevert(abi.encodeWithSelector(IEntryPoint.FailedOp.selector, 0, "AA24 signature error"));
Expand Down
1 change: 0 additions & 1 deletion test/account/UpgradeableModularAccount.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {MockPlugin} from "../mocks/MockPlugin.sol";
import {AccountTestBase} from "../utils/AccountTestBase.sol";

import {Signer} from "../../src/validators/IStatelessValidator.sol";
import {EcdsaValidator} from "../../src/validators/EcdsaValidator.sol";

contract UpgradeableModularAccountTest is AccountTestBase {
using ECDSA for bytes32;
Expand Down
2 changes: 1 addition & 1 deletion test/plugin/SingleOwnerPlugin.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {ISingleOwnerPlugin} from "../../src/plugins/owner/ISingleOwnerPlugin.sol
import {ContractOwner} from "../mocks/ContractOwner.sol";
import {OptimizedTest} from "../utils/OptimizedTest.sol";

import {Signer, IStatelessValidator} from "../../src/validators/IStatelessValidator.sol";
import {Signer} from "../../src/validators/IStatelessValidator.sol";
import {EcdsaValidator} from "../../src/validators/EcdsaValidator.sol";
import {Erc1271Validator} from "../../src/validators/Erc1271Validator.sol";

Expand Down

0 comments on commit 8026eec

Please sign in to comment.