Skip to content

Commit d2146a2

Browse files
authored
Merge pull request #34 from 0xPolygonID/feature/pipeline-for-unit-tests
pipeline to run unit tests
2 parents e69da94 + c43303c commit d2146a2

File tree

6 files changed

+118
-24
lines changed

6 files changed

+118
-24
lines changed

.github/workflows/unit-test.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Unit Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Update git submodules
17+
run: git submodule update --init
18+
19+
# It is hard to build circom-witnesscalc on GitHub Actions
20+
# so we are waiting for prebuilt binaries to be available
21+
# - name: Install Rust
22+
# uses: actions-rs/toolchain@v1
23+
# with:
24+
# toolchain: stable
25+
# profile: minimal
26+
# override: true
27+
28+
# - name: Build circom-witnesscalc
29+
# run: |
30+
# cd ./circom-witnesscalc
31+
# cargo build --release
32+
33+
- name: Set up Node.js
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: 20.16.0
37+
38+
- name: Install circom 2.1.9
39+
run: |
40+
wget https://github.com/iden3/circom/releases/download/v2.1.9/circom-linux-amd64 -O /usr/local/bin/circom
41+
chmod +x /usr/local/bin/circom
42+
43+
- name: Install pnpm
44+
run: npm install -g pnpm
45+
46+
- name: Install dependencies
47+
run: pnpm install
48+
49+
- name: Run tests
50+
run: npm run test
51+
52+
# Waiting for prebuilt circom-witnesscalc to be available
53+
# - name: Download circuits
54+
# run: bash dl_circuits.sh
55+
56+
# - name: Integration Credential
57+
# run: npm run integration-credential
58+
59+
# - name: Integration AnonAadhaar
60+
# run: npm run integration-anonaadhaar

dl_circuits.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
VERSION="v1.0.2"
6+
BASE_URL="https://privadoid-passport-circuits.s3.eu-west-1.amazonaws.com/${VERSION}"
7+
CREDENTIAL_DIR="./build/credential"
8+
ANON_AADHAAR_DIR="./build/anonAadhaarV1"
9+
10+
# Create target directories
11+
mkdir -p "${CREDENTIAL_DIR}"
12+
mkdir -p "${ANON_AADHAAR_DIR}"
13+
14+
# List of credential circuit zips
15+
CREDENTIAL_ZIPS=(
16+
# "credential_sha1.zip"
17+
# "credential_sha224.zip"
18+
"credential_sha256.zip"
19+
# "credential_sha384.zip"
20+
# "credential_sha512.zip"
21+
)
22+
23+
# Download and unzip credential circuits
24+
for zip in "${CREDENTIAL_ZIPS[@]}"; do
25+
curl -L "${BASE_URL}/${zip}" -o "${CREDENTIAL_DIR}/${zip}"
26+
unzip -o "${CREDENTIAL_DIR}/${zip}" -d "${CREDENTIAL_DIR}"
27+
rm "${CREDENTIAL_DIR}/${zip}"
28+
done
29+
30+
# Download and unzip anonAadhaarV1 circuit
31+
curl -L "${BASE_URL}/anonAadhaarV1.zip" -o "${ANON_AADHAAR_DIR}/anonAadhaarV1.zip"
32+
unzip -o "${ANON_AADHAAR_DIR}/anonAadhaarV1.zip" -d "${ANON_AADHAAR_DIR}"
33+
rm "${ANON_AADHAAR_DIR}/anonAadhaarV1.zip"
34+

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"main": "index.js",
55
"scripts": {
66
"test": "npm run test-credential && npm run test-anonaadhaar",
7-
"test-credential": "FULL_TEST_SUITE=true npx ts-mocha --max-old-space-size=40960 'tests/credential/*.test.ts' --exit",
7+
"test-credential": "FULL_TEST_SUITE=false npx ts-mocha --max-old-space-size=40960 'tests/credential/*.test.ts' --exit",
88
"test-anonaadhaar": "npx ts-mocha --max-old-space-size=40960 'tests/anonaadhaar/*.test.ts' --exit",
99
"test-utils": "npx ts-mocha --max-old-space-size=40960 'tests/utils/*.test.ts' --exit",
1010
"build-all": "bash scripts/build/build_credential_circuit.sh",
@@ -38,7 +38,7 @@
3838
"typescript": "^5.8.2"
3939
},
4040
"dependencies": {
41-
"@anon-aadhaar/core": "^2.4.3",
41+
"@anon-aadhaar/core": "2.4.3",
4242
"@iden3/js-crypto": "^1.3.0",
4343
"@openpassport/zk-kit-imt": "^0.0.5",
4444
"@openpassport/zk-kit-lean-imt": "^0.0.6",

scripts/integration/anonAadhaarV1/anonAadhaarV1.integration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ describe(`anonAadhaarV1`, function () {
4141
inputs = jsonInputs;
4242
circuitName = `anonAadhaarV1`;
4343
witness_calculator = `./circom-witnesscalc/target/release/calc-witness`;
44-
circuit_graph_path = `./build/${circuitName}/${circuitName}/${circuitName}_graph.wcd`;
44+
circuit_graph_path = `./build/${circuitName}/${circuitName}/${circuitName}.wcd`;
4545
input_path = `./build/${circuitName}/${circuitName}/input.json`;
4646
witnes_path = `./build/${circuitName}/${circuitName}/output.wtns`;
47-
zkey_path = `./build/${circuitName}/${circuitName}/${circuitName}_final.zkey`;
47+
zkey_path = `./build/${circuitName}/${circuitName}/${circuitName}.zkey`;
4848
v_key = `./build/${circuitName}/${circuitName}/${circuitName}_vkey.json`;
4949
});
5050

scripts/integration/credential/credential.integration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ testSuite.forEach(({ shaAlg }) => {
5858
inputs = await generateCircuitInputsCredential(passportData);
5959
circuitName = `credential_${shaAlg}`;
6060
witness_calculator = `./circom-witnesscalc/target/release/calc-witness`;
61-
circuit_graph_path = `./build/credential/${circuitName}/${circuitName}_graph.wcd`;
61+
circuit_graph_path = `./build/credential/${circuitName}/${circuitName}.wcd`;
6262
input_path = `./build/credential/${circuitName}/input.json`;
6363
witnes_path = `./build/credential/${circuitName}/output.wtns`;
64-
zkey_path = `./build/credential/${circuitName}/${circuitName}_final.zkey`;
64+
zkey_path = `./build/credential/${circuitName}/${circuitName}.zkey`;
6565
v_key = `./build/credential/${circuitName}/${circuitName}_vkey.json`;
6666
});
6767

yarn.lock

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# yarn lockfile v1
33

44

5-
"@anon-aadhaar/core@^2.4.3":
5+
"@anon-aadhaar/core@2.4.3":
66
version "2.4.3"
77
resolved "https://registry.yarnpkg.com/@anon-aadhaar/core/-/core-2.4.3.tgz#e31f372565d055047a13154dac3d02903e97097d"
88
integrity sha512-KSbgUx6DjqKuAz+LUgIvddoAdKrYw+KFE8kcdHWtVGdYza0W2M0Ip9v9TnO1D9g/I7XK+trebmK/fNjMLtXBNA==
@@ -412,11 +412,11 @@
412412
ffjavascript "^0.3.0"
413413

414414
"@iden3/js-crypto@^1.3.0":
415-
version "1.3.0"
416-
resolved "https://registry.yarnpkg.com/@iden3/js-crypto/-/js-crypto-1.3.0.tgz#948d73df3d69542517e7738cd7980eedcdcef9f8"
417-
integrity sha512-kU0Omlm6P0O0MXGYE2ejTP+bgMMNzam7OfJbGbyu0NgfPag+6LThISmm8JYSc7VsoXtEVgC4s3zxg3hOenX0tA==
415+
version "1.3.1"
416+
resolved "https://registry.yarnpkg.com/@iden3/js-crypto/-/js-crypto-1.3.1.tgz#db95784c8cadeca30888d0c8f73dfe124d4843c9"
417+
integrity sha512-zZefKE2+GpEMPPMPDKqNBIvKZH8ubs/+nwOx2+rRZj+gSI1P49e9Nz6vGb/4YGTTHdPU2/L4lReQ5p/bF23c6A==
418418
dependencies:
419-
"@noble/hashes" "^1.7.1"
419+
"@noble/hashes" "^1.8.0"
420420

421421
"@jridgewell/resolve-uri@^3.0.3":
422422
version "3.1.2"
@@ -436,7 +436,7 @@
436436
"@jridgewell/resolve-uri" "^3.0.3"
437437
"@jridgewell/sourcemap-codec" "^1.4.10"
438438

439-
"@noble/hashes@^1.4.0", "@noble/hashes@^1.7.1":
439+
"@noble/hashes@^1.4.0", "@noble/hashes@^1.8.0":
440440
version "1.8.0"
441441
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.8.0.tgz#cee43d801fcef9644b11b8194857695acd5f815a"
442442
integrity sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==
@@ -513,9 +513,9 @@
513513
"@types/chai" "*"
514514

515515
"@types/chai@*":
516-
version "5.2.1"
517-
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-5.2.1.tgz#85687a58b27eac736ec0e87e5cb98f21e57a0bb1"
518-
integrity sha512-iu1JLYmGmITRzUgNiLMZD3WCoFzpYtueuyAgHTXqgwSRAMIlFTnZqG6/xenkpUGRJEzSfklUTI4GNSzks/dc0w==
516+
version "5.2.2"
517+
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-5.2.2.tgz#6f14cea18180ffc4416bc0fd12be05fdd73bdd6b"
518+
integrity sha512-8kB30R7Hwqf40JPiKhVzodJs2Qc1ZJ5zuT3uzw5Hq/dhNCl3G3l83jfpdI1e20BP348+fV7VIL/+FxaXkqBmWg==
519519
dependencies:
520520
"@types/deep-eql" "*"
521521

@@ -552,9 +552,9 @@
552552
"@types/node" "*"
553553

554554
"@types/node@*", "@types/node@^22.13.10":
555-
version "22.15.3"
556-
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.15.3.tgz#b7fb9396a8ec5b5dfb1345d8ac2502060e9af68b"
557-
integrity sha512-lX7HFZeHf4QG/J7tBZqrCAXwz9J5RD56Y6MpP0eJkka8p+K0RY/yBTW7CYFJ4VGCclxqOLKmiGP5juQc6MKgcw==
555+
version "22.15.21"
556+
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.15.21.tgz#196ef14fe20d87f7caf1e7b39832767f9a995b77"
557+
integrity sha512-EV/37Td6c+MgKAbkcLG6vqZ2zEYHD7bvSrzqqs2RIhbA6w3x+Dqz8MZM3sP6kGTeLrdoOgKZe+Xja7tUB2DNkQ==
558558
dependencies:
559559
undici-types "~6.21.0"
560560

@@ -1096,9 +1096,9 @@ csstype@3.1.3:
10961096
integrity sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==
10971097

10981098
debug@^4.3.5:
1099-
version "4.4.0"
1100-
resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.0.tgz#2b3f2aea2ffeb776477460267377dc8710faba8a"
1101-
integrity sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==
1099+
version "4.4.1"
1100+
resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.1.tgz#e5a8bc6cbc4c6cd3e64308b0693a3d4fa550189b"
1101+
integrity sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==
11021102
dependencies:
11031103
ms "^2.1.3"
11041104

@@ -2290,9 +2290,9 @@ strip-json-comments@^3.1.1:
22902290
integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==
22912291

22922292
styled-components@^6.0.0-rc.1:
2293-
version "6.1.17"
2294-
resolved "https://registry.yarnpkg.com/styled-components/-/styled-components-6.1.17.tgz#59032edd7efa59e114ddbc41165f0984d0fa4fb7"
2295-
integrity sha512-97D7DwWanI7nN24v0D4SvbfjLE9656umNSJZkBkDIWL37aZqG/wRQ+Y9pWtXyBIM/NSfcBzHLErEsqHmJNSVUg==
2293+
version "6.1.18"
2294+
resolved "https://registry.yarnpkg.com/styled-components/-/styled-components-6.1.18.tgz#9647497a92326ba9d758051c914f15004d524bb9"
2295+
integrity sha512-Mvf3gJFzZCkhjY2Y/Fx9z1m3dxbza0uI9H1CbNZm/jSHCojzJhQ0R7bByrlFJINnMzz/gPulpoFFGymNwrsMcw==
22962296
dependencies:
22972297
"@emotion/is-prop-valid" "1.2.2"
22982298
"@emotion/unitless" "0.8.1"

0 commit comments

Comments
 (0)