circom/test/cases.js
test/cases.jsRaw
1const chai = require("chai");
2const path = require("path");
3const snarkjs = require("snarkjs");
4
5const bigInt = snarkjs.bigInt;
6
7const compiler = require("../index.js");
8
9const assert = chai.assert;
10
11describe("Sum test", () => {
12 it("Should compile a code with an undefined if", async () => {
13 await compiler(path.join(__dirname, "circuits", "undefinedif.circom"));
14 });
15 it("Should compile a code with vars inside a for", async () => {
16 const cirDef = await compiler(path.join(__dirname, "circuits", "forvariables.circom"));
17
18 const circuit = new snarkjs.Circuit(cirDef);
19
20 const witness = circuit.calculateWitness({ "in": 111});
21 assert(witness[0].equals(bigInt(1)));
22 assert(witness[1].equals(bigInt(114)));
23 assert(witness[2].equals(bigInt(111)));
24
25 });
26 it("Should compile a code with an undefined if", async () => {
27 const cirDef = await compiler(path.join(__dirname, "circuits", "mixvarsignal.circom"));
28
29 const circuit = new snarkjs.Circuit(cirDef);
30
31 const witness = circuit.calculateWitness({ "i": 111});
32 assert(witness[0].equals(bigInt(1)));
33 assert(witness[1].equals(bigInt(111)));
34 assert(witness[2].equals(bigInt(111)));
35 });
36});