Skip to content

Commit 5eed36e

Browse files
committed
Add test: whitebox_fuzzing
1 parent 46cd904 commit 5eed36e

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

applications/cybersecurity/whitebox_fuzzing/whitebox_fuzzing.ipynb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,9 @@
311311
" my_oracle(predicate=lambda q: my_predicate(x, y, q))\n",
312312
"\n",
313313
"\n",
314+
"MAX_WIDTH_ORACLE = 25\n",
314315
"qmod_oracle = create_model(main)\n",
315-
"qmod_oracle = set_constraints(qmod_oracle, max_width=25)\n",
316+
"qmod_oracle = set_constraints(qmod_oracle, max_width=MAX_WIDTH_ORACLE)\n",
316317
"qprog_oracle = synthesize(qmod_oracle)\n",
317318
"show(qprog_oracle)"
318319
]
@@ -527,7 +528,8 @@
527528
"metadata": {},
528529
"outputs": [],
529530
"source": [
530-
"qmod_grover = set_constraints(qmod_grover, max_width=25)\n",
531+
"MAX_WIDTH_GROVER = 25\n",
532+
"qmod_grover = set_constraints(qmod_grover, max_width=MAX_WIDTH_GROVER)\n",
531533
"write_qmod(qmod_grover, \"whitebox_fuzzing\")"
532534
]
533535
},
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from tests.utils_for_testbook import (
2+
validate_quantum_program_size,
3+
validate_quantum_model,
4+
wrap_testbook,
5+
)
6+
from testbook.client import TestbookNotebookClient
7+
8+
9+
@wrap_testbook("whitebox_fuzzing", timeout_seconds=720)
10+
def test_notebook(tb: TestbookNotebookClient) -> None:
11+
# test models
12+
validate_quantum_model(tb.ref("qmod_oracle"))
13+
validate_quantum_model(tb.ref("qmod_grover"))
14+
# test quantum programs
15+
validate_quantum_program_size(
16+
tb.ref("qprog_oracle"),
17+
expected_width=tb.ref("MAX_WIDTH_ORACLE"),
18+
expected_depth=700, # actual depth: 626
19+
)
20+
validate_quantum_program_size(
21+
tb.ref("qprog_grover"),
22+
expected_width=tb.ref("MAX_WIDTH_GROVER"),
23+
expected_depth=4500, # actual depth: 4044
24+
)
25+
26+
# test notebook content
27+
pass # Todo

0 commit comments

Comments
 (0)