Skip to content

Commit

Permalink
Refactor fflonk test (#336)
Browse files Browse the repository at this point in the history
* fflonk files test moved

* fflonk SC verification added to test suite

* add again length proof check to smart contract

* fix tests.yml for continous integration

* add hardhat dependencies to github action

* add more options to launch.json file

* remove hardhat-toolbox

* add missed packages

* skip smart contract testing in node version < 14

* fix smart contract tests

* fix typo and move variables inside function

* add plonk&groth16 smart contract tests

* add setup and prove on smart contracts tests
  • Loading branch information
xavi-pinsach authored Mar 22, 2023
1 parent 614c350 commit 96b7d27
Show file tree
Hide file tree
Showing 26 changed files with 14,569 additions and 2,544 deletions.
36 changes: 35 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
node-version: [ "12", "14", "16", "18" ]
node-version: [ "14", "16", "18" ]

steps:
- name: Checkout project
Expand All @@ -29,5 +29,39 @@ jobs:
- name: Install dependencies
run: npm ci

# Install hardhat dependencies for smart contracts tests
- name: Install hardhat dependencies
run: npm install hardhat @nomiclabs/hardhat-ethers @nomiclabs/hardhat-waffle

- name: Run tests
run: npm run test

testv12:
name: Testv12
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
node-version: [ "12" ]

steps:
- name: Checkout project
uses: actions/checkout@v2

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
check-latest: true
cache: 'npm'

- name: Install circom
run: npm install -g circom@latest

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm run testv12
154 changes: 130 additions & 24 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Attach",
"port": 9229,
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node"
},
{
"type": "pwa-node",
"name": "Attach",
"port": 9229,
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
},
{
"type": "node",
"request": "launch",
"name": "plonk setup",
"skipFiles": [
Expand All @@ -24,12 +24,12 @@
"args": [
"pks",
"test/plonk_circuit/circuit.r1cs",
"test/plonk_circuit/powersOfTau15_final.ptau",
"test/plonk_circuit/powersOfTau15_final.ptau",
"test/plonk_circuit/circuit.zkey"
]
},
{
"type": "pwa-node",
"type": "node",
"request": "launch",
"name": "plonk prove",
"skipFiles": [
Expand All @@ -39,14 +39,14 @@
"args": [
"pkp",
"test/plonk_circuit/circuit.zkey",
"test/plonk_circuit/witness.wtns",
"test/plonk_circuit/witness.wtns",
"test/plonk_circuit/proof.json",
"test/plonk_circuit/public.json",
"-v"
]
},
{
"type": "pwa-node",
"type": "node",
"request": "launch",
"name": "plonk export vk",
"skipFiles": [
Expand All @@ -60,7 +60,7 @@
]
},
{
"type": "pwa-node",
"type": "node",
"request": "launch",
"name": "plonk verify",
"skipFiles": [
Expand All @@ -76,7 +76,7 @@
]
},
{
"type": "pwa-node",
"type": "node",
"request": "launch",
"name": "export solidity calldata",
"skipFiles": [
Expand All @@ -90,7 +90,7 @@
]
},
{
"type": "pwa-node",
"type": "node",
"request": "launch",
"name": "export solidity verifier",
"skipFiles": [
Expand All @@ -103,13 +103,119 @@
"test/plonk_circuit/verifier.sol",
]
},
{
"type": "node",
"request": "launch",
"name": "Mocha all tests",
{
"type": "node",
"request": "launch",
"name": "Mocha all tests",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"cwd": "${workspaceRoot}",
"internalConsoleOptions": "openOnSessionStart"
}
"cwd": "${workspaceRoot}",
"internalConsoleOptions": "openOnSessionStart"
},
{
"type": "node",
"request": "launch",
"name": "fflonk setup",
"skipFiles": [
"<node_internals>/**"
],
"program": "cli.js",
"args": [
"fflonk",
"setup",
"test/fflonk/circuit.r1cs",
"test/plonk_circuit/powersOfTau15_final.ptau",
"test/fflonk/circuit.zkey"
]
},
{
"type": "node",
"request": "launch",
"name": "fflonk prove",
"skipFiles": [
"<node_internals>/**"
],
"program": "cli.js",
"args": [
"fflonk",
"prove",
"test/fflonk/circuit.zkey",
"test/fflonk/witness.wtns",
"test/fflonk/proof.json",
"test/fflonk/public.json"
]
},
{
"type": "node",
"request": "launch",
"name": "fflonk export vkey",
"skipFiles": [
"<node_internals>/**"
],
"program": "cli.js",
"args": [
"zkev",
"test/fflonk/circuit.zkey",
"test/fflonk/circuit_vk.json",
]
},
{
"type": "node",
"request": "launch",
"name": "fflonk verify",
"skipFiles": [
"<node_internals>/**"
],
"program": "cli.js",
"args": [
"fflonk",
"verify",
"test/fflonk/circuit_vk.json",
"test/fflonk/public.json",
"test/fflonk/proof.json"
]
},
{
"type": "node",
"request": "launch",
"name": "fflonk export call data",
"skipFiles": [
"<node_internals>/**"
],
"program": "cli.js",
"args": [
"zkesc",
"test/fflonk/public.json",
"test/fflonk/proof.json"
]
},
{
"type": "node",
"request": "launch",
"name": "fflonk export SC",
"skipFiles": [
"<node_internals>/**"
],
"program": "cli.js",
"args": [
"zkesv",
"test/fflonk/circuit.zkey",
"test/fflonk/verifier.sol"
]
},
{
"type": "node",
"request": "launch",
"name": "wtns check",
"skipFiles": [
"<node_internals>/**"
],
"program": "cli.js",
"args": [
"wtns",
"check",
"test/fflonk/circuit.r1cs",
"test/fflonk/witness.wtns",
]
},
]
}
39 changes: 39 additions & 0 deletions hardhat.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
require("@nomiclabs/hardhat-waffle");

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: {
compilers: [
{
version: "0.8.17",
settings: {
optimizer: {
enabled: true,
runs: 999999
}
}
},
{
version: "0.6.11",
settings: {
optimizer: {
enabled: true,
runs: 999999
}
}
},
]
},
paths: {
sources: "./test/smart_contracts/contracts",
tests: "./test",
cache: "./test/smart_contracts/cache",
artifacts: "./test/smart_contracts/artifacts"
},
// gasReporter: {
// enabled: !!process.env.REPORT_GAS,
// outputFile: process.env.REPORT_GAS_FILE ? "./gas_report.md" : null,
// noColors: process.env.REPORT_GAS_FILE ? true : false
// },

};
1 change: 1 addition & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export * as wtns from "./src/wtns.js";
export * as wtnsCmds from "./src/cmds/wtns_cmds.js";
export * as zKey from "./src/zkey.js";
export * as plonk from "./src/plonk.js";
export * as fflonk from "./src/cmds/fflonk_cmds.js";
Loading

0 comments on commit 96b7d27

Please sign in to comment.