Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
andresaiello committed Oct 20, 2023
1 parent a8735ce commit 6d7bc45
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe("InvitationManager Contract test", () => {
const InvitationManager = await ethers.getContractFactory("InvitationManager");
//@ts-ignore
invitationManager = await InvitationManager.deploy();
await invitationManager.markAsVerified();
});

describe("True", () => {
Expand Down Expand Up @@ -51,7 +52,7 @@ describe("InvitationManager Contract test", () => {
const sig = await getInvitationSig(inviter);
await invitationManager.connect(invitee).confirmAndAcceptInvitation(inviter.address, sig);
const tx = invitationManager.connect(invitee).confirmAndAcceptInvitation(inviter.address, sig);
await expect(tx).to.be.revertedWith("InvitationAlreadyAccepted");
await expect(tx).to.be.revertedWith("UserAlreadyVerified");
});

it("Should count only for today if I just accepted", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ use(solidity);
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { ethers } from "hardhat";

import { UserVerificationRegistry } from "../../typechain-types";
import { InvitationManager } from "../../typechain-types";

describe("UserVerificationRegistry Contract test", () => {
let userVerificationRegistry: UserVerificationRegistry, user: SignerWithAddress, addrs: SignerWithAddress[];
let invitationManager: InvitationManager, user: SignerWithAddress, addrs: SignerWithAddress[];

beforeEach(async () => {
[user, ...addrs] = await ethers.getSigners();
const UserVerificationRegistryFactory = await ethers.getContractFactory("UserVerificationRegistry");
const InvitationManagerFactory = await ethers.getContractFactory("InvitationManager");
//@ts-ignore
userVerificationRegistry = await UserVerificationRegistryFactory.deploy();
invitationManager = await InvitationManagerFactory.deploy();
});

describe("True", () => {
Expand All @@ -24,17 +24,17 @@ describe("UserVerificationRegistry Contract test", () => {

describe("Vereification test", () => {
it("Should be able to verify a wallet", async () => {
const hasBeenVerified = await userVerificationRegistry.hasBeenVerified(user.address);
const hasBeenVerified = await invitationManager.hasBeenVerified(user.address);
expect(hasBeenVerified).to.be.false;

const tx = await userVerificationRegistry.markAsVerified();
const tx = await invitationManager.markAsVerified();
const receipt = await tx.wait();
const block = await ethers.provider.getBlock(receipt.blockNumber);

const hasBeenVerifiedAfter = await userVerificationRegistry.hasBeenVerified(user.address);
const hasBeenVerifiedAfter = await invitationManager.hasBeenVerified(user.address);
expect(hasBeenVerifiedAfter).to.be.true;

const verification = await userVerificationRegistry.getVerifiedTimestamp(user.address);
const verification = await invitationManager.getVerifiedTimestamp(user.address);
expect(verification).to.be.eq(block.timestamp);
});
});
Expand Down

0 comments on commit 6d7bc45

Please sign in to comment.