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

  1. const chai = require("chai");
  2. const path = require("path");
  3. const tester = require("circom").tester;
  4. const bigInt = require("big-integer");
  5. const assert = chai.assert;
  6. describe("Sum test", function () {
  7. this.timeout(100000000);
  8. it("Should create a constant circuit", async () => {
  9. const circuit = await tester(path.join(__dirname, "circuits", "constants_test.circom"));
  10. await circuit.loadConstraints();
  11. assert.equal(circuit.nWires, 2);
  12. const witness = await circuit.calculateWitness({ "in": bigInt("d807aa98", 16)});
  13. assert(witness[0].equals(bigInt(1)));
  14. assert(witness[1].equals(bigInt("d807aa98", 16)));
  15. });
  16. it("Should create a sum circuit", async () => {
  17. const circuit = await tester(path.join(__dirname, "circuits", "sum_test.circom"));
  18. await circuit.loadConstraints();
  19. assert.equal(circuit.nWires, 97); // 32 (in1) + 32(in2) + 32(out) + 1 (carry)
  20. const witness = await circuit.calculateWitness({ "a": "111", "b": "222" });
  21. assert(witness[0].equals(bigInt(1)));
  22. assert(witness[1].equals(bigInt("333")));
  23. });
  24. });