mirror of
https://github.com/vacp2p/linea-monorepo.git
synced 2026-01-09 04:08:01 -05:00
* first pass contracts and makefile cleanup * remove unused 4844 test files * Remove Goerli references * lint fixing * lint fixing * remove more Goerli references * correct folder paths for L2 service tests * fix pathing and hardhat version * reinstate deleted file * correct file pathing
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { loadFixture } from "@nomicfoundation/hardhat-network-helpers";
|
|
import { expect } from "chai";
|
|
import { ethers } from "hardhat";
|
|
import { Mimc } from "../../typechain-types";
|
|
import mimcTestData from "../testData/mimc-test-data.json";
|
|
import { deployFromFactory } from "../common/deployment";
|
|
import { expectRevertWithCustomError } from "../common/helpers";
|
|
|
|
describe("Mimc", () => {
|
|
let mimc: Mimc;
|
|
|
|
async function deployMIMCFixture() {
|
|
return deployFromFactory("Mimc") as Promise<Mimc>;
|
|
}
|
|
|
|
beforeEach(async () => {
|
|
mimc = await loadFixture(deployMIMCFixture);
|
|
});
|
|
|
|
describe("hash", () => {
|
|
it("Should return mimc hash for each test case", async () => {
|
|
for (const element of mimcTestData) {
|
|
const msgs = ethers.concat(element.in);
|
|
expect(await mimc.hash(msgs)).to.equal(element.out);
|
|
}
|
|
});
|
|
|
|
it("Should revert if the data is zero length", async () => {
|
|
await expectRevertWithCustomError(mimc, mimc.hash("0x"), "DataMissing");
|
|
});
|
|
|
|
it("Should revert if the data is less than 32 and not mod32", async () => {
|
|
await expectRevertWithCustomError(mimc, mimc.hash("0x12"), "DataIsNotMod32");
|
|
});
|
|
|
|
it("Should revert if the data is greater than 32 and not mod32", async () => {
|
|
await expectRevertWithCustomError(
|
|
mimc,
|
|
mimc.hash("0x103adbc490c2067eac112873462707eb2072813005a4ac3ab182135be336742423456789"),
|
|
"DataIsNotMod32",
|
|
);
|
|
});
|
|
});
|
|
});
|