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.

37 lines
1.0 KiB

  1. const path = require("path");
  2. const tester = require("circom").tester;
  3. const chai = require("chai");
  4. const assert = chai.assert;
  5. const circomlib = require("circomlib");
  6. export {};
  7. describe("withdraw test", function () {
  8. this.timeout(200000);
  9. it("Test Withdraw", async () => {
  10. const circuit = await tester(
  11. path.join(__dirname, "../../circuits", "withdraw.circom"),
  12. {reduceConstraints: false}
  13. );
  14. // const secret = Math.floor(Math.random()*1000).toString();
  15. const secret = "123456789";
  16. const coinCode = "1";
  17. const amount = "100";
  18. const poseidon = circomlib.poseidon.createHash(6, 8, 57);
  19. const commitment = poseidon([coinCode, amount, secret]).toString();
  20. const witness = await circuit.calculateWitness({
  21. "coinCode": coinCode,
  22. "amount": amount,
  23. "commitment": commitment,
  24. "secret": secret,
  25. "address": "987654321"
  26. });
  27. await circuit.checkConstraints(witness);
  28. });
  29. });