diff --git a/.gitignore b/.gitignore index 51be0e8c9..91d6cfba0 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ typechain-types # zksync era node log era_test_node.log +anvil-zksync.log diff --git a/package.json b/package.json index 9ab9b2caa..13db74ac3 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "build:ts": "rimraf dist && tsc -p tsconfig.prod.json", "build:ts:dev": "rimraf dist && tsc -p tsconfig.json", "test:zk": "HARDHAT_ENABLE_ZKSYNC=1 hardhat test", - "test": "hardhat test --network hardhat && npm run test:L1 && npm run test:L2 && npm run test:zk", + "test": "hardhat test --network hardhat && npm run test:L1 && npm run test:L2", "test:parallel": "hardhat test --parallel", "test:L1": "HARDHAT_CHAIN_ID=1 hardhat test --grep '@L1'", "test:L2": "SAFE_CONTRACT_UNDER_TEST=SafeL2 hardhat test --network hardhat", @@ -32,7 +32,7 @@ "lint": "npm run lint:sol && npm run lint:ts", "lint:fix": "npm run lint:sol:fix && npm run lint:ts:fix", "lint:sol": "solhint 'contracts/**/*.sol'", - "lint:sol:fix": "solhint --fix 'contracts/**/*.sol'", + "lint:sol:fix": "solhint --fix 'contracts/**/*.sol' --noPrompt", "lint:sol:prettier": "prettier 'contracts/**/*.sol' --list-different", "lint:ts": "eslint 'src/**/*.ts' 'test/**/*.ts'", "lint:ts:fix": "eslint 'src/**/*.ts' 'test/**/*.ts' --fix", diff --git a/test/core/Safe.OwnerManager.spec.ts b/test/core/Safe.OwnerManager.spec.ts index f6903df2a..2d7e50e79 100644 --- a/test/core/Safe.OwnerManager.spec.ts +++ b/test/core/Safe.OwnerManager.spec.ts @@ -395,7 +395,7 @@ describe("OwnerManager", () => { }); }); - describe("changeThreshold", async () => { + describe("changeThreshold", () => { it("can only be called from Safe itself", async () => { const { safe } = await setupTests(); await expect(safe.changeThreshold(1)).to.be.revertedWith("GS031"); diff --git a/test/core/Safe.Signatures.spec.ts b/test/core/Safe.Signatures.spec.ts index 2941a3f41..97041848c 100644 --- a/test/core/Safe.Signatures.spec.ts +++ b/test/core/Safe.Signatures.spec.ts @@ -639,7 +639,7 @@ describe("Safe", () => { }); }); - describe("checkNSignatures", async () => { + describe("checkNSignatures", () => { it("should fail if signature points into static part", async () => { const { safe, diff --git a/test/handlers/ExtensibleFallbackHandler.spec.ts b/test/handlers/ExtensibleFallbackHandler.spec.ts index df7cee4e6..ff3b48376 100644 --- a/test/handlers/ExtensibleFallbackHandler.spec.ts +++ b/test/handlers/ExtensibleFallbackHandler.spec.ts @@ -7,11 +7,10 @@ import { chainId } from "../utils/encoding"; import { encodeHandler, decodeHandler, encodeCustomVerifier, encodeHandlerFunction } from "../utils/extensible"; import { killLibContract } from "../utils/contracts"; -describe("ExtensibleFallbackHandler", async () => { - const [user1, user2] = await hre.ethers.getSigners(); - +describe("ExtensibleFallbackHandler", () => { const setupTests = deployments.createFixture(async ({ deployments }) => { await deployments.fixture(); + const [user1, user2] = await hre.ethers.getSigners(); const signLib = await (await hre.ethers.getContractFactory("SignMessageLib")).deploy(); const handler = await getExtensibleFallbackHandler(); const handlerAddress = await handler.getAddress(); @@ -49,13 +48,13 @@ describe("ExtensibleFallbackHandler", async () => { const counterSource = ` contract Counter { uint256 public count = 0; - + function handle(address, address, uint256, bytes calldata) external returns (bytes memory result) { bytes4 selector; assembly { selector := calldataload(164) } - + require(selector == 0xdeadbeef, "Invalid data"); count = count + 1; } @@ -112,6 +111,8 @@ describe("ExtensibleFallbackHandler", async () => { ); return { + user1, + user2, safe, validator, otherSafe, @@ -128,8 +129,8 @@ describe("ExtensibleFallbackHandler", async () => { }; }); - describe("Token Callbacks", async () => { - describe("ERC1155", async () => { + describe("Token Callbacks", () => { + describe("ERC1155", () => { it("to handle onERC1155Received", async () => { const { handler } = await setupTests(); expect(await handler.onERC1155Received.staticCall(AddressZero, AddressZero, 0, 0, "0x")).to.be.eq("0xf23a6e61"); @@ -146,7 +147,7 @@ describe("ExtensibleFallbackHandler", async () => { }); }); - describe("ERC721", async () => { + describe("ERC721", () => { it("to handle onERC721Received", async () => { const { handler } = await setupTests(); expect(await handler.onERC721Received.staticCall(AddressZero, AddressZero, 0, "0x")).to.be.eq("0x150b7a02"); @@ -159,10 +160,10 @@ describe("ExtensibleFallbackHandler", async () => { }); }); - describe("Fallback Handler", async () => { - describe("fallback()", async () => { + describe("Fallback Handler", () => { + describe("fallback()", () => { it("should revert if call to safe is less than 4 bytes (method selector)", async () => { - const { validator } = await setupTests(); + const { user1, validator } = await setupTests(); const tx = { to: await validator.getAddress(), @@ -175,8 +176,8 @@ describe("ExtensibleFallbackHandler", async () => { }); }); - describe("Custom methods", async () => { - describe("setSafeMethod(bytes4,bytes32)", async () => { + describe("Custom methods", () => { + describe("setSafeMethod(bytes4,bytes32)", () => { it("should revert if called by non-safe", async () => { const { handler, mirror } = await setupTests(); await expect(handler.setSafeMethod("0xdeadbeef", encodeHandler(true, await mirror.getAddress()))).to.be.revertedWith( @@ -185,7 +186,7 @@ describe("ExtensibleFallbackHandler", async () => { }); it("should emit event when setting a new method", async () => { - const { safe, handler, validator, mirror } = await setupTests(); + const { user1, user2, safe, handler, validator, mirror } = await setupTests(); const safeAddress = await safe.getAddress(); const newHandler = encodeHandler(true, await mirror.getAddress()); await expect(executeContractCallWithSigners(safe, validator, "setSafeMethod", ["0xdededede", newHandler], [user1, user2])) @@ -197,7 +198,7 @@ describe("ExtensibleFallbackHandler", async () => { }); it("should emit event when updating a method", async () => { - const { otherSafe, handler, preconfiguredValidator, mirror } = await setupTests(); + const { user1, user2, otherSafe, handler, preconfiguredValidator, mirror } = await setupTests(); const otherSafeAddress = await otherSafe.getAddress(); const oldHandler = encodeHandler(true, await mirror.getAddress()); const newHandler = encodeHandler(true, "0xdeAdDeADDEaDdeaDdEAddEADDEAdDeadDEADDEaD"); @@ -218,7 +219,7 @@ describe("ExtensibleFallbackHandler", async () => { }); it("should emit event when removing a method", async () => { - const { otherSafe, handler, preconfiguredValidator } = await setupTests(); + const { user1, user2, otherSafe, handler, preconfiguredValidator } = await setupTests(); const otherSafeAddress = await otherSafe.getAddress(); await expect( executeContractCallWithSigners( @@ -237,7 +238,7 @@ describe("ExtensibleFallbackHandler", async () => { }); it("is correctly set", async () => { - const { safe, validator, mirror } = await setupTests(); + const { user1, user2, safe, validator, mirror } = await setupTests(); const safeAddress = await safe.getAddress(); const tx = { to: safeAddress, @@ -275,7 +276,7 @@ describe("ExtensibleFallbackHandler", async () => { }); it("should allow calling non-static methods", async () => { - const { safe, validator, counter } = await setupTests(); + const { user1, user2, safe, validator, counter } = await setupTests(); const tx = { to: await safe.getAddress(), @@ -302,7 +303,7 @@ describe("ExtensibleFallbackHandler", async () => { }); }); - describe("MarshalLib", async () => { + describe("MarshalLib", () => { it("should correctly encode a handler and static flag", async () => { const { testMarshalLib } = await setupTests(); const handler = "0xdeaddeaddeaddeaddeaddeaddeaddeaddeaddead"; @@ -358,15 +359,15 @@ describe("ExtensibleFallbackHandler", async () => { }); }); - describe("Signature Verifier Muxer", async () => { - describe("supportsInterface(bytes4)", async () => { + describe("Signature Verifier Muxer", () => { + describe("supportsInterface(bytes4)", () => { it("should return true for supporting ERC1271", async () => { const { handler } = await setupTests(); expect(await handler.supportsInterface.staticCall("0x1626ba7e")).to.be.eq(true); }); }); - describe("setDomainVerifier(bytes32,address)", async () => { + describe("setDomainVerifier(bytes32,address)", () => { it("should revert if called by non-safe", async () => { const { handler, mirror } = await setupTests(); const domainSeparator = ethers.keccak256("0xdeadbeef"); @@ -376,7 +377,7 @@ describe("ExtensibleFallbackHandler", async () => { }); it("should emit event when setting a new domain verifier", async () => { - const { safe, handler, validator, testVerifier } = await setupTests(); + const { user1, user2, safe, handler, validator, testVerifier } = await setupTests(); const safeAddress = await safe.getAddress(); const testVerifierAddress = await testVerifier.getAddress(); const domainSeparator = ethers.keccak256("0xdeadbeef"); @@ -396,7 +397,7 @@ describe("ExtensibleFallbackHandler", async () => { }); it("should emit event when updating a domain verifier", async () => { - const { otherSafe, handler, preconfiguredValidator, mirror } = await setupTests(); + const { user1, user2, otherSafe, handler, preconfiguredValidator, mirror } = await setupTests(); const otherSafeAddress = await otherSafe.getAddress(); const mirrorAddress = await mirror.getAddress(); const domainSeparator = ethers.keccak256("0xdeadbeef"); @@ -418,7 +419,7 @@ describe("ExtensibleFallbackHandler", async () => { }); it("should emit event when removing a domain verifier", async () => { - const { otherSafe, handler, preconfiguredValidator } = await setupTests(); + const { user1, user2, otherSafe, handler, preconfiguredValidator } = await setupTests(); const otherSafeAddress = await otherSafe.getAddress(); const domainSeparator = ethers.keccak256("0xdeadbeef"); await expect( @@ -437,7 +438,7 @@ describe("ExtensibleFallbackHandler", async () => { }); }); - describe("isValidSignature(bytes32,bytes)", async () => { + describe("isValidSignature(bytes32,bytes)", () => { it("should revert if called directly", async () => { const { handler } = await setupTests(); const dataHash = ethers.keccak256("0xbaddad"); @@ -463,14 +464,14 @@ describe("ExtensibleFallbackHandler", async () => { }); it("should return magic value if message was signed", async () => { - const { safe, validator, signLib } = await setupTests(); + const { user1, user2, safe, validator, signLib } = await setupTests(); const dataHash = ethers.keccak256("0xbaddad"); await executeContractCallWithSigners(safe, signLib, "signMessage", [dataHash], [user1, user2], true); expect(await validator.isValidSignature.staticCall(dataHash, "0x")).to.be.eq("0x1626ba7e"); }); it("should return magic value if enough owners signed with typed signatures", async () => { - const { validator } = await setupTests(); + const { user1, user2, validator } = await setupTests(); const validatorAddress = await validator.getAddress(); const dataHash = ethers.keccak256("0xbaddad"); const typedDataSig = { @@ -496,7 +497,7 @@ describe("ExtensibleFallbackHandler", async () => { }); it("should send EIP-712 context to custom verifier", async () => { - const { safe, validator, revertVerifier } = await setupTests(); + const { user1, user2, safe, validator, revertVerifier } = await setupTests(); const domainSeparator = ethers.keccak256("0xdeadbeef"); const typeHash = ethers.keccak256("0xbaddad"); // abi encode the message @@ -600,36 +601,36 @@ describe("ExtensibleFallbackHandler", async () => { }); }); - describe("IERC165", async () => { - describe("supportsInterface(bytes4)", async () => { + describe("IERC165", () => { + describe("supportsInterface(bytes4)", () => { it("should return true for ERC165", async () => { const { validator } = await setupTests(); expect(await validator.supportsInterface.staticCall("0x01ffc9a7")).to.be.true; }); }); - describe("setSupportedInterface(bytes4,bool)", async () => { + describe("setSupportedInterface(bytes4,bool)", () => { it("should revert if called by non-safe", async () => { const { handler } = await setupTests(); await expect(handler.setSupportedInterface("0xdeadbeef", true)).to.be.revertedWith("only safe can call this method"); }); it("should revert if trying to set an invalid interface", async () => { - const { validator, safe } = await setupTests(); + const { user1, user2, validator, safe } = await setupTests(); await expect( executeContractCallWithSigners(safe, validator, "setSupportedInterface", ["0xffffffff", true], [user1, user2]), ).to.be.revertedWith("invalid interface id"); }); it("should emit event when adding a newly supported interface", async () => { - const { validator, safe, handler } = await setupTests(); + const { user1, user2, validator, safe, handler } = await setupTests(); await expect(executeContractCallWithSigners(safe, validator, "setSupportedInterface", ["0xdeadbeef", true], [user1, user2])) .to.emit(handler, "AddedInterface") .withArgs(await safe.getAddress(), "0xdeadbeef"); }); it("should emit event when removing a supported interface", async () => { - const { handler, otherSafe, preconfiguredValidator } = await setupTests(); + const { user1, user2, handler, otherSafe, preconfiguredValidator } = await setupTests(); await expect( executeContractCallWithSigners( @@ -645,7 +646,7 @@ describe("ExtensibleFallbackHandler", async () => { }); it("should not emit event when removing an unsupported interface", async () => { - const { handler, otherSafe, preconfiguredValidator } = await setupTests(); + const { user1, user2, handler, otherSafe, preconfiguredValidator } = await setupTests(); await expect( executeContractCallWithSigners( @@ -659,7 +660,7 @@ describe("ExtensibleFallbackHandler", async () => { }); }); - describe("addSupportedInterfaceBatch(bytes4, bytes32[]", async () => { + describe("addSupportedInterfaceBatch(bytes4, bytes32[]", () => { it("should revert if called by non-safe", async () => { const { handler } = await setupTests(); await expect(handler.addSupportedInterfaceBatch("0xdeadbeef", [HashZero])).to.be.revertedWith( @@ -668,7 +669,7 @@ describe("ExtensibleFallbackHandler", async () => { }); it("should revert if batch contains an invalid interface", async () => { - const { validator, safe } = await setupTests(); + const { user1, user2, validator, safe } = await setupTests(); await expect( executeContractCallWithSigners( safe, @@ -681,7 +682,7 @@ describe("ExtensibleFallbackHandler", async () => { }); it("should add all handlers in batch", async () => { - const { validator, safe, handler, mirror } = await setupTests(); + const { user1, user2, validator, safe, handler, mirror } = await setupTests(); const safeAddress = await safe.getAddress(); // calculate the selector for each function @@ -713,7 +714,7 @@ describe("ExtensibleFallbackHandler", async () => { }); }); - describe("removeSupportedInterfaceBatch(bytes4, bytes4[]", async () => { + describe("removeSupportedInterfaceBatch(bytes4, bytes4[]", () => { it("should revert if called by non-safe", async () => { const { handler } = await setupTests(); await expect(handler.removeSupportedInterfaceBatch("0xdeadbeef", ["0xdeadbeef"])).to.be.revertedWith( @@ -722,7 +723,7 @@ describe("ExtensibleFallbackHandler", async () => { }); it("should remove all methods in a batch", async () => { - const { validator, safe, handler, mirror } = await setupTests(); + const { user1, user2, validator, safe, handler, mirror } = await setupTests(); const safeAddress = await safe.getAddress(); // calculate the selector for each function diff --git a/test/l2/Safe.Execution.spec.ts b/test/l2/Safe.Execution.spec.ts index fbaf3a263..6d36b903e 100644 --- a/test/l2/Safe.Execution.spec.ts +++ b/test/l2/Safe.Execution.spec.ts @@ -29,7 +29,7 @@ describe("SafeL2", () => { }; }); - describe("execTransactions", async () => { + describe("execTransactions", () => { it("should emit SafeMultiSigTransaction event", async () => { const { safe, diff --git a/test/libraries/Migration.120.spec.ts b/test/libraries/Migration.120.spec.ts index a5979922f..60770ca5b 100644 --- a/test/libraries/Migration.120.spec.ts +++ b/test/libraries/Migration.120.spec.ts @@ -36,7 +36,7 @@ describe("Migration 1.2.0", () => { signers, }; }); - describe("constructor", async () => { + describe("constructor", () => { it("can not use 0 Address", async () => { const { signers: [user1],