Skip to content

Commit

Permalink
rename event
Browse files Browse the repository at this point in the history
  • Loading branch information
andresaiello committed Oct 30, 2023
1 parent 6d7bc45 commit 8ee07a6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/addresses/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
"vite": "^3.1.0",
"vite-plugin-dts": "^1.4.1"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ contract InvitationManager {
error CanNotInviteYourself();

event UserVerified(address indexed userAddress, uint256 verifiedAt);
event InvitationAccepted(address indexed inviter, address indexed invitee, uint256 timestamp);
event InvitationAccepted(address indexed inviter, address indexed invitee, uint256 acceptedAt);

function _markAsVerified(address user) internal {
// Check if the user is already verified
Expand Down
13 changes: 13 additions & 0 deletions packages/zevm-app-contracts/test/zeta-points/InvitationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ describe("InvitationManager Contract test", () => {
describe("Invitations test", () => {
it("Should verify an invitation and store it", async () => {
const sig = await getInvitationSig(inviter);

const hasBeenVerifiedBefore = await invitationManager.hasBeenVerified(invitee.address);
await expect(hasBeenVerifiedBefore).to.be.eq(false);

const tx = await invitationManager.connect(invitee).confirmAndAcceptInvitation(inviter.address, sig);
const rec = await tx.wait();

Expand All @@ -40,6 +44,9 @@ describe("InvitationManager Contract test", () => {

const invitationCount = await invitationManager.getInviteeCount(inviter.address);
await expect(invitationCount).to.be.eq(1);

const hasBeenVerifiedAfter = await invitationManager.hasBeenVerified(invitee.address);
await expect(hasBeenVerifiedAfter).to.be.eq(true);
});

it("Should revert if invitation is invalid", async () => {
Expand All @@ -48,6 +55,12 @@ describe("InvitationManager Contract test", () => {
await expect(tx).to.be.revertedWith("UnrecognizedInvitation");
});

it("Should revert if inviter has not been verified", async () => {
const sig = await getInvitationSig(addrs[0]);
const tx = invitationManager.connect(invitee).confirmAndAcceptInvitation(addrs[0].address, sig);
await expect(tx).to.be.revertedWith("UnrecognizedInvitation");
});

it("Should revert if invitation is already accepted", async () => {
const sig = await getInvitationSig(inviter);
await invitationManager.connect(invitee).confirmAndAcceptInvitation(inviter.address, sig);
Expand Down

0 comments on commit 8ee07a6

Please sign in to comment.