Skip to content

Commit

Permalink
add: more campaign tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sirpy committed Mar 12, 2024
1 parent 4f02494 commit f30f4a2
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/invite/InvitesV2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,11 @@ describe("InvitesV2", () => {
.connect(invitee1)
.join(ethers.utils.hexZeroPad(invitee1.address, 32), ethers.utils.formatBytes32String("test"));
const { events } = await tx.wait();

const bountyEvent = events.find(_ => _.event === "InviterBounty");
const bounty = (await invites.levels(0)).bounty;

expect(await gd.balanceOf(invitee1.address)).eq(bounty.div(2));
expect(bountyEvent).not.empty;
});

Expand All @@ -377,6 +381,28 @@ describe("InvitesV2", () => {
const bountyEvent2 = events2.find(_ => _.event === "InviterBounty");
expect(bountyEvent2).not.undefined;
});

it("should collect bounty with campaignCode after first join without being whitelisted", async () => {
await loadFixture(initialState);
await invites.setCampaignCode(ethers.utils.formatBytes32String("test"));

const tx = await invites
.connect(invitee1)
.join(ethers.utils.hexZeroPad(invitee1.address, 32), ethers.utils.formatBytes32String("test"));
const { events } = await tx.wait();
const bountyEvent = events.find(_ => _.event === "InviterBounty");
expect(bountyEvent).undefined;

await id.addWhitelistedWithDID(invitee1.address, Math.random() + "").catch(e => e);

expect(await invites.canCollectBountyFor(invitee1.address)).to.be.true;

const tx2 = await invites.connect(invitee1).bountyFor(invitee1.address);

const { events: events2 } = await tx2.wait();
const bountyEvent2 = events2.find(_ => _.event === "InviterBounty");
expect(bountyEvent2).not.undefined;
});
});

it("should end contract by owner", async () => {
Expand Down

0 comments on commit f30f4a2

Please sign in to comment.