Skip to content

Commit

Permalink
add tests triggering bug
Browse files Browse the repository at this point in the history
  • Loading branch information
sirnicolaz committed Sep 12, 2023
1 parent b204ae0 commit 4c0b2d6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/GovernanceToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ describe("GovernanceToken", () => {
redemption.afterMint.reset();
daoRoles.hasRole.reset();
shareholderRegistry.isAtLeast.reset();
neokingdomToken.mint.reset();
});

describe("transfer hooks", async () => {
Expand Down Expand Up @@ -335,7 +336,7 @@ describe("GovernanceToken", () => {
});
});

describe("processDepositedTokens", async () => {
describe("settleTokens", async () => {
describe("when no tokens have been wrapped", async () => {
it("should mint nothing", async () => {
await governanceToken.settleTokens(contributor.address);
Expand Down Expand Up @@ -383,7 +384,7 @@ describe("GovernanceToken", () => {
expect(result).equal(41);
});

it("should only not mint non cooled tokens", async () => {
it("should not mint non cooled tokens", async () => {
await governanceToken.wrap(contributor.address, 42);
await governanceToken.settleTokens(contributor.address);

Expand Down Expand Up @@ -418,6 +419,14 @@ describe("GovernanceToken", () => {

expect(balanceAfter).equal(balanceBefore.add(42));
});

it("should not mint an equivalent amount of neok tokens to the governance contract", async () => {
await governanceToken.wrap(contributor.address, 42);
await timeTravel(7);
await governanceToken.settleTokens(contributor.address);

expect(neokingdomToken.mint).to.not.have.been.called;
});
});
});

Expand Down
17 changes: 17 additions & 0 deletions test/Integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1254,25 +1254,39 @@ describe("Integration", async () => {
});

it("back and forth NEOK <-> Governance", async () => {
async function _expectWrapped(count: number) {
let wrappedNEOKs = await neokingdomToken.balanceOf(
governanceToken.address
);
expect(wrappedNEOKs).equal(count);
}

await governanceToken.setSettlementPeriod(3600 * 24 * 7);
const share = parseEther("1");
await shareholderRegistry.mint(user1.address, parseEther("1"));
await shareholderRegistry.mint(user2.address, parseEther("1"));
await shareholderRegistry.setStatus(contributorStatus, user1.address);
await shareholderRegistry.setStatus(contributorStatus, user2.address);

await _expectWrapped(0);

// 15 Governance Tokens to user2
await governanceToken.mint(user2.address, 15);
await _expectWrapped(15);

// 5 Governance tokens minted to user1
await governanceToken.mint(user1.address, 5);
await _expectWrapped(20);

// user2 withdraws 10 Governance tokens to user1
await internalMarket.connect(user2).makeOffer(10);
await timeTravel(7, true);
await internalMarket.connect(user2).withdraw(user1.address, 10);
await _expectWrapped(10);

// user1 deposit 4 NEOK
await internalMarket.connect(user1).deposit(4);
await _expectWrapped(14);
// user1 voting power is 5
expect(await voting.getVotingPower(user1.address)).equal(share.add(5));
// user1 offers 3 NEOK
Expand All @@ -1287,6 +1301,7 @@ describe("Integration", async () => {
);
// user1 deposit 3 NEOK
await internalMarket.connect(user1).deposit(3);
await _expectWrapped(17);
// user1 voting power is 2
expect(await voting.getVotingPower(user1.address)).equal(share.add(2));
// deposit is finalized
Expand All @@ -1299,6 +1314,8 @@ describe("Integration", async () => {
await governanceToken.settleTokens(user1.address);
// user1 voting power is 9
expect(await voting.getVotingPower(user1.address)).equal(share.add(9));

await _expectWrapped(17);
});

it("internal and external token amounts", async () => {
Expand Down

0 comments on commit 4c0b2d6

Please sign in to comment.