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