Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in make offer #131

Merged
merged 4 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions contracts/InternalMarket/InternalMarket.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ contract InternalMarket is Initializable, HasRole, InternalMarketBase {
* @param amount The amount of tokens to offer for sale.
*/
function makeOffer(uint256 amount) public virtual {
require(
_shareholderRegistry.isAtLeast(
_shareholderRegistry.CONTRIBUTOR_STATUS(),
msg.sender
),
"InternalMarket: only contributors can make offers"
);
_makeOffer(_msgSender(), amount);
}

Expand Down
5 changes: 5 additions & 0 deletions test/Integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,11 @@ describe("Integration", async () => {
"Resolution: account cannot vote"
);

// user3 cannot offer tokens
await expect(internalMarket.connect(user3).makeOffer(10)).revertedWith(
"InternalMarket: only contributors can make offers"
);

// ... and finally the world is saved.
expect(await resolutionManager.getResolutionResult(resolutionId)).to.be
.true;
Expand Down
7 changes: 7 additions & 0 deletions test/InternalMarket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ describe("InternalMarket", async () => {
);
});

it("should revert when called by a non-contributor", async () => {
registry.isAtLeast.returns(false);
await expect(internalMarket.makeOffer(1000)).revertedWith(
"InternalMarket: only contributors can make offers"
);
});

describe("redeem", async () => {
describe("with some unlocked tokens", async () => {
beforeEach(async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/RedemptionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ describe("RedemptionController", () => {
);
});

describe.only("when 10 tokens are redeemable", async () => {
describe("when 10 tokens are redeemable", async () => {
beforeEach(async () => {
await redemptionController.afterMint(account.address, 10);
await redemptionController.afterOffer(account.address, 10);
Expand Down