@@ -152,7 +152,8 @@ TEST_F(AvmExecutionTests, basicAddReturn)
152
152
" 00FF" ; // ret size offset 255
153
153
154
154
auto bytecode = hex_to_bytes (bytecode_hex);
155
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
155
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
156
+ ASSERT_TRUE (is_ok (error));
156
157
157
158
// 2 instructions
158
159
ASSERT_THAT (instructions, SizeIs (5 ));
@@ -214,7 +215,8 @@ TEST_F(AvmExecutionTests, setAndSubOpcodes)
214
215
" 00FF" ; // ret size offset 255
215
216
216
217
auto bytecode = hex_to_bytes (bytecode_hex);
217
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
218
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
219
+ ASSERT_TRUE (is_ok (error));
218
220
219
221
ASSERT_THAT (instructions, SizeIs (5 ));
220
222
@@ -295,7 +297,8 @@ TEST_F(AvmExecutionTests, powerWithMulOpcodes)
295
297
bytecode_hex.append (ret_hex);
296
298
297
299
auto bytecode = hex_to_bytes (bytecode_hex);
298
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
300
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
301
+ ASSERT_TRUE (is_ok (error));
299
302
300
303
ASSERT_THAT (instructions, SizeIs (16 ));
301
304
@@ -394,7 +397,8 @@ TEST_F(AvmExecutionTests, simpleInternalCall)
394
397
;
395
398
396
399
auto bytecode = hex_to_bytes (bytecode_hex);
397
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
400
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
401
+ ASSERT_TRUE (is_ok (error));
398
402
399
403
EXPECT_THAT (instructions, SizeIs (7 ));
400
404
@@ -475,7 +479,8 @@ TEST_F(AvmExecutionTests, nestedInternalCalls)
475
479
bytecode_f2 + bytecode_f1 + bytecode_g;
476
480
477
481
auto bytecode = hex_to_bytes (bytecode_hex);
478
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
482
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
483
+ ASSERT_TRUE (is_ok (error));
479
484
480
485
ASSERT_THAT (instructions, SizeIs (13 ));
481
486
@@ -555,7 +560,8 @@ TEST_F(AvmExecutionTests, jumpAndCalldatacopy)
555
560
;
556
561
557
562
auto bytecode = hex_to_bytes (bytecode_hex);
558
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
563
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
564
+ ASSERT_TRUE (is_ok (error));
559
565
560
566
ASSERT_THAT (instructions, SizeIs (8 ));
561
567
@@ -657,7 +663,8 @@ TEST_F(AvmExecutionTests, jumpiAndCalldatacopy)
657
663
;
658
664
659
665
auto bytecode = hex_to_bytes (bytecode_hex);
660
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
666
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
667
+ ASSERT_TRUE (is_ok (error));
661
668
662
669
ASSERT_THAT (instructions, SizeIs (9 ));
663
670
@@ -714,7 +721,8 @@ TEST_F(AvmExecutionTests, movOpcode)
714
721
" 00FF" ; // ret size offset 255
715
722
716
723
auto bytecode = hex_to_bytes (bytecode_hex);
717
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
724
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
725
+ ASSERT_TRUE (is_ok (error));
718
726
719
727
ASSERT_THAT (instructions, SizeIs (4 ));
720
728
@@ -773,7 +781,8 @@ TEST_F(AvmExecutionTests, indMovOpcode)
773
781
" 00FF" ; // ret size offset 255
774
782
775
783
auto bytecode = hex_to_bytes (bytecode_hex);
776
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
784
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
785
+ ASSERT_TRUE (is_ok (error));
777
786
778
787
ASSERT_THAT (instructions, SizeIs (6 ));
779
788
@@ -815,7 +824,8 @@ TEST_F(AvmExecutionTests, setAndCastOpcodes)
815
824
" 00FF" ; // ret size offset 255
816
825
817
826
auto bytecode = hex_to_bytes (bytecode_hex);
818
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
827
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
828
+ ASSERT_TRUE (is_ok (error));
819
829
820
830
ASSERT_THAT (instructions, SizeIs (4 ));
821
831
@@ -884,7 +894,8 @@ TEST_F(AvmExecutionTests, toRadixBeOpcodeBytes)
884
894
" 0200" ; // ret size offset 512
885
895
886
896
auto bytecode = hex_to_bytes (bytecode_hex);
887
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
897
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
898
+ ASSERT_TRUE (is_ok (error));
888
899
889
900
// Assign a vector that we will mutate internally in gen_trace to store the return values;
890
901
std::vector<FF> returndata;
@@ -958,7 +969,8 @@ TEST_F(AvmExecutionTests, toRadixBeOpcodeBitsMode)
958
969
" 0200" ; // ret size offset 512
959
970
960
971
auto bytecode = hex_to_bytes (bytecode_hex);
961
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
972
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
973
+ ASSERT_TRUE (is_ok (error));
962
974
963
975
// Assign a vector that we will mutate internally in gen_trace to store the return values;
964
976
std::vector<FF> returndata;
@@ -1031,7 +1043,8 @@ TEST_F(AvmExecutionTests, sha256CompressionOpcode)
1031
1043
" 0200" ; // ret size offset 512
1032
1044
1033
1045
auto bytecode = hex_to_bytes (bytecode_hex);
1034
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
1046
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
1047
+ ASSERT_TRUE (is_ok (error));
1035
1048
1036
1049
// Assign a vector that we will mutate internally in gen_trace to store the return values;
1037
1050
std::vector<FF> calldata = std::vector<FF>();
@@ -1093,7 +1106,8 @@ TEST_F(AvmExecutionTests, poseidon2PermutationOpCode)
1093
1106
" 0200" ; // ret size offset 512
1094
1107
1095
1108
auto bytecode = hex_to_bytes (bytecode_hex);
1096
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
1109
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
1110
+ ASSERT_TRUE (is_ok (error));
1097
1111
1098
1112
// Assign a vector that we will mutate internally in gen_trace to store the return values;
1099
1113
std::vector<FF> returndata = std::vector<FF>();
@@ -1168,7 +1182,8 @@ TEST_F(AvmExecutionTests, keccakf1600OpCode)
1168
1182
" 0200" ; // ret size offset 512
1169
1183
1170
1184
auto bytecode = hex_to_bytes (bytecode_hex);
1171
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
1185
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
1186
+ ASSERT_TRUE (is_ok (error));
1172
1187
1173
1188
// Assign a vector that we will mutate internally in gen_trace to store the return values;
1174
1189
std::vector<FF> calldata = std::vector<FF>();
@@ -1241,7 +1256,8 @@ TEST_F(AvmExecutionTests, embeddedCurveAddOpCode)
1241
1256
" 0200" ; // ret size offset 512
1242
1257
1243
1258
auto bytecode = hex_to_bytes (bytecode_hex);
1244
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
1259
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
1260
+ ASSERT_TRUE (is_ok (error));
1245
1261
1246
1262
// Assign a vector that we will mutate internally in gen_trace to store the return values;
1247
1263
std::vector<FF> returndata;
@@ -1336,7 +1352,8 @@ TEST_F(AvmExecutionTests, msmOpCode)
1336
1352
" 0200" ; // ret size offset 512
1337
1353
1338
1354
auto bytecode = hex_to_bytes (bytecode_hex);
1339
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
1355
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
1356
+ ASSERT_TRUE (is_ok (error));
1340
1357
1341
1358
// Assign a vector that we will mutate internally in gen_trace to store the return values;
1342
1359
std::vector<FF> returndata;
@@ -1407,7 +1424,8 @@ TEST_F(AvmExecutionTests, getEnvOpcode)
1407
1424
" 0200" ; // ret size offset 512
1408
1425
1409
1426
auto bytecode = hex_to_bytes (bytecode_hex);
1410
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
1427
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
1428
+ ASSERT_TRUE (is_ok (error));
1411
1429
1412
1430
ASSERT_THAT (instructions, SizeIs (13 ));
1413
1431
@@ -1623,7 +1641,8 @@ TEST_F(AvmExecutionTests, getEnvOpcode)
1623
1641
// "0001"; // dst_offset
1624
1642
//
1625
1643
// auto bytecode = hex_to_bytes(bytecode_hex);
1626
- // auto instructions = Deserialization::parse_bytecode_statically(bytecode);
1644
+ // auto [instructions, error] = Deserialization::parse_bytecode_statically(bytecode);
1645
+ // ASSERT_TRUE(is_ok(error));
1627
1646
//
1628
1647
// // Public inputs for the circuit
1629
1648
// std::vector<FF> calldata;
@@ -1660,7 +1679,8 @@ TEST_F(AvmExecutionTests, l2GasLeft)
1660
1679
" 00FF" ; // ret size offset 255
1661
1680
1662
1681
auto bytecode = hex_to_bytes (bytecode_hex);
1663
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
1682
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
1683
+ ASSERT_TRUE (is_ok (error));
1664
1684
1665
1685
ASSERT_THAT (instructions, SizeIs (4 ));
1666
1686
@@ -1708,7 +1728,8 @@ TEST_F(AvmExecutionTests, daGasLeft)
1708
1728
" 00FF" ; // ret size offset 255
1709
1729
1710
1730
auto bytecode = hex_to_bytes (bytecode_hex);
1711
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
1731
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
1732
+ ASSERT_TRUE (is_ok (error));
1712
1733
1713
1734
ASSERT_THAT (instructions, SizeIs (4 ));
1714
1735
@@ -1747,7 +1768,8 @@ TEST_F(AvmExecutionTests, ExecutorThrowsWithTooMuchGasAllocated)
1747
1768
public_inputs.gas_settings .gas_limits .l2_gas = MAX_L2_GAS_PER_ENQUEUED_CALL;
1748
1769
1749
1770
auto bytecode = hex_to_bytes (bytecode_hex);
1750
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
1771
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
1772
+ ASSERT_TRUE (is_ok (error));
1751
1773
1752
1774
ExecutionHints execution_hints;
1753
1775
EXPECT_THROW_WITH_MESSAGE (gen_trace (bytecode, calldata, public_inputs, returndata, execution_hints),
@@ -1767,7 +1789,8 @@ TEST_F(AvmExecutionTests, ExecutorThrowsWithTooMuchGasAllocated)
1767
1789
// std::vector<FF> public_inputs = { 1 };
1768
1790
//
1769
1791
// auto bytecode = hex_to_bytes(bytecode_hex);
1770
- // auto instructions = Deserialization::parse_bytecode_statically(bytecode);
1792
+ // auto [instructions, error] = Deserialization::parse_bytecode_statically(bytecode);
1793
+ // ASSERT_TRUE(is_ok(error));
1771
1794
//
1772
1795
// ExecutionHints execution_hints;
1773
1796
// EXPECT_THROW_WITH_MESSAGE(gen_trace(bytecode, calldata, public_inputs, returndata, execution_hints),
@@ -1814,7 +1837,8 @@ TEST_F(AvmExecutionTests, kernelOutputEmitOpcodes)
1814
1837
" 0000" ; // ret size 0
1815
1838
1816
1839
auto bytecode = hex_to_bytes (bytecode_hex);
1817
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
1840
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
1841
+ ASSERT_TRUE (is_ok (error));
1818
1842
1819
1843
ASSERT_THAT (instructions, SizeIs (8 ));
1820
1844
@@ -1943,7 +1967,8 @@ TEST_F(AvmExecutionTests, kernelOutputStorageLoadOpcodeSimple)
1943
1967
" 00FF" ; // ret size offset 255
1944
1968
1945
1969
auto bytecode = hex_to_bytes (bytecode_hex);
1946
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
1970
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
1971
+ ASSERT_TRUE (is_ok (error));
1947
1972
1948
1973
ASSERT_THAT (instructions, SizeIs (5 ));
1949
1974
@@ -2010,7 +2035,8 @@ TEST_F(AvmExecutionTests, kernelOutputStorageStoreOpcodeSimple)
2010
2035
" 0200" ; // ret size offset 512
2011
2036
2012
2037
auto bytecode = hex_to_bytes (bytecode_hex);
2013
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
2038
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
2039
+ ASSERT_TRUE (is_ok (error));
2014
2040
2015
2041
std::vector<FF> returndata;
2016
2042
@@ -2072,7 +2098,8 @@ TEST_F(AvmExecutionTests, kernelOutputStorageOpcodes)
2072
2098
" 00FF" ; // ret size offset 255
2073
2099
2074
2100
auto bytecode = hex_to_bytes (bytecode_hex);
2075
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
2101
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
2102
+ ASSERT_TRUE (is_ok (error));
2076
2103
2077
2104
ASSERT_THAT (instructions, SizeIs (6 ));
2078
2105
@@ -2159,7 +2186,8 @@ TEST_F(AvmExecutionTests, kernelOutputHashExistsOpcodes)
2159
2186
" 0200" ; // ret size offset 512
2160
2187
2161
2188
auto bytecode = hex_to_bytes (bytecode_hex);
2162
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
2189
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
2190
+ ASSERT_TRUE (is_ok (error));
2163
2191
2164
2192
ASSERT_THAT (instructions, SizeIs (7 ));
2165
2193
@@ -2313,7 +2341,8 @@ TEST_F(AvmExecutionTests, opCallOpcodes)
2313
2341
" 0200" ; // ret size offset 512
2314
2342
2315
2343
auto bytecode = hex_to_bytes (bytecode_hex);
2316
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
2344
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
2345
+ ASSERT_TRUE (is_ok (error));
2317
2346
2318
2347
std::vector<FF> returndata;
2319
2348
@@ -2392,7 +2421,8 @@ TEST_F(AvmExecutionTests, opGetContractInstanceOpcode)
2392
2421
" 0200" ; // ret size offset 512
2393
2422
2394
2423
auto bytecode = hex_to_bytes (bytecode_hex);
2395
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
2424
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
2425
+ ASSERT_TRUE (is_ok (error));
2396
2426
2397
2427
ASSERT_THAT (instructions, SizeIs (6 ));
2398
2428
@@ -2427,7 +2457,9 @@ TEST_F(AvmExecutionTests, opGetContractInstanceOpcodeBadEnum)
2427
2457
+ to_hex (static_cast <uint8_t >(ContractInstanceMember::MAX_MEMBER)); // member enum
2428
2458
2429
2459
auto bytecode = hex_to_bytes (bytecode_hex);
2430
- auto instructions = Deserialization::parse_bytecode_statically (bytecode);
2460
+ auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
2461
+ ASSERT_TRUE (is_ok (error));
2462
+
2431
2463
ASSERT_THAT (instructions, SizeIs (2 ));
2432
2464
2433
2465
std::vector<FF> calldata;
@@ -2457,7 +2489,8 @@ TEST_F(AvmExecutionTests, invalidOpcode)
2457
2489
" 0000" ; // ret size 0
2458
2490
2459
2491
auto bytecode = hex_to_bytes (bytecode_hex);
2460
- EXPECT_THROW_WITH_MESSAGE (Deserialization::parse_bytecode_statically (bytecode), " Invalid opcode" );
2492
+ const auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
2493
+ ASSERT_EQ (error, AvmError::INVALID_OPCODE);
2461
2494
}
2462
2495
2463
2496
// Negative test detecting an incomplete instruction: instruction tag present but an operand is missing
@@ -2474,7 +2507,8 @@ TEST_F(AvmExecutionTests, truncatedInstructionNoOperand)
2474
2507
" FF" ; // addr b and missing address for c = a-b
2475
2508
2476
2509
auto bytecode = hex_to_bytes (bytecode_hex);
2477
- EXPECT_THROW_WITH_MESSAGE (Deserialization::parse_bytecode_statically (bytecode), " Operand is missing" );
2510
+ const auto [instructions, error] = Deserialization::parse_bytecode_statically (bytecode);
2511
+ ASSERT_EQ (error, AvmError::PARSING_ERROR);
2478
2512
}
2479
2513
2480
2514
} // namespace tests_avm
0 commit comments