rln-interep-contract/test/validGroupStorage.ts

43 lines
1.3 KiB
TypeScript
Raw Normal View History

2022-11-25 11:38:38 +05:30
import { expect } from "chai";
import { ethers, deployments } from "hardhat";
import { sToBytes32, createGroupId } from "../common";
describe("Valid Group Storage", () => {
2022-11-25 11:38:38 +05:30
beforeEach(async () => {
await deployments.fixture(["ValidGroupStorage"]);
});
it("should not deploy if an invalid group is passed in constructor", async () => {
const interepTest = await ethers.getContract("InterepTest");
const interepAddress = interepTest.address;
2022-11-25 11:38:38 +05:30
const ValidGroupStorage = await ethers.getContractFactory(
"ValidGroupStorage"
);
expect(
ValidGroupStorage.deploy(interepAddress, [
{
provider: sToBytes32("github"),
name: sToBytes32("diamond"),
},
])
).to.be.revertedWith("[ValidGroupStorage] Invalid group");
});
2022-11-25 11:38:38 +05:30
it("should return true for valid group", async () => {
const validGroupStorage = await ethers.getContract("ValidGroupStorage");
const valid = await validGroupStorage.isValidGroup(
2022-12-02 15:25:17 +05:30
createGroupId("github", "bronze")
2022-11-25 11:38:38 +05:30
);
expect(valid).to.be.true;
});
2022-11-25 11:38:38 +05:30
it("should return false for invalid group", async () => {
const validGroupStorage = await ethers.getContract("ValidGroupStorage");
const valid = await validGroupStorage.isValidGroup(
2022-12-02 15:25:17 +05:30
createGroupId("github", "silver")
2022-11-25 11:38:38 +05:30
);
expect(valid).to.be.false;
});
});