Skip to content

Commit

Permalink
fix: merkle tree js tests
Browse files Browse the repository at this point in the history
  • Loading branch information
olivmath committed Feb 1, 2024
1 parent b305102 commit 0b843e6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ repos:
hooks:
- id: pytest
name: Unit Tests (Pytest)
entry: pytest -m "not benchmark and not merkletreejs"
entry: pytest -m "not benchmark"
language: system
pass_filenames: false
always_run: true
Expand Down
7 changes: 7 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ def compile_rust_ffi(request):
if any("ffi" in item.keywords for item in request.session.items):
print("Compiling Rust FFI")
subprocess.run(["./build.sh"], cwd="./merkly/accelerator", check=True)

Check notice

Code scanning / Bandit

subprocess call - check for execution of untrusted input. Note test

subprocess call - check for execution of untrusted input.


@fixture(scope="session", autouse=True)
def install_js_deps(request):
if any("merkletreejs" in item.keywords for item in request.session.items):
print("Install js dependencies")
subprocess.run(["yarn"], cwd="./test/merkletreejs", check=True)

Check notice

Code scanning / Bandit

Starting a process with a partial executable path Note test

Starting a process with a partial executable path

Check notice

Code scanning / Bandit

subprocess call - check for execution of untrusted input. Note test

subprocess call - check for execution of untrusted input.
5 changes: 3 additions & 2 deletions test/merkletreejs/test_merkle_proof_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@


@mark.merkletreejs
def test_merkle_proof_compatibility_between_merkletreejs_and_merkly():
def test_merkle_proof_compatibility_between_merkletreejs_and_merkly(install_js_deps):
result = subprocess.run(["yarn"], check=False)

assert result.returncode == 0, result.stderr

result_js = subprocess.run(
["node", "./test/merkletreejs/merkle_proof/merkle_proof_test.js"],
["node", "./merkle_proof/merkle_proof_test.js"],
capture_output=True,
cwd="./test/merkletreejs",
text=True,
check=True,
)
Expand Down
7 changes: 5 additions & 2 deletions test/merkletreejs/test_merkle_proof_verify_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@


@mark.merkletreejs
def test_merkle_proof_verify_compatibility_between_merkletreejs_and_merkly():
def test_merkle_proof_verify_compatibility_between_merkletreejs_and_merkly(
install_js_deps,
):
result = subprocess.run(["yarn"], check=False)

assert result.returncode == 0, result.stderr

result_js = subprocess.run(
["node", "./test/merkletreejs/merkle_proof/merkle_proof_test.js"],
["node", "./merkle_proof/merkle_proof_test.js"],
cwd="./test/merkletreejs",
capture_output=True,
text=True,
check=True,
Expand Down
5 changes: 3 additions & 2 deletions test/merkletreejs/test_merkle_root_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@


@mark.merkletreejs
def test_merkle_root_compatibility_between_merkletreejs_and_merkly():
def test_merkle_root_compatibility_between_merkletreejs_and_merkly(install_js_deps):
result = subprocess.run(["yarn"], check=False)

assert result.returncode == 0, result.stderr

result_js = subprocess.run(
["node", "./test/merkletreejs/merkle_root/merkle_root_test.js"],
["node", "./merkle_root/merkle_root_test.js"],
cwd="./test/merkletreejs",
capture_output=True,
text=True,
check=False,
Expand Down

0 comments on commit 0b843e6

Please sign in to comment.