Skip to content

Commit

Permalink
fix: change from pnpm to npm for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rpalakkal committed Nov 28, 2023
1 parent 5630d70 commit 8af1e62
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/halo2-browser-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:
runs-on: ubuntu-latest-64core-256ram
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Build halo2-wasm
working-directory: halo2-wasm
run: |
Expand All @@ -32,14 +35,12 @@ jobs:
- name: Build halo2-lib-js
working-directory: halo2-lib-js
run: |
pnpm install
pnpm add @axiom-crypto/halo2-wasm-cli
npm install
npm add @axiom-crypto/halo2-wasm-cli
- name: Test halo2-lib-js/halo2-wasm VK equivalence
working-directory: halo2-lib-js
run: |
pnpm run test:vk
run: npm run test:vk
- name: Test halo2-lib-js constant equivalence
working-directory: halo2-lib-js
run: |
pnpm run test:constant
run: npm run test:constant

15 changes: 8 additions & 7 deletions halo2-lib-js/tests/test_constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ def camel_to_snake(name):
circuit_dir = os.path.join(script_dir, 'circuits')
vk_dir = os.path.join(script_dir, 'data')

def replace_text_in_file(file_path, out_path):
def replace_text_in_file(file_path):
with open(file_path, 'r') as file:
file_data = file.read()

file_data = re.sub(r'constant\((.*?)\)', r'\1', file_data)
with open(out_path, 'w') as file:
with open(file_path, 'w') as file:
file.write(file_data)

def test_constant(filename):
Expand All @@ -25,12 +25,13 @@ def test_constant(filename):
test_name = camel_to_snake(filename.split('.')[0])
if "constant" in filename:
return None
const_file_path = os.path.join(circuit_dir, "constant." + filename)
replace_text_in_file(file_path, const_file_path)
replace_text_in_file(file_path)
test_type = filename.split('.')[-2]
rust_test = "tests::" + test_type + "::test_" + test_name
print("Testing " + test_name)
subprocess.run(["pnpm", 'halo2-wasm', 'keygen', file_path, "-c", "./tests/run.ts"], capture_output=True)
subprocess.run(["pnpm", 'halo2-wasm', 'keygen', const_file_path, "-c", "./tests/run.ts", "-vk", "./data/const_vk.bin"], capture_output=True)
result = subprocess.run(['diff', './data/vk.bin', './data/const_vk.bin'], capture_output=True)
subprocess.run(["npx", 'halo2-wasm', 'keygen', file_path, "-c", "./tests/run.ts"], capture_output=True)
subprocess.run(['cargo', 'test', rust_test, "--quiet", "--", "--exact"], capture_output=True)
result = subprocess.run(['diff', './data/vk.bin', '../halo2-wasm/vk.bin'], capture_output=True)
if result.returncode != 0:
return (test_name, False)
return (test_name, True)
Expand Down
4 changes: 2 additions & 2 deletions halo2-lib-js/tests/test_constant.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
rm -rf tests/circuits
mkdir tests/circuits
pnpm ts-node tests/range.ts
pnpm ts-node tests/gate.ts
npx ts-node tests/range.ts
npx ts-node tests/gate.ts
python3 tests/test_constant.py
2 changes: 1 addition & 1 deletion halo2-lib-js/tests/test_vk.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_vk(filename):
test_type = filename.split('.')[-2]
rust_test = "tests::" + test_type + "::test_" + test_name
print("Testing " + test_name)
subprocess.run(["pnpm", 'halo2-wasm', 'keygen', file_path, "-c", "./tests/run.ts"], capture_output=True)
subprocess.run(["npx", 'halo2-wasm', 'keygen', file_path, "-c", "./tests/run.ts"], capture_output=True)
subprocess.run(['cargo', 'test', rust_test, "--quiet", "--", "--exact"], capture_output=True)
result = subprocess.run(['diff', './data/vk.bin', '../halo2-wasm/vk.bin'], capture_output=True)
if result.returncode != 0:
Expand Down
4 changes: 2 additions & 2 deletions halo2-lib-js/tests/test_vk.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
rm -rf tests/circuits
mkdir tests/circuits
pnpm ts-node tests/range.ts
pnpm ts-node tests/gate.ts
npx ts-node tests/range.ts
npx ts-node tests/gate.ts
python3 tests/test_vk.py

0 comments on commit 8af1e62

Please sign in to comment.