circomlibjs/test/poseidoncontract.js
Micah Zoltu fc0c01e400 Removes many dependencies and bundles to ES Module.
* NodeJS has built-in testing tools now, so no need to include Mocha/Chai which bring in a lot of transitive dependencies.
* Removes ethers, as it was only being used for a few utility functions (which are now in `utils.js` and `keccak256`, whiche is better sourced from @noble/hashes.
* Adds @noble/hashes for `keccak256`.
* Removes hardhat, since it was brought in only to test one thing, and it is huge.
* Switches to esbuild for simple ESM targeted bundling with inlnined NodeJS dependencies.
* Pinned all JS dependencies to fixed versions.
* Adds a Dockerfile for generating reproducible builds.
* Commented out two tests that had a dependency on Hardhat.
2024-12-06 13:17:31 +08:00

67 lines
2.0 KiB
JavaScript

// 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";
// const assert = chai.assert;
// const log = (msg) => { if (process.env.MOCHA_VERBOSE) console.log(msg); };
// describe("Poseidon Smart contract test", function () {
// let testrpc;
// let web3;
// let poseidon6;
// let poseidon3;
// let poseidon;
// let account;
// this.timeout(100000);
// before(async () => {
// const provider = new ethers.providers.Web3Provider(ganache.provider());
// account = provider.getSigner(0);
// poseidon = await buildPoseidon();
// });
// 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
// );
// poseidon6 = await C6.deploy();
// poseidon3 = await C3.deploy();
// });
// it("Should calculate the poseidon correctly t=6", async () => {
// const res = await poseidon6["poseidon(uint256[5])"]([1,2, 0, 0, 0]);
// // console.log("Cir: " + bigInt(res.toString(16)).toString(16));
// const res2 = poseidon([1,2, 0, 0, 0]);
// // console.log("Ref: " + bigInt(res2).toString(16));
// assert.equal(res.toString(), poseidon.F.toString(res2));
// });
// it("Should calculate the poseidon correctly t=3", async () => {
// const res = await poseidon3["poseidon(uint256[2])"]([1,2]);
// // console.log("Cir: " + bigInt(res.toString(16)).toString(16));
// const res2 = poseidon([1,2]);
// // console.log("Ref: " + bigInt(res2).toString(16));
// assert.equal(res.toString(), poseidon.F.toString(res2));
// });
// });