From eec44862a9f9c8e826308eb5d6f14dcd7b5022c3 Mon Sep 17 00:00:00 2001 From: Akshay Date: Mon, 26 Jun 2023 15:03:48 +0200 Subject: [PATCH] [#4] Add test case: Non-enabled module should not be able to execute root tx --- .solcover.js | 2 +- test/SafeProtocolMediator.spec.ts | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.solcover.js b/.solcover.js index 2a45ba3e..e83aef09 100644 --- a/.solcover.js +++ b/.solcover.js @@ -1,3 +1,3 @@ module.exports = { - skipFiles: ['test/TestExecutor.sol', 'test/TestModule.sol'] + skipFiles: ['test/TestExecutor.sol', 'test/TestModule.sol', 'test/TestDelegateCallReceiver.sol'] }; \ No newline at end of file diff --git a/test/SafeProtocolMediator.spec.ts b/test/SafeProtocolMediator.spec.ts index 34003723..0188cfa3 100644 --- a/test/SafeProtocolMediator.spec.ts +++ b/test/SafeProtocolMediator.spec.ts @@ -246,5 +246,25 @@ describe("SafeProtocolMediator", async () => { .to.emit(safeProtocolMediator, "RootAccessActionExecuted") .withArgs(await safe.getAddress(), safeTx.metaHash); }); + + it("Should not allow non-enabled module to execute root tx from a safe", async () => { + const { safeProtocolMediator, safe } = await loadFixture(deployContractsFixture); + const module = await (await hre.ethers.getContractFactory("TestModuleWithRootAccess")).deploy(); + // TODO: Replace with builder function + const safeTx = { + action: { + to: user2.address, + value: hre.ethers.parseEther("1"), + data: "0x", + }, + nonce: 1, + metaHash: hre.ethers.randomBytes(32), + }; + + await expect(module.executeFromModule(safeProtocolMediator, safe, safeTx)).to.be.revertedWithCustomError( + safeProtocolMediator, + "MoudleNotEnabled", + ); + }); }); });