2024-12-05 17:53:43 +08:00
|
|
|
// import chai from "chai";
|
|
|
|
// import {createCode, generateABI} from "../src/poseidon_gencontract.js";
|
|
|
|
// import { buildPoseidon } from "../src/poseidon_wasm.js";
|
|
|
|
// import { ethers } from "ethers";
|
|
|
|
// import ganache from "ganache";
|
2021-10-06 11:28:14 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// const assert = chai.assert;
|
|
|
|
// const log = (msg) => { if (process.env.MOCHA_VERBOSE) console.log(msg); };
|
2021-10-06 11:28:14 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// describe("Poseidon Smart contract test", function () {
|
|
|
|
// let testrpc;
|
|
|
|
// let web3;
|
|
|
|
// let poseidon6;
|
|
|
|
// let poseidon3;
|
|
|
|
// let poseidon;
|
|
|
|
// let account;
|
|
|
|
// this.timeout(100000);
|
2021-10-06 11:28:14 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// before(async () => {
|
|
|
|
// const provider = new ethers.providers.Web3Provider(ganache.provider());
|
2021-10-30 13:57:29 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// account = provider.getSigner(0);
|
|
|
|
// poseidon = await buildPoseidon();
|
|
|
|
// });
|
2021-10-06 11:28:14 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// it("Should deploy the contract", async () => {
|
|
|
|
// const C6 = new ethers.ContractFactory(
|
|
|
|
// generateABI(5),
|
|
|
|
// createCode(5),
|
|
|
|
// account
|
|
|
|
// );
|
|
|
|
// const C3 = new ethers.ContractFactory(
|
|
|
|
// generateABI(2),
|
|
|
|
// createCode(2),
|
|
|
|
// account
|
|
|
|
// );
|
2021-10-30 13:57:29 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// poseidon6 = await C6.deploy();
|
|
|
|
// poseidon3 = await C3.deploy();
|
|
|
|
// });
|
2021-10-06 11:28:14 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// it("Should calculate the poseidon correctly t=6", async () => {
|
2021-10-06 11:28:14 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// const res = await poseidon6["poseidon(uint256[5])"]([1,2, 0, 0, 0]);
|
2021-10-06 11:28:14 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// // console.log("Cir: " + bigInt(res.toString(16)).toString(16));
|
2021-10-06 11:28:14 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// const res2 = poseidon([1,2, 0, 0, 0]);
|
|
|
|
// // console.log("Ref: " + bigInt(res2).toString(16));
|
2021-10-06 11:28:14 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// assert.equal(res.toString(), poseidon.F.toString(res2));
|
|
|
|
// });
|
|
|
|
// it("Should calculate the poseidon correctly t=3", async () => {
|
2021-10-06 11:28:14 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// const res = await poseidon3["poseidon(uint256[2])"]([1,2]);
|
2021-10-06 11:28:14 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// // console.log("Cir: " + bigInt(res.toString(16)).toString(16));
|
2021-10-06 11:28:14 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// const res2 = poseidon([1,2]);
|
|
|
|
// // console.log("Ref: " + bigInt(res2).toString(16));
|
2021-10-06 11:28:14 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// assert.equal(res.toString(), poseidon.F.toString(res2));
|
|
|
|
// });
|
2021-10-06 11:28:14 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// });
|
2021-10-06 11:28:14 +02:00
|
|
|
|