fc0c01e400
* 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.
28 lines
757 B
JavaScript
28 lines
757 B
JavaScript
import { describe, it, before } from 'node:test'
|
|
import assert from 'node:assert'
|
|
|
|
import buildPedersenHash from "../src/pedersen_hash.js";
|
|
|
|
function buff2hex(buff) {
|
|
function i2hex(i) {
|
|
return ('0' + i.toString(16)).slice(-2);
|
|
}
|
|
return Array.from(buff).map(i2hex).join('');
|
|
}
|
|
|
|
describe("Pedersen Hash test", function () {
|
|
let pedersen;
|
|
|
|
before(async () => {
|
|
pedersen = await buildPedersenHash();
|
|
});
|
|
|
|
it("Should check multihash reference 2", async () => {
|
|
const msg = (new TextEncoder()).encode("Hello");
|
|
|
|
const res2 = pedersen.hash(msg);
|
|
// console.log(buff2hex(res2));
|
|
assert.equal(buff2hex(res2), "0e90d7d613ab8b5ea7f4f8bc537db6bb0fa2e5e97bbac1c1f609ef9e6a35fd8b");
|
|
});
|
|
});
|