Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Filipp Makarov authored and Filipp Makarov committed Nov 21, 2024
1 parent 26acfa5 commit 984fd2a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ contract TestERC1271Account_IsValidSignature is NexusTest_Base {
(t.v, t.r, t.s) = vm.sign(ALICE.privateKey, hashToSign);
bytes memory signature = abi.encodePacked(t.r, t.s, t.v);
assertEq(ALICE_ACCOUNT.isValidSignature(t.contents, abi.encodePacked(address(validator), signature)), bytes4(0x1626ba7e));

unchecked {
uint256 vs = uint256(t.s) | (uint256(t.v - 27) << 255);
signature = abi.encodePacked(t.r, vs);
assertEq(ALICE_ACCOUNT.isValidSignature(t.contents, abi.encodePacked(address(validator), signature)), bytes4(0xffffffff));
}
}

/// @notice Tests the validation of an EIP-712 signature using the mock validator.
Expand All @@ -68,15 +62,6 @@ contract TestERC1271Account_IsValidSignature is NexusTest_Base {
if (random() % 4 == 0) signature = erc6492Wrap(signature);
bytes4 ret = ALICE_ACCOUNT.isValidSignature(toContentsHash(t.contents), abi.encodePacked(address(validator), signature));
assertEq(ret, bytes4(0x1626ba7e));

unchecked {
uint256 vs = uint256(t.s) | (uint256(t.v - 27) << 255);
signature = abi.encodePacked(t.r, vs, APP_DOMAIN_SEPARATOR, t.contents, contentsType, uint16(contentsType.length));
assertEq(
ALICE_ACCOUNT.isValidSignature(toContentsHash(t.contents), abi.encodePacked(address(validator), signature)),
bytes4(0xffffffff)
);
}
}

/// @notice Tests the failure of an EIP-712 signature validation due to a wrong signer.
Expand Down Expand Up @@ -171,7 +156,7 @@ contract TestERC1271Account_IsValidSignature is NexusTest_Base {
/// @return The ERC-1271 hash for personal sign.
function toERC1271HashPersonalSign(bytes32 childHash, address account) internal view returns (bytes32) {
AccountDomainStruct memory t;
(/*t.fields*/, t.name, t.version, t.chainId, t.verifyingContract, t.salt, /*t.extensions*/) = EIP712(account).eip712Domain();
(/*t.fields*/, t.name, t.version, t.chainId, t.verifyingContract, t.salt, /*t.extensions*/) = EIP712(account).eip712Domain();
bytes32 domainSeparator = keccak256(
abi.encode(
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
Expand Down
4 changes: 2 additions & 2 deletions test/foundry/unit/concrete/modules/TestK1Validator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ contract TestK1Validator is NexusTest_Base {
function test_Version() public {
string memory contractVersion = validator.version();

assertEq(contractVersion, "1.0.0", "Contract version should be '1.0.0'");
assertEq(contractVersion, "1.0.1", "Contract version should be '1.0.1'");
}

/// @notice Tests the isModuleType function to return the correct module type
Expand Down Expand Up @@ -383,7 +383,7 @@ contract TestK1Validator is NexusTest_Base {
abi.encode(
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
keccak256("Nexus"),
keccak256("1.0.0"),
keccak256("1.0.1"),
block.chainid,
address(BOB_ACCOUNT)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe("K1Validator module tests", () => {

it("should get module version", async () => {
const version = await k1Validator.version();
expect(version).to.equal("1.0.0");
expect(version).to.equal("1.0.1");
});

it("should check module type", async () => {
Expand Down

0 comments on commit 984fd2a

Please sign in to comment.