You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

36 lines
1.1 KiB

const chai = require("chai");
const path = require("path");
const tester = require("circom").tester;
const bigInt = require("big-integer");
const assert = chai.assert;
describe("Sum test", function () {
this.timeout(100000);
it("Should create a constant circuit", async () => {
const circuit = await tester(path.join(__dirname, "circuits", "constants_test.circom"));
// TODO
// assert.equal(cirDef.nVars, 2);
const witness = await circuit.calculateWitness({ "in": bigInt("d807aa98", 16)});
assert(witness[0].equals(bigInt(1)));
assert(witness[1].equals(bigInt("d807aa98", 16)));
});
it("Should create a sum circuit", async () => {
const circuit = await tester(path.join(__dirname, "circuits", "sum_test.circom"));
// TODO
// assert.equal(cirDef.nVars, 97); // 32 (in1) + 32(in2) + 32(out) + 1 (carry)
const witness = await circuit.calculateWitness({ "a": "111", "b": "222" });
assert(witness[0].equals(bigInt(1)));
assert(witness[1].equals(bigInt("333")));
});
});