Skip to content

Commit

Permalink
[#6] Make event parameters indexed when registry is changed, move tests
Browse files Browse the repository at this point in the history
  • Loading branch information
akshay-ap committed Jul 5, 2023
1 parent 72b753f commit 48527f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion contracts/base/RegistryManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {ISafeProtocolRegistry} from "../interfaces/Registry.sol";
contract RegistryManager is Ownable2Step {
address public registry;

event RegistryChanged(address oldRegistry, address newRegistry);
event RegistryChanged(address indexed oldRegistry, address indexed newRegistry);

error ModuleNotPermitted(address module, uint64 listedAt, uint64 flaggedAt);

Expand Down
22 changes: 10 additions & 12 deletions test/SafeProtocolMediator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,16 @@ describe("SafeProtocolMediator", async () => {
return { safeProtocolMediator, safe, module, safeProtocolRegistry };
}

describe("Enabling module reverts with ModuleNotPermitted", async () => {
describe("Test enable module", async () => {
it("Should not allow a Safe to enable zero address module", async () => {
const { safeProtocolMediator, safe } = await loadFixture(deployContractsWithModuleFixture);
await safe.setModule(await safeProtocolMediator.getAddress());
const data = safeProtocolMediator.interface.encodeFunctionData("enableModule", [hre.ethers.ZeroAddress, false]);
await expect(safe.exec(await safeProtocolMediator.getAddress(), 0, data))
.to.be.revertedWithCustomError(safeProtocolMediator, "InvalidModuleAddress")
.withArgs(hre.ethers.ZeroAddress);
});

it("Should not allow a Safe to enable module if not added as a component in registry", async () => {
const { safeProtocolMediator, safe } = await loadFixture(deployContractsWithModuleFixture);
await safe.setModule(await safeProtocolMediator.getAddress());
Expand All @@ -62,17 +71,6 @@ describe("SafeProtocolMediator", async () => {
"ModuleNotPermitted",
);
});
});

describe("Test enable module", async () => {
it("Should not allow a Safe to enable zero address module", async () => {
const { safeProtocolMediator, safe } = await loadFixture(deployContractsWithModuleFixture);
await safe.setModule(await safeProtocolMediator.getAddress());
const data = safeProtocolMediator.interface.encodeFunctionData("enableModule", [hre.ethers.ZeroAddress, false]);
await expect(safe.exec(await safeProtocolMediator.getAddress(), 0, data))
.to.be.revertedWithCustomError(safeProtocolMediator, "InvalidModuleAddress")
.withArgs(hre.ethers.ZeroAddress);
});

it("Should not allow a Safe to enable SENTINEL_MODULES module", async () => {
const { safeProtocolMediator, safe } = await loadFixture(deployContractsWithModuleFixture);
Expand Down

0 comments on commit 48527f4

Please sign in to comment.