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.2 KiB

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