circomlib/test/binsum.js
test/binsum.jsRaw
1const chai = require("chai");
2const path = require("path");
3
4const tester = require("circom").tester;
5
6const bigInt = require("big-integer");
7
8const assert = chai.assert;
9
10describe("Sum test", function () {
11
12 this.timeout(100000);
13
14 it("Should create a constant circuit", async () => {
15 const circuit = await tester(path.join(__dirname, "circuits", "constants_test.circom"));
16
17 // TODO
18 // assert.equal(cirDef.nVars, 2);
19
20 const witness = await circuit.calculateWitness({ "in": bigInt("d807aa98", 16)});
21
22 assert(witness[0].equals(bigInt(1)));
23 assert(witness[1].equals(bigInt("d807aa98", 16)));
24 });
25 it("Should create a sum circuit", async () => {
26 const circuit = await tester(path.join(__dirname, "circuits", "sum_test.circom"));
27
28 // TODO
29 // assert.equal(cirDef.nVars, 97); // 32 (in1) + 32(in2) + 32(out) + 1 (carry)
30
31 const witness = await circuit.calculateWitness({ "a": "111", "b": "222" });
32
33 assert(witness[0].equals(bigInt(1)));
34 assert(witness[1].equals(bigInt("333")));
35 });
36});