From 901de5d12a7837bb48b74940282f5b4383ba0a14 Mon Sep 17 00:00:00 2001 From: Alberto Granzotto Date: Wed, 1 Nov 2023 16:22:46 +0100 Subject: [PATCH 1/2] Add failing test --- test/ResolutionManager.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/ResolutionManager.ts b/test/ResolutionManager.ts index 58a08be..97f2e54 100644 --- a/test/ResolutionManager.ts +++ b/test/ResolutionManager.ts @@ -237,7 +237,7 @@ describe("Resolution", async () => { }); describe("createResolutionWithExclusion", async () => { - it("allows to create an addressable resolution", async () => { + it("allows to create a resolution to exclude an address from voting", async () => { await expect( resolution .connect(managingBoard) @@ -247,6 +247,20 @@ describe("Resolution", async () => { .withArgs(managingBoard.address, resolutionId); }); + it.only("doesn't allow to create a resolution to exclude an address that is not a contributor from votin", async () => { + await expect( + resolution + .connect(managingBoard) + .createResolutionWithExclusion( + "test", + 0, + [], + [], + nonContributor.address + ) + ).revertedWith("Resolution: address is not a contributor"); + }); + it("doesn't allow non contributors to create an addressable resolution", async () => { await expect( resolution From b643fb6cc5175c8ef2058cf65eb1948dda609cd1 Mon Sep 17 00:00:00 2001 From: Alberto Granzotto Date: Wed, 1 Nov 2023 16:30:29 +0100 Subject: [PATCH 2/2] Fix bug --- contracts/ResolutionManager/ResolutionManagerBase.sol | 8 ++++++++ test/ResolutionManager.ts | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/contracts/ResolutionManager/ResolutionManagerBase.sol b/contracts/ResolutionManager/ResolutionManagerBase.sol index 819e139..886275b 100644 --- a/contracts/ResolutionManager/ResolutionManagerBase.sol +++ b/contracts/ResolutionManager/ResolutionManagerBase.sol @@ -177,6 +177,14 @@ abstract contract ResolutionManagerBase { executionTo.length == executionData.length, "Resolution: length mismatch" ); + require( + addressedContributor == address(0) || + _shareholderRegistry.isAtLeast( + _shareholderRegistry.CONTRIBUTOR_STATUS(), + addressedContributor + ), + "Resolution: excluded address is not a contributor" + ); uint256 resolutionId = _currentResolutionId++; emit ResolutionCreated(msg.sender, resolutionId); diff --git a/test/ResolutionManager.ts b/test/ResolutionManager.ts index 97f2e54..9a0e4a8 100644 --- a/test/ResolutionManager.ts +++ b/test/ResolutionManager.ts @@ -247,7 +247,7 @@ describe("Resolution", async () => { .withArgs(managingBoard.address, resolutionId); }); - it.only("doesn't allow to create a resolution to exclude an address that is not a contributor from votin", async () => { + it("doesn't allow to create a resolution to exclude an address that is not a contributor from voting", async () => { await expect( resolution .connect(managingBoard) @@ -258,7 +258,7 @@ describe("Resolution", async () => { [], nonContributor.address ) - ).revertedWith("Resolution: address is not a contributor"); + ).revertedWith("Resolution: excluded address is not a contributor"); }); it("doesn't allow non contributors to create an addressable resolution", async () => {