Skip to content

Commit

Permalink
test(wasm): avoid magic hash for testing WASM module uid
Browse files Browse the repository at this point in the history
  • Loading branch information
qartik committed Jan 22, 2024
1 parent f3e8b62 commit e42c997
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

# mypy: disable-error-code="misc"

import base64
import hashlib
import json
import logging
from pathlib import Path
Expand Down Expand Up @@ -111,15 +113,12 @@ def test_qasm_to_phir_with_wasm(self) -> None:

wasm_bytes = get_wat_as_wasm_bytes(WatFile.add)

wasm_uid = hashlib.sha256(base64.b64encode(wasm_bytes)).hexdigest()

phir_str = qasm_to_phir(qasm, QtmMachine.H1_1, wasm_bytes=wasm_bytes)
phir = json.loads(phir_str)

expected_metadata = {
"ff_object": (
"WASM module uid: 28c0194b91f1e24d6fc40ec480c026a5874661184"
"bcd411a61bd5d5383df5180"
)
}
expected_metadata = {"ff_object": (f"WASM module uid: {wasm_uid}")}

assert phir["ops"][21] == {
"metadata": expected_metadata,
Expand Down Expand Up @@ -158,12 +157,7 @@ def test_pytket_with_wasm(self) -> None:

phir = json.loads(phir_str)

expected_metadata = {
"ff_object": (
"WASM module uid: 3138ec2df84e13dcee5f3772555e93d4"
"3de8f2e2a0937770c5959bca2da4fb10"
)
}
expected_metadata = {"ff_object": (f"WASM module uid: {w!s}")}

assert phir["ops"][4] == {
"metadata": expected_metadata,
Expand Down

0 comments on commit e42c997

Please sign in to comment.