Skip to content

Commit

Permalink
Update test4.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
chyanju committed Feb 28, 2024
1 parent 1b4bc76 commit 825b9f5
Showing 1 changed file with 26 additions and 122 deletions.
148 changes: 26 additions & 122 deletions tests/test4.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@
"metadata": {},
"outputs": [],
"source": [
"from vanguard.aleo.common import aleo2json, simplify_json\n",
"from vanguard.aleo.grammar import AleoProgram, AleoEnvironment\n",
"# from vanguard.aleo.detectors.infoleak import detector_infoleak\n",
"from vanguard.aleo.detectors.infoleak import detector_infoleak\n",
"from vanguard.aleo.detectors.rtcnst import detector_rtcnst\n",
"# from vanguard.aleo.detectors.unused import detector_unused\n",
"from vanguard.aleo.detectors.divz import detector_divz\n",
"from vanguard.aleo.detectors.divrd import detector_divrd\n",
"# from vanguard.aleo.testing import run_test_suite"
"from vanguard.aleo.detectors.unused import detector_unused\n",
"from vanguard.aleo.detectors.divz import detector_divz"
]
},
{
Expand All @@ -48,151 +45,58 @@
],
"source": [
"project_name = \"divz0\"\n",
"# project_name = \"infoleak0\"\n",
"# project_name = \"unused0\"\n",
"# project_name = \"rtcnst0\"\n",
"build_path = f\"./tests/public/{project_name}/build/\"\n",
"env = AleoEnvironment(build_path)\n",
"main_id = env.main_id"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "0dc6fcff-f8b2-44cb-8919-fda9b23c0b49",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"# [debug] inst: ['call', ['locator', ['program_id', ['program_name', 'helpers'], ['program_domain', 'aleo']], 'division'], ['unsigned_literal', 224, ['unsigned_type', 'u8']], ['unsigned_literal', 0, ['unsigned_type', 'u8']], 'into', ['register_access', 'r0']]\n",
"# [debug] inst: ['div', ['register_access', 'r0'], ['register_access', 'r1'], ['register_access', 'r2']]\n"
]
},
{
"data": {
"text/plain": [
"(True,\n",
" [['div',\n",
" ['register_access', 'r0'],\n",
" ['register_access', 'r1'],\n",
" ['register_access', 'r2']]])"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fid = \"ex25\"\n",
"detector_divz(env, main_id, fid)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "2f672f73-2b39-4889-bf87-fbf646487e47",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"dict_keys(['a', 'b'])"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"env.programs[main_id].structs[\"struct_ex16\"]"
"main = env.main"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c76ce9b9-7725-4b54-ab9b-9bda3060ea35",
"id": "7e7f213c-e3da-4042-9207-867305d7b5e2",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "b7584813-9f19-4b80-8869-a68a6a293dab",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 3,
"id": "5645605b-7ba2-462c-a263-e78342045dc0",
"execution_count": 9,
"id": "0dc6fcff-f8b2-44cb-8919-fda9b23c0b49",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"# [debug] deploy: main.aleo\n"
"ename": "KeyError",
"evalue": "'ex26'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[9], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m fid \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mex26\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m----> 2\u001b[0m \u001b[43mdetector_divz\u001b[49m\u001b[43m(\u001b[49m\u001b[43menv\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmain\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mid\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfid\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mreadable\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m~/Desktop/UCSB/24winter/vanguard-aleo/vanguard/aleo/detectors/divz.py:158\u001b[0m, in \u001b[0;36mdetector_divz\u001b[0;34m(env, pid, fid, readable)\u001b[0m\n\u001b[1;32m 155\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mdetector_divz\u001b[39m(env: AleoEnvironment, pid: \u001b[38;5;28mstr\u001b[39m, fid: \u001b[38;5;28mstr\u001b[39m, readable\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m):\n\u001b[1;32m 156\u001b[0m \u001b[38;5;66;03m# initialize\u001b[39;00m\n\u001b[1;32m 157\u001b[0m prog: AleoProgram \u001b[38;5;241m=\u001b[39m env\u001b[38;5;241m.\u001b[39mprograms[pid]\n\u001b[0;32m--> 158\u001b[0m func: AleoFunction \u001b[38;5;241m=\u001b[39m \u001b[43mprog\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfunctions\u001b[49m\u001b[43m[\u001b[49m\u001b[43mfid\u001b[49m\u001b[43m]\u001b[49m\n\u001b[1;32m 160\u001b[0m \u001b[38;5;66;03m# store problematic instructions\u001b[39;00m\n\u001b[1;32m 161\u001b[0m lines \u001b[38;5;241m=\u001b[39m []\n",
"\u001b[0;31mKeyError\u001b[0m: 'ex26'"
]
}
],
"source": [
"project_name = \"rtcnst0\"\n",
"build_path = f\"./tests/public/{project_name}/build/\"\n",
"env = AleoEnvironment(build_path)\n",
"main_id = env.main_id"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "3c44bffb-6667-494c-ae7a-afd8c0f548f5",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(False, [])"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fid = \"ex1\"\n",
"detector_rtcnst(env, main_id, fid)"
"fid = \"ex26\"\n",
"detector_divz(env, main.id, fid, readable=True)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "4540b0ba-c3c3-4fd0-97ae-733801807665",
"execution_count": null,
"id": "e895857f-8473-4e0e-a561-3553469ceceb",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[(['unsigned_literal', 0, ['unsigned_type', 'u8']],\n",
" ['value_type', ['unsigned_type', 'u8'], '.private'])]"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"env.programs[main_id].functions[\"ex0\"][\"outputs\"]"
]
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "b24a0c19-176f-49e6-955a-0304b6c94379",
"id": "a983f9b5-286c-4748-b2c7-b450ff0d7948",
"metadata": {},
"outputs": [],
"source": []
Expand Down

0 comments on commit 825b9f5

Please sign in to comment.