From 94298fd149d29902933e81a091f1b03d85749fdf Mon Sep 17 00:00:00 2001 From: SatyamAgrawal Date: Wed, 26 May 2021 16:21:30 +0530 Subject: [PATCH] bare bones of differential fuzzing and cleanup of commits from #385 --- .github/workflows/main.yml | 250 ++- Cargo.lock | 44 + Cargo.toml | 21 +- compiler/tests/cases/main.rs | 11 - fuzz/.gitignore | 4 + fuzz/Cargo.lock | 1368 +++++++++++++++++ fuzz/Cargo.toml | 30 + .../fixtures/fe/erc20.fe | 0 fuzz/fixtures/solidity/erc20.sol | 233 +++ fuzz/fuzz_targets/erc20_target.rs | 10 + fuzz/src/erc20.rs | 264 ++++ fuzz/src/lib.rs | 1 + test-utils/Cargo.toml | 23 + .../cases/utils.rs => test-utils/src/lib.rs | 17 +- tests/Cargo.toml | 28 + .../assert_reason_not_string.fe | 0 .../compile_errors/aug_assign_non_numeric.fe | 0 .../fixtures/compile_errors/bad_map.fe | 0 .../fixtures/compile_errors/bad_map2.fe | 0 .../fixtures/compile_errors/bad_map3.fe | 0 .../fixtures/compile_errors/bad_map4.fe | 0 .../fixtures/compile_errors/bad_map5.fe | 0 .../compile_errors/bad_tuple_attr1.fe | 0 .../compile_errors/bad_tuple_attr2.fe | 0 .../binary_operations/add_uints.fe | 0 .../binary_operations/lshift_bool.fe | 0 .../binary_operations/lshift_with_int.fe | 0 .../binary_operations/pow_int.fe | 0 .../compile_errors/break_without_loop.fe | 0 .../compile_errors/break_without_loop_2.fe | 0 .../call_event_with_wrong_types.fe | 0 .../call_undefined_function_on_contract.fe | 0 ...undefined_function_on_external_contract.fe | 0 ...all_undefined_function_on_memory_struct.fe | 0 ...ll_undefined_function_on_storage_struct.fe | 0 .../circular_dependency_create.fe | 0 .../circular_dependency_create2.fe | 0 .../compile_errors/continue_without_loop.fe | 0 .../compile_errors/continue_without_loop_2.fe | 0 .../duplicate_contract_in_module.fe | 0 .../duplicate_event_in_contract.fe | 0 .../duplicate_field_in_contract.fe | 0 .../duplicate_field_in_struct.fe | 0 .../duplicate_method_in_contract.fe | 0 .../duplicate_struct_in_module.fe | 0 .../duplicate_typedef_in_module.fe | 0 .../duplicate_var_in_child_scope.fe | 0 .../duplicate_var_in_contract_method.fe | 0 .../compile_errors/emit_undefined_event.fe | 0 .../external_call_type_error.fe | 0 .../external_call_wrong_number_of_params.fe | 0 .../fixtures/compile_errors/indexed_event.fe | 0 .../keccak_called_with_wrong_type.fe | 0 .../compile_errors/mismatch_return_type.fe | 0 .../fixtures/compile_errors/missing_return.fe | 0 .../compile_errors/missing_return_in_else.fe | 0 .../fixtures/compile_errors/needs_mem_copy.fe | 0 .../fixtures/compile_errors/non_bool_and.fe | 0 .../fixtures/compile_errors/non_bool_or.fe | 0 .../fixtures/compile_errors/not_in_scope.fe | 0 .../fixtures/compile_errors/not_in_scope_2.fe | 0 .../numeric_capacity_mismatch/i128_neg.fe | 0 .../numeric_capacity_mismatch/i128_pos.fe | 0 .../numeric_capacity_mismatch/i16_neg.fe | 0 .../numeric_capacity_mismatch/i16_pos.fe | 0 .../numeric_capacity_mismatch/i256_neg.fe | 0 .../numeric_capacity_mismatch/i256_pos.fe | 0 .../numeric_capacity_mismatch/i32_neg.fe | 0 .../numeric_capacity_mismatch/i32_pos.fe | 0 .../numeric_capacity_mismatch/i64_neg.fe | 0 .../numeric_capacity_mismatch/i64_pos.fe | 0 .../numeric_capacity_mismatch/i8_neg.fe | 0 .../numeric_capacity_mismatch/i8_pos.fe | 0 .../literal_too_big.fe | 0 .../literal_too_small.fe | 0 .../numeric_capacity_mismatch/u128_neg.fe | 0 .../numeric_capacity_mismatch/u128_pos.fe | 0 .../numeric_capacity_mismatch/u16_neg.fe | 0 .../numeric_capacity_mismatch/u16_pos.fe | 0 .../numeric_capacity_mismatch/u256_neg.fe | 0 .../numeric_capacity_mismatch/u256_pos.fe | 0 .../numeric_capacity_mismatch/u32_neg.fe | 0 .../numeric_capacity_mismatch/u32_pos.fe | 0 .../numeric_capacity_mismatch/u64_neg.fe | 0 .../numeric_capacity_mismatch/u64_pos.fe | 0 .../numeric_capacity_mismatch/u8_neg.fe | 0 .../numeric_capacity_mismatch/u8_pos.fe | 0 .../pow_with_signed_exponent.fe | 0 .../compile_errors/pow_with_wrong_capacity.fe | 0 .../return_addition_with_mixed_types.fe | 0 ...urn_call_to_fn_with_param_type_mismatch.fe | 0 .../return_call_to_fn_without_return.fe | 0 .../compile_errors/return_from_init.fe | 0 .../compile_errors/return_lt_mixed_types.fe | 0 .../compile_errors/strict_boolean_if_else.fe | 0 .../string_capacity_mismatch.fe | 0 .../struct_call_without_kw_args.fe | 0 .../type_constructor_from_variable.fe | 0 .../compile_errors/unary_minus_on_bool.fe | 0 .../compile_errors/unexpected_return.fe | 0 tests/fixtures/demos/erc20_token.fe | 107 ++ .../fixtures/demos/guest_book.fe | 0 .../tests => tests}/fixtures/demos/uniswap.fe | 0 .../fixtures/features/address_bytes10_map.fe | 0 .../fixtures/features/assert.fe | 0 .../fixtures/features}/aug_assign.fe | 0 .../fixtures/features/base_tuple.fe | 0 .../features/call_statement_with_args.fe | 0 .../features/call_statement_with_args_2.fe | 0 .../features/call_statement_without_args.fe | 0 .../fixtures/features/checked_arithmetic.fe | 0 .../fixtures/features/constructor.fe | 0 .../fixtures/features/create2_contract.fe | 0 .../fixtures/features/create_contract.fe | 0 .../features/create_contract_from_init.fe | 0 .../fixtures/features/empty.fe | 0 .../fixtures/features/events.fe | 0 .../fixtures/features/external_contract.fe | 0 .../fixtures/features/for_loop_with_break.fe | 0 .../features/for_loop_with_continue.fe | 0 .../features/for_loop_with_static_array.fe | 0 .../fixtures/features/if_statement.fe | 0 .../fixtures/features/if_statement_2.fe | 0 .../if_statement_with_block_declaration.fe | 0 .../fixtures/features/keccak.fe | 0 .../tests => tests}/fixtures/features/math.fe | 0 .../fixtures/features/multi_param.fe | 0 .../fixtures/features/nested_map.fe | 0 .../fixtures/features/numeric_sizes.fe | 0 .../fixtures/features/ownable.fe | 0 .../fixtures/features/radix_binary.fe | 0 .../fixtures/features/radix_hex.fe | 0 .../fixtures/features/radix_octal.fe | 0 .../fixtures/features/return_addition_i256.fe | 0 .../fixtures/features/return_addition_u128.fe | 0 .../fixtures/features/return_addition_u256.fe | 0 .../fixtures/features/return_array.fe | 0 .../features/return_bitwiseand_u128.fe | 0 .../features/return_bitwiseand_u256.fe | 0 .../features/return_bitwiseor_u256.fe | 0 .../features/return_bitwiseshl_u256.fe | 0 .../features/return_bitwiseshr_i256.fe | 0 .../features/return_bitwiseshr_u256.fe | 0 .../features/return_bitwisexor_u256.fe | 0 .../fixtures/features/return_bool_false.fe | 0 .../fixtures/features/return_bool_inverted.fe | 0 .../fixtures/features/return_bool_op_and.fe | 0 .../fixtures/features/return_bool_op_or.fe | 0 .../fixtures/features/return_bool_true.fe | 0 .../features/return_builtin_attributes.fe | 0 .../fixtures/features/return_division_i256.fe | 0 .../fixtures/features/return_division_u256.fe | 0 .../fixtures/features/return_eq_u256.fe | 0 .../fixtures/features/return_gt_i256.fe | 0 .../fixtures/features/return_gt_u256.fe | 0 .../fixtures/features/return_gte_i256.fe | 0 .../fixtures/features/return_gte_u256.fe | 0 .../fixtures/features/return_i128_cast.fe | 0 .../fixtures/features/return_i256.fe | 0 .../fixtures/features/return_identity_u128.fe | 0 .../fixtures/features/return_identity_u16.fe | 0 .../fixtures/features/return_identity_u256.fe | 0 .../fixtures/features/return_identity_u32.fe | 0 .../fixtures/features/return_identity_u64.fe | 0 .../fixtures/features/return_identity_u8.fe | 0 .../fixtures/features/return_lt_i256.fe | 0 .../fixtures/features/return_lt_u128.fe | 0 .../fixtures/features/return_lt_u256.fe | 0 .../fixtures/features/return_lte_i256.fe | 0 .../fixtures/features/return_lte_u256.fe | 0 .../fixtures/features/return_mod_i256.fe | 0 .../fixtures/features/return_mod_u256.fe | 0 .../fixtures/features/return_msg_sig.fe | 0 .../features/return_multiplication_i256.fe | 0 .../features/return_multiplication_u256.fe | 0 .../fixtures/features/return_noteq_u256.fe | 0 .../fixtures/features/return_pow_i256.fe | 0 .../fixtures/features/return_pow_u256.fe | 0 .../features/return_subtraction_i256.fe | 0 .../features/return_subtraction_u256.fe | 0 .../features/return_sum_list_expression_1.fe | 0 .../features/return_sum_list_expression_2.fe | 0 .../fixtures/features/return_u128_cast.fe | 0 .../fixtures/features/return_u256.fe | 0 .../features/return_u256_from_called_fn.fe | 0 .../return_u256_from_called_fn_with_args.fe | 0 .../fixtures/features/return_unit.fe | 0 .../fixtures/features/revert.fe | 0 .../fixtures/features/self_address.fe | 0 .../fixtures/features/sized_vals_in_sto.fe | 0 .../fixtures/features/strings.fe | 0 .../fixtures/features/structs.fe | 0 .../fixtures/features/ternary_expression.fe | 0 .../fixtures/features/two_contracts.fe | 0 .../fixtures/features/u128_u128_map.fe | 0 .../fixtures/features/u16_u16_map.fe | 0 .../fixtures/features/u256_u256_map.fe | 0 .../fixtures/features/u32_u32_map.fe | 0 .../fixtures/features/u64_u64_map.fe | 0 .../fixtures/features/u8_u8_map.fe | 0 .../fixtures/features/while_loop.fe | 0 .../features/while_loop_with_break.fe | 0 .../features/while_loop_with_break_2.fe | 0 .../features/while_loop_with_continue.fe | 0 .../fixtures/solidity/revert_test.sol | 0 .../fixtures/stress/abi_encoding_stress.fe | 0 .../fixtures/stress/data_copying_stress.fe | 0 .../fixtures/stress/external_calls.fe | 0 .../fixtures/stress/tuple_stress.fe | 0 .../cases => tests/src}/compile_errors.rs | 2 +- .../tests/cases => tests/src}/demo_erc20.rs | 4 +- .../cases => tests/src}/demo_guestbook.rs | 9 +- .../tests/cases => tests/src}/demo_uniswap.rs | 10 +- .../tests/cases => tests/src}/features.rs | 14 +- tests/src/lib.rs | 17 + .../src/lowering/fixtures}/aug_assign.fe | 0 .../lowering/fixtures/aug_assign_lowered.fe | 0 .../src}/lowering/fixtures/base_tuple.fe | 0 .../lowering/fixtures/base_tuple_lowered.fe | 0 .../lowering/fixtures/custom_empty_type.fe | 0 .../fixtures/custom_empty_type_lowered.fe | 0 .../src}/lowering/fixtures/init.fe | 0 .../src}/lowering/fixtures/init_lowered.fe | 0 .../lowering/fixtures/list_expressions.fe | 0 .../fixtures/list_expressions_lowered.fe | 0 .../src}/lowering/fixtures/return_unit.fe | 0 .../lowering/fixtures/return_unit_lowered.fe | 0 .../src}/lowering/fixtures/unit_implicit.fe | 0 .../fixtures/unit_implicit_lowered.fe | 0 .../tests/cases => tests/src}/lowering/mod.rs | 0 .../tests/cases => tests/src}/runtime.rs | 2 +- .../tests/cases => tests/src}/solidity.rs | 9 +- {compiler/tests/cases => tests/src}/stress.rs | 7 +- 233 files changed, 2310 insertions(+), 175 deletions(-) delete mode 100644 compiler/tests/cases/main.rs create mode 100644 fuzz/.gitignore create mode 100644 fuzz/Cargo.lock create mode 100644 fuzz/Cargo.toml rename compiler/tests/fixtures/demos/erc20_token.fe => fuzz/fixtures/fe/erc20.fe (100%) create mode 100644 fuzz/fixtures/solidity/erc20.sol create mode 100644 fuzz/fuzz_targets/erc20_target.rs create mode 100644 fuzz/src/erc20.rs create mode 100644 fuzz/src/lib.rs create mode 100644 test-utils/Cargo.toml rename compiler/tests/cases/utils.rs => test-utils/src/lib.rs (97%) create mode 100644 tests/Cargo.toml rename {compiler/tests => tests}/fixtures/compile_errors/assert_reason_not_string.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/aug_assign_non_numeric.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/bad_map.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/bad_map2.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/bad_map3.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/bad_map4.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/bad_map5.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/bad_tuple_attr1.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/bad_tuple_attr2.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/binary_operations/add_uints.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/binary_operations/lshift_bool.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/binary_operations/lshift_with_int.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/binary_operations/pow_int.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/break_without_loop.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/break_without_loop_2.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/call_event_with_wrong_types.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/call_undefined_function_on_contract.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/call_undefined_function_on_external_contract.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/call_undefined_function_on_memory_struct.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/call_undefined_function_on_storage_struct.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/circular_dependency_create.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/circular_dependency_create2.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/continue_without_loop.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/continue_without_loop_2.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/duplicate_contract_in_module.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/duplicate_event_in_contract.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/duplicate_field_in_contract.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/duplicate_field_in_struct.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/duplicate_method_in_contract.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/duplicate_struct_in_module.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/duplicate_typedef_in_module.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/duplicate_var_in_child_scope.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/duplicate_var_in_contract_method.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/emit_undefined_event.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/external_call_type_error.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/external_call_wrong_number_of_params.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/indexed_event.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/keccak_called_with_wrong_type.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/mismatch_return_type.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/missing_return.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/missing_return_in_else.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/needs_mem_copy.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/non_bool_and.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/non_bool_or.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/not_in_scope.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/not_in_scope_2.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/i128_neg.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/i128_pos.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/i16_neg.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/i16_pos.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/i256_neg.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/i256_pos.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/i32_neg.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/i32_pos.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/i64_neg.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/i64_pos.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/i8_neg.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/i8_pos.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/literal_too_big.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/literal_too_small.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/u128_neg.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/u128_pos.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/u16_neg.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/u16_pos.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/u256_neg.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/u256_pos.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/u32_neg.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/u32_pos.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/u64_neg.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/u64_pos.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/u8_neg.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/numeric_capacity_mismatch/u8_pos.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/pow_with_signed_exponent.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/pow_with_wrong_capacity.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/return_addition_with_mixed_types.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/return_call_to_fn_with_param_type_mismatch.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/return_call_to_fn_without_return.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/return_from_init.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/return_lt_mixed_types.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/strict_boolean_if_else.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/string_capacity_mismatch.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/struct_call_without_kw_args.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/type_constructor_from_variable.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/unary_minus_on_bool.fe (100%) rename {compiler/tests => tests}/fixtures/compile_errors/unexpected_return.fe (100%) create mode 100644 tests/fixtures/demos/erc20_token.fe rename {compiler/tests => tests}/fixtures/demos/guest_book.fe (100%) rename {compiler/tests => tests}/fixtures/demos/uniswap.fe (100%) rename {compiler/tests => tests}/fixtures/features/address_bytes10_map.fe (100%) rename {compiler/tests => tests}/fixtures/features/assert.fe (100%) rename {compiler/tests/cases/lowering/fixtures => tests/fixtures/features}/aug_assign.fe (100%) rename {compiler/tests => tests}/fixtures/features/base_tuple.fe (100%) rename {compiler/tests => tests}/fixtures/features/call_statement_with_args.fe (100%) rename {compiler/tests => tests}/fixtures/features/call_statement_with_args_2.fe (100%) rename {compiler/tests => tests}/fixtures/features/call_statement_without_args.fe (100%) rename {compiler/tests => tests}/fixtures/features/checked_arithmetic.fe (100%) rename {compiler/tests => tests}/fixtures/features/constructor.fe (100%) rename {compiler/tests => tests}/fixtures/features/create2_contract.fe (100%) rename {compiler/tests => tests}/fixtures/features/create_contract.fe (100%) rename {compiler/tests => tests}/fixtures/features/create_contract_from_init.fe (100%) rename {compiler/tests => tests}/fixtures/features/empty.fe (100%) rename {compiler/tests => tests}/fixtures/features/events.fe (100%) rename {compiler/tests => tests}/fixtures/features/external_contract.fe (100%) rename {compiler/tests => tests}/fixtures/features/for_loop_with_break.fe (100%) rename {compiler/tests => tests}/fixtures/features/for_loop_with_continue.fe (100%) rename {compiler/tests => tests}/fixtures/features/for_loop_with_static_array.fe (100%) rename {compiler/tests => tests}/fixtures/features/if_statement.fe (100%) rename {compiler/tests => tests}/fixtures/features/if_statement_2.fe (100%) rename {compiler/tests => tests}/fixtures/features/if_statement_with_block_declaration.fe (100%) rename {compiler/tests => tests}/fixtures/features/keccak.fe (100%) rename {compiler/tests => tests}/fixtures/features/math.fe (100%) rename {compiler/tests => tests}/fixtures/features/multi_param.fe (100%) rename {compiler/tests => tests}/fixtures/features/nested_map.fe (100%) rename {compiler/tests => tests}/fixtures/features/numeric_sizes.fe (100%) rename {compiler/tests => tests}/fixtures/features/ownable.fe (100%) rename {compiler/tests => tests}/fixtures/features/radix_binary.fe (100%) rename {compiler/tests => tests}/fixtures/features/radix_hex.fe (100%) rename {compiler/tests => tests}/fixtures/features/radix_octal.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_addition_i256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_addition_u128.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_addition_u256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_array.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_bitwiseand_u128.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_bitwiseand_u256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_bitwiseor_u256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_bitwiseshl_u256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_bitwiseshr_i256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_bitwiseshr_u256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_bitwisexor_u256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_bool_false.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_bool_inverted.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_bool_op_and.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_bool_op_or.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_bool_true.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_builtin_attributes.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_division_i256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_division_u256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_eq_u256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_gt_i256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_gt_u256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_gte_i256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_gte_u256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_i128_cast.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_i256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_identity_u128.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_identity_u16.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_identity_u256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_identity_u32.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_identity_u64.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_identity_u8.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_lt_i256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_lt_u128.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_lt_u256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_lte_i256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_lte_u256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_mod_i256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_mod_u256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_msg_sig.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_multiplication_i256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_multiplication_u256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_noteq_u256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_pow_i256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_pow_u256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_subtraction_i256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_subtraction_u256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_sum_list_expression_1.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_sum_list_expression_2.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_u128_cast.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_u256.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_u256_from_called_fn.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_u256_from_called_fn_with_args.fe (100%) rename {compiler/tests => tests}/fixtures/features/return_unit.fe (100%) rename {compiler/tests => tests}/fixtures/features/revert.fe (100%) rename {compiler/tests => tests}/fixtures/features/self_address.fe (100%) rename {compiler/tests => tests}/fixtures/features/sized_vals_in_sto.fe (100%) rename {compiler/tests => tests}/fixtures/features/strings.fe (100%) rename {compiler/tests => tests}/fixtures/features/structs.fe (100%) rename {compiler/tests => tests}/fixtures/features/ternary_expression.fe (100%) rename {compiler/tests => tests}/fixtures/features/two_contracts.fe (100%) rename {compiler/tests => tests}/fixtures/features/u128_u128_map.fe (100%) rename {compiler/tests => tests}/fixtures/features/u16_u16_map.fe (100%) rename {compiler/tests => tests}/fixtures/features/u256_u256_map.fe (100%) rename {compiler/tests => tests}/fixtures/features/u32_u32_map.fe (100%) rename {compiler/tests => tests}/fixtures/features/u64_u64_map.fe (100%) rename {compiler/tests => tests}/fixtures/features/u8_u8_map.fe (100%) rename {compiler/tests => tests}/fixtures/features/while_loop.fe (100%) rename {compiler/tests => tests}/fixtures/features/while_loop_with_break.fe (100%) rename {compiler/tests => tests}/fixtures/features/while_loop_with_break_2.fe (100%) rename {compiler/tests => tests}/fixtures/features/while_loop_with_continue.fe (100%) rename {compiler/tests => tests}/fixtures/solidity/revert_test.sol (100%) rename {compiler/tests => tests}/fixtures/stress/abi_encoding_stress.fe (100%) rename {compiler/tests => tests}/fixtures/stress/data_copying_stress.fe (100%) rename {compiler/tests => tests}/fixtures/stress/external_calls.fe (100%) rename {compiler/tests => tests}/fixtures/stress/tuple_stress.fe (100%) rename {compiler/tests/cases => tests/src}/compile_errors.rs (98%) rename {compiler/tests/cases => tests/src}/demo_erc20.rs (98%) rename {compiler/tests/cases => tests/src}/demo_guestbook.rs (77%) rename {compiler/tests/cases => tests/src}/demo_uniswap.rs (97%) rename {compiler/tests/cases => tests/src}/features.rs (99%) create mode 100644 tests/src/lib.rs rename {compiler/tests/fixtures/features => tests/src/lowering/fixtures}/aug_assign.fe (100%) rename {compiler/tests/cases => tests/src}/lowering/fixtures/aug_assign_lowered.fe (100%) rename {compiler/tests/cases => tests/src}/lowering/fixtures/base_tuple.fe (100%) rename {compiler/tests/cases => tests/src}/lowering/fixtures/base_tuple_lowered.fe (100%) rename {compiler/tests/cases => tests/src}/lowering/fixtures/custom_empty_type.fe (100%) rename {compiler/tests/cases => tests/src}/lowering/fixtures/custom_empty_type_lowered.fe (100%) rename {compiler/tests/cases => tests/src}/lowering/fixtures/init.fe (100%) rename {compiler/tests/cases => tests/src}/lowering/fixtures/init_lowered.fe (100%) rename {compiler/tests/cases => tests/src}/lowering/fixtures/list_expressions.fe (100%) rename {compiler/tests/cases => tests/src}/lowering/fixtures/list_expressions_lowered.fe (100%) rename {compiler/tests/cases => tests/src}/lowering/fixtures/return_unit.fe (100%) rename {compiler/tests/cases => tests/src}/lowering/fixtures/return_unit_lowered.fe (100%) rename {compiler/tests/cases => tests/src}/lowering/fixtures/unit_implicit.fe (100%) rename {compiler/tests/cases => tests/src}/lowering/fixtures/unit_implicit_lowered.fe (100%) rename {compiler/tests/cases => tests/src}/lowering/mod.rs (100%) rename {compiler/tests/cases => tests/src}/runtime.rs (99%) rename {compiler/tests/cases => tests/src}/solidity.rs (91%) rename {compiler/tests/cases => tests/src}/stress.rs (98%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 023b1eb8e1..29a6e60a34 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,81 +2,79 @@ name: CI on: push: - branches: [ master ] + branches: [master] tags: - v* pull_request: - branches: [ master ] + branches: [master] env: CARGO_TERM_COLOR: always jobs: - coverage: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Install system dependencies - run: | - "${GITHUB_WORKSPACE}/.github/install_deps.sh" - - name: Cache Rust dependencies - uses: actions/cache@v1.1.2 - with: - # There's a problem with caching serde, hence we exclude it here - path: | - target - !target/**/*serde* - key: ${{ runner.OS }}-build-v2-${{ hashFiles('**/Cargo.lock') }} - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - name: coverage with tarpaulin - run: | - cargo install cargo-tarpaulin - make coverage - bash <(curl -s https://codecov.io/bash) + - uses: actions/checkout@v2 + - name: Install system dependencies + run: | + "${GITHUB_WORKSPACE}/.github/install_deps.sh" + - name: Cache Rust dependencies + uses: actions/cache@v1.1.2 + with: + # There's a problem with caching serde, hence we exclude it here + path: | + target + !target/**/*serde* + key: ${{ runner.OS }}-build-v2-${{ hashFiles('**/Cargo.lock') }} + - name: Install rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - name: coverage with tarpaulin + run: | + cargo install cargo-tarpaulin + make coverage + bash <(curl -s https://codecov.io/bash) lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Install system dependencies - run: | - "${GITHUB_WORKSPACE}/.github/install_deps.sh" - - name: Cache Rust dependencies - uses: actions/cache@v1.1.2 - with: - # There's a problem with caching serde, hence we exclude it here - path: | - target - !target/**/*serde* - key: ${{ runner.OS }}-build-v2-${{ hashFiles('**/Cargo.lock') }} - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - components: rustfmt, clippy - - name: Validate release notes entry - run: ./newsfragments/validate_files.py - - name: Lint with rustfmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - - name: Lint with clippy - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --workspace --all-targets --all-features -- -D warnings + - uses: actions/checkout@v2 + - name: Install system dependencies + run: | + "${GITHUB_WORKSPACE}/.github/install_deps.sh" + - name: Cache Rust dependencies + uses: actions/cache@v1.1.2 + with: + # There's a problem with caching serde, hence we exclude it here + path: | + target + !target/**/*serde* + key: ${{ runner.OS }}-build-v2-${{ hashFiles('**/Cargo.lock') }} + - name: Install rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + components: rustfmt, clippy + - name: Validate release notes entry + run: ./newsfragments/validate_files.py + - name: Lint with rustfmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + - name: Lint with clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: --workspace --all-targets --all-features -- -D warnings test: # Build & Test runs on all platforms @@ -84,87 +82,87 @@ jobs: strategy: matrix: include: - - os: ubuntu-latest - - os: macOS-latest + - os: ubuntu-latest + - os: macOS-latest steps: - - uses: actions/checkout@v2 - - name: Cache Rust dependencies - uses: actions/cache@v1.1.2 - with: - # There's a problem with caching serde, hence we exclude it here - path: | - target - !target/**/*serde* - key: ${{ runner.OS }}-build-v2-${{ hashFiles('**/Cargo.lock') }} - - name: Install Mac System dependencies - if: startsWith(matrix.os,'macOS') - run: | - brew install boost - - name: Install Linux dependencies - if: startsWith(matrix.os,'ubuntu') - run: | - "${GITHUB_WORKSPACE}/.github/install_deps.sh" - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - name: Build - run: cargo build --all-features --verbose - - name: Run tests - run: cargo test --workspace --features solc-backend --verbose - - wasm-test: - runs-on: ubuntu-latest - container: davesque/rust-wasm - steps: - uses: actions/checkout@v2 + - name: Cache Rust dependencies + uses: actions/cache@v1.1.2 + with: + # There's a problem with caching serde, hence we exclude it here + path: | + target + !target/**/*serde* + key: ${{ runner.OS }}-build-v2-${{ hashFiles('**/Cargo.lock') }} + - name: Install Mac System dependencies + if: startsWith(matrix.os,'macOS') + run: | + brew install boost + - name: Install Linux dependencies + if: startsWith(matrix.os,'ubuntu') + run: | + "${GITHUB_WORKSPACE}/.github/install_deps.sh" - name: Install rust uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable override: true - - name: Run WASM tests - run: wasm-pack test --node -- --workspace + - name: Build + run: cargo build --all-features --verbose + - name: Run tests + run: cargo test --workspace --features solc-backend --verbose + # wasm-test: + # runs-on: ubuntu-latest + # container: davesque/rust-wasm + # steps: + # - uses: actions/checkout@v2 + # - name: Install rust + # uses: actions-rs/toolchain@v1 + # with: + # profile: minimal + # toolchain: stable + # override: true + # - name: Run WASM tests + # run: wasm-pack test --node -- --workspace release: - # Only run this when we push a tag - if: startsWith(github.ref, 'refs/tags/') - runs-on: ${{ matrix.os }} - needs: [lint, test, wasm-test] - strategy: - matrix: - include: + # Only run this when we push a tag + if: startsWith(github.ref, 'refs/tags/') + runs-on: ${{ matrix.os }} + # needs: [lint, test, wasm-test] + needs: [lint, test] + strategy: + matrix: + include: - os: ubuntu-latest BIN_FILE: fe_amd64 - os: macOS-latest BIN_FILE: fe_mac - steps: - - uses: actions/checkout@v2 - - name: Install Linux dependencies - if: startsWith(matrix.os,'ubuntu') - run: | - "${GITHUB_WORKSPACE}/.github/install_deps.sh" - - name: Install Mac System dependencies - if: startsWith(matrix.os,'macOS') - run: | - brew install boost - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - name: Build - run: cargo build --all-features --release && strip target/release/fe && mv target/release/fe target/release/${{ matrix.BIN_FILE }} - - name: Release - uses: softprops/action-gh-release@v1 - with: - files: target/release/${{ matrix.BIN_FILE }} - prerelease: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + - name: Install Linux dependencies + if: startsWith(matrix.os,'ubuntu') + run: | + "${GITHUB_WORKSPACE}/.github/install_deps.sh" + - name: Install Mac System dependencies + if: startsWith(matrix.os,'macOS') + run: | + brew install boost + - name: Install rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - name: Build + run: cargo build --all-features --release && strip target/release/fe && mv target/release/fe target/release/${{ matrix.BIN_FILE }} + - name: Release + uses: softprops/action-gh-release@v1 + with: + files: target/release/${{ matrix.BIN_FILE }} + prerelease: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Cargo.lock b/Cargo.lock index dc05ca01d2..49c3379769 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -615,6 +615,7 @@ dependencies = [ "clap", "fe-common", "fe-compiler", + "fe-compiler-tests", "fe-parser", ] @@ -672,6 +673,43 @@ dependencies = [ "yultsur", ] +[[package]] +name = "fe-compiler-test-utils" +version = "0.4.0-alpha" +dependencies = [ + "ethabi", + "evm", + "evm-runtime", + "fe-common", + "fe-compiler", + "hex", + "primitive-types", + "serde_json", + "solc", + "stringreader", + "yultsur", +] + +[[package]] +name = "fe-compiler-tests" +version = "0.4.0-alpha" +dependencies = [ + "ethabi", + "evm", + "evm-runtime", + "fe-analyzer", + "fe-common", + "fe-compiler", + "fe-compiler-test-utils", + "hex", + "primitive-types", + "rand", + "regex", + "rstest", + "stringreader", + "yultsur", +] + [[package]] name = "fe-parser" version = "0.4.0-alpha" @@ -1623,6 +1661,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "stringreader" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "913e7b03d63752f6cdd2df77da36749d82669904798fe8944b9ec3d23f159905" + [[package]] name = "strsim" version = "0.8.0" diff --git a/Cargo.toml b/Cargo.toml index 38fec3a2c0..c17e4cb3bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,26 +1,27 @@ [package] -name = "fe" -version = "0.4.0-alpha" authors = ["David Sanders "] -edition = "2018" -license = "Apache-2.0" -repository = "https://github.com/ethereum/fe" +categories = ["cryptography::cryptocurrencies", "command-line-utilities", "development-tools"] description = "An implementation of the Fe smart contract language" +edition = "2018" keywords = ["ethereum", "fe", "yul", "smart", "contract", "compiler"] -categories = ["cryptography::cryptocurrencies", "command-line-utilities", "development-tools"] +license = "Apache-2.0" +name = "fe" readme = "README.md" +repository = "https://github.com/ethereum/fe" +version = "0.4.0-alpha" [workspace] -members = [".", "parser", "compiler"] +members = [".", "parser", "compiler", "tests"] [features] -solc-backend = ["fe-compiler/solc-backend"] +solc-backend = ["fe-compiler/solc-backend", "fe-compiler-tests/solc-backend"] [dependencies] +clap = "2.33.3" fe-common = {path = "common", version = "^0.4.0-alpha"} -fe-parser = {path = "parser", version = "^0.4.0-alpha"} fe-compiler = {path = "compiler", version = "^0.4.0-alpha"} -clap = "2.33.3" +fe-compiler-tests = {path = "tests", features = ["solc-backend"], version = "^0.4.0-alpha"} +fe-parser = {path = "parser", version = "^0.4.0-alpha"} [dev-dependencies] cargo-release = "0.13.9" diff --git a/compiler/tests/cases/main.rs b/compiler/tests/cases/main.rs deleted file mode 100644 index 5dda498f32..0000000000 --- a/compiler/tests/cases/main.rs +++ /dev/null @@ -1,11 +0,0 @@ -mod compile_errors; -mod demo_erc20; -mod demo_guestbook; -mod demo_uniswap; -mod features; -mod lowering; -mod runtime; -mod solidity; -mod stress; - -mod utils; diff --git a/fuzz/.gitignore b/fuzz/.gitignore new file mode 100644 index 0000000000..572e03bdf3 --- /dev/null +++ b/fuzz/.gitignore @@ -0,0 +1,4 @@ + +target +corpus +artifacts diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock new file mode 100644 index 0000000000..8bbc366e97 --- /dev/null +++ b/fuzz/Cargo.lock @@ -0,0 +1,1368 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +dependencies = [ + "memchr", +] + +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +dependencies = [ + "winapi", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "arbitrary" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "237430fd6ed3740afe94eefcc278ae21e050285be882804e0d6e8695f0c94691" + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "base64" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" +dependencies = [ + "byteorder", +] + +[[package]] +name = "beef" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "474a626a67200bd107d44179bb3d4fc61891172d11696609264589be6a0e6a43" + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bindgen" +version = "0.56.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2da379dbebc0b76ef63ca68d8fc6e71c0f13e59432e0987e508c1820e6ab5239" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "clap", + "env_logger", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "which", +] + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "bitvec" +version = "0.17.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41262f11d771fd4a61aa3ce019fca363b4b6c282fca9da2a31186d3965a47a5c" +dependencies = [ + "either", + "radium", +] + +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +dependencies = [ + "block-padding 0.1.5", + "byte-tools", + "byteorder", + "generic-array 0.12.4", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "block-padding 0.2.1", + "generic-array 0.14.4", +] + +[[package]] +name = "block-padding" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +dependencies = [ + "byte-tools", +] + +[[package]] +name = "block-padding" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" + +[[package]] +name = "bumpalo" +version = "3.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" + +[[package]] +name = "byte-slice-cast" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0a5e3906bcbf133e33c1d4d95afc664ad37fbdb9f6568d8043e7ea8c27d93d3" + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" + +[[package]] +name = "cc" +version = "1.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" + +[[package]] +name = "cexpr" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clang-sys" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "853eda514c284c2287f4bf20ae614f8781f40a81d32ecda6e91449304dfe077c" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "clap" +version = "2.33.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +dependencies = [ + "ansi_term 0.11.0", + "atty", + "bitflags", + "strsim", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +name = "cmake" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb6210b637171dfba4cda12e579ac6dc73f5165ad56133e5d72ef3131f320855" +dependencies = [ + "cc", +] + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "difference" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" + +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array 0.12.4", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array 0.14.4", +] + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "env_logger" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17392a012ea30ef05a610aa97dfb49496e71c9f676b27879922ea5bdf60d9d3f" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "ethabi" +version = "12.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052a565e3de82944527d6d10a465697e6bb92476b772ca7141080c901f6a63c6" +dependencies = [ + "ethereum-types", + "rustc-hex", + "serde", + "serde_json", + "tiny-keccak 1.5.0", + "uint", +] + +[[package]] +name = "ethbloom" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71a6567e6fd35589fea0c63b94b4cf2e55573e413901bdbe60ab15cf0e25e5df" +dependencies = [ + "crunchy", + "fixed-hash", + "impl-rlp", + "impl-serde", + "tiny-keccak 2.0.2", +] + +[[package]] +name = "ethereum" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01ea35e1b0845310ade8eb048d401b0b899b8eff05c4d2a3454d29ef4eb1b8af" +dependencies = [ + "ethereum-types", + "hash-db", + "hash256-std-hasher", + "parity-scale-codec", + "rlp 0.4.6", + "rlp-derive", + "serde", + "sha3 0.9.1", + "triehash", +] + +[[package]] +name = "ethereum-types" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "473aecff686bd8e7b9db0165cbbb53562376b39bf35b427f0c60446a9e1634b0" +dependencies = [ + "ethbloom", + "fixed-hash", + "impl-rlp", + "impl-serde", + "primitive-types", + "uint", +] + +[[package]] +name = "evm" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5286da2277b078e7033491d62e674eeccd01d913a87bb60ec0cabbcf80ec62e9" +dependencies = [ + "ethereum", + "evm-core", + "evm-gasometer", + "evm-runtime", + "log", + "parity-scale-codec", + "primitive-types", + "rlp 0.4.6", + "serde", + "sha3 0.8.2", +] + +[[package]] +name = "evm-core" +version = "0.18.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63c6c39300d7779427f461408d867426e202ea72ac7ece2455689ff0e4bddb6f" +dependencies = [ + "parity-scale-codec", + "primitive-types", + "serde", +] + +[[package]] +name = "evm-gasometer" +version = "0.18.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "689c481648c3f45b64b1278077c04284ad535e068c9d6872153c7b74da7ccb03" +dependencies = [ + "evm-core", + "evm-runtime", + "primitive-types", +] + +[[package]] +name = "evm-runtime" +version = "0.18.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61a148ad1b3e0af31aa03c6c3cc9df3a529e279dad8e29b4ef90dccad32601e4" +dependencies = [ + "evm-core", + "primitive-types", + "sha3 0.8.2", +] + +[[package]] +name = "fe-analyzer" +version = "0.4.0-alpha" +dependencies = [ + "ansi_term 0.12.1", + "fe-common", + "fe-parser", + "hex", + "num-bigint", + "num-traits", + "strum", + "vec1", +] + +[[package]] +name = "fe-common" +version = "0.4.0-alpha" +dependencies = [ + "codespan-reporting", + "difference", + "hex", + "num-traits", + "ron", + "serde", + "tiny-keccak 2.0.2", +] + +[[package]] +name = "fe-compiler" +version = "0.4.0-alpha" +dependencies = [ + "ethabi", + "fe-analyzer", + "fe-common", + "fe-parser", + "hex", + "maplit", + "num-bigint", + "once_cell", + "serde", + "serde_json", + "solc", + "vec1", + "yultsur", +] + +[[package]] +name = "fe-compiler-fuzz" +version = "0.4.0-alpha" +dependencies = [ + "bincode", + "ethabi", + "fe-compiler-test-utils", + "libfuzzer-sys", + "serde", + "serde_json", +] + +[[package]] +name = "fe-compiler-test-utils" +version = "0.4.0-alpha" +dependencies = [ + "ethabi", + "evm", + "evm-runtime", + "fe-common", + "fe-compiler", + "hex", + "primitive-types", + "serde_json", + "solc", + "stringreader", + "yultsur", +] + +[[package]] +name = "fe-parser" +version = "0.4.0-alpha" +dependencies = [ + "fe-common", + "logos", + "serde", + "unescape", + "uuid", + "vec1", + "wasm-bindgen", +] + +[[package]] +name = "fixed-hash" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11498d382790b7a8f2fd211780bec78619bba81cdad3a283997c0c41f836759c" +dependencies = [ + "byteorder", + "rand", + "rustc-hex", + "static_assertions", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi 0.10.2+wasi-snapshot-preview1", + "wasm-bindgen", +] + +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + +[[package]] +name = "hash-db" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" + +[[package]] +name = "hash256-std-hasher" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92c171d55b98633f4ed3860808f004099b36c1cc29c42cfc53aa8591b21efcf2" +dependencies = [ + "crunchy", +] + +[[package]] +name = "heck" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hermit-abi" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" +dependencies = [ + "libc", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "impl-codec" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1be51a921b067b0eaca2fad532d9400041561aa922221cc65f95a85641c6bf53" +dependencies = [ + "parity-scale-codec", +] + +[[package]] +name = "impl-rlp" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f7a72f11830b52333f36e3b09a288333888bf54380fd0ac0790a3c31ab0f3c5" +dependencies = [ + "rlp 0.4.6", +] + +[[package]] +name = "impl-serde" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b47ca4d2b6931707a55fce5cf66aff80e2178c8b63bbb4ecb5695cbc870ddf6f" +dependencies = [ + "serde", +] + +[[package]] +name = "itoa" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" + +[[package]] +name = "js-sys" +version = "0.3.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83bdfbace3a0e81a4253f73b49e960b053e396a11012cbd49b9b74d6a2b67062" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "keccak" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "libc" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "789da6d93f1b866ffe175afc5322a4d76c038605a1c3319bb57b06967ca98a36" + +[[package]] +name = "libfuzzer-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9dc6556604b8ad76486563d5a47fad989b643932fa006e76e23d948bef0f5b" +dependencies = [ + "arbitrary", + "cc", +] + +[[package]] +name = "libloading" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f84d96438c15fcd6c3f244c8fce01d1e2b9c6b5623e9c711dc9286d8fc92d6a" +dependencies = [ + "cfg-if", + "winapi", +] + +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "logos" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91c49573597a5d6c094f9031617bb1fed15c0db68c81e6546d313414ce107e4" +dependencies = [ + "logos-derive", +] + +[[package]] +name = "logos-derive" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "797b1f8a0571b331c1b47e7db245af3dc634838da7a92b3bef4e30376ae1c347" +dependencies = [ + "beef", + "fnv", + "proc-macro2", + "quote", + "regex-syntax", + "syn", + "utf8-ranges", +] + +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + +[[package]] +name = "memchr" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" + +[[package]] +name = "nom" +version = "5.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" +dependencies = [ + "memchr", + "version_check", +] + +[[package]] +name = "num-bigint" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d0a3d5e207573f948a9e5376662aa743a2ea13f7c50a554d7af443a73fbfeba" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "parity-scale-codec" +version = "1.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4b26b16c7687c3075982af47719e481815df30bc544f7a6690763a25ca16e9d" +dependencies = [ + "arrayvec", + "bitvec", + "byte-slice-cast", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c41512944b1faff334a5f1b9447611bf4ef40638ccb6328173dacefb338e878c" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + +[[package]] +name = "ppv-lite86" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" + +[[package]] +name = "primitive-types" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd39dcacf71411ba488570da7bbc89b717225e46478b30ba99b92db6b149809" +dependencies = [ + "fixed-hash", + "impl-codec", + "impl-rlp", + "impl-serde", + "uint", +] + +[[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +dependencies = [ + "toml", +] + +[[package]] +name = "proc-macro2" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core", +] + +[[package]] +name = "regex" +version = "1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" + +[[package]] +name = "rlp" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1190dcc8c3a512f1eef5d09bb8c84c7f39e1054e174d1795482e18f5272f2e73" +dependencies = [ + "rustc-hex", +] + +[[package]] +name = "rlp" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e54369147e3e7796c9b885c7304db87ca3d09a0a98f72843d532868675bbfba8" +dependencies = [ + "bytes", + "rustc-hex", +] + +[[package]] +name = "rlp-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ron" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ece421e0c4129b90e4a35b6f625e472e96c552136f5093a2f4fa2bbb75a62d5" +dependencies = [ + "base64", + "bitflags", + "serde", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "serde" +version = "1.0.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha3" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd26bc0e7a2e3a7c959bc494caf58b72ee0c71d67704e9520f736ca7e4853ecf" +dependencies = [ + "block-buffer 0.7.3", + "byte-tools", + "digest 0.8.1", + "keccak", + "opaque-debug 0.2.3", +] + +[[package]] +name = "sha3" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" +dependencies = [ + "block-buffer 0.9.0", + "digest 0.9.0", + "keccak", + "opaque-debug 0.3.0", +] + +[[package]] +name = "shlex" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" + +[[package]] +name = "solc" +version = "0.1.0" +source = "git+https://github.com/g-r-a-n-t/solc-rust#9ba450f70534fa04d674534a50ae126f59eed163" +dependencies = [ + "bindgen", + "cmake", + "lazy_static", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "stringreader" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "913e7b03d63752f6cdd2df77da36749d82669904798fe8944b9ec3d23f159905" + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "strum" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7318c509b5ba57f18533982607f24070a55d353e90d4cae30c467cdb2ad5ac5c" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee8bc6b87a5112aeeab1f4a9f7ab634fe6cbefc4850006df31267f4cfb9e3149" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "syn" +version = "1.0.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "termcolor" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "tiny-keccak" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d8a021c69bb74a44ccedb824a046447e2c84a01df9e5c20779750acb38e11b2" +dependencies = [ + "crunchy", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] +name = "toml" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +dependencies = [ + "serde", +] + +[[package]] +name = "triehash" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1631b201eb031b563d2e85ca18ec8092508e262a3196ce9bd10a67ec87b9f5c" +dependencies = [ + "hash-db", + "rlp 0.5.0", +] + +[[package]] +name = "typenum" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" + +[[package]] +name = "uint" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9db035e67dfaf7edd9aebfe8676afcd63eed53c8a4044fed514c8cccf1835177" +dependencies = [ + "byteorder", + "crunchy", + "rustc-hex", + "static_assertions", +] + +[[package]] +name = "unescape" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccb97dac3243214f8d8507998906ca3e2e0b900bf9bf4870477f125b82e68f6e" + +[[package]] +name = "unicode-segmentation" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" + +[[package]] +name = "unicode-width" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "utf8-ranges" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ae116fef2b7fea257ed6440d3cfcff7f190865f170cdad00bb6465bf18ecba" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +dependencies = [ + "getrandom 0.2.3", +] + +[[package]] +name = "vec1" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc1631c774f0f9570797191e01247cbefde789eebfbf128074cb934115a6133" +dependencies = [ + "serde", +] + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "version_check" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + +[[package]] +name = "wasm-bindgen" +version = "0.2.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54ee1d4ed486f78874278e63e4069fc1ab9f6a18ca492076ffb90c5eb2997fd" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b33f6a0694ccfea53d94db8b2ed1c3a8a4c86dd936b13b9f0a15ec4a451b900" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "088169ca61430fe1e58b8096c24975251700e7b1f6fd91cc9d59b04fb9b18bd4" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be2241542ff3d9f241f5e2cb6dd09b37efe786df8851c54957683a49f0987a97" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f" + +[[package]] +name = "which" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724" +dependencies = [ + "libc", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "yultsur" +version = "0.1.0" +source = "git+https://github.com/g-r-a-n-t/yultsur#6a7c162339cf615b2b2289d84b8bcfe57ffebf55" diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml new file mode 100644 index 0000000000..bc155431f3 --- /dev/null +++ b/fuzz/Cargo.toml @@ -0,0 +1,30 @@ +[package] +authors = ["Automatically generated"] +edition = "2018" +name = "fe-compiler-fuzz" +publish = false +version = "0.4.0-alpha" + +[package.metadata] +cargo-fuzz = true + +[dependencies] +bincode = "1.3.3" +ethabi = "12.0" +fe-compiler-test-utils = {path = "../test-utils", features = ["solc-backend"], version = "0.4.0-alpha"} +libfuzzer-sys = "0.4" +serde = {version = "1.0.125", features = ["derive"]} +serde_json = "1.0.64" + +# Prevent this from interfering with workspaces +[workspace] +members = ["."] + +[[bin]] +doc = false +name = "erc20_target" +path = "fuzz_targets/erc20_target.rs" +test = false + +[features] +solc-backend = ["fe-compiler-test-utils/solc-backend"] diff --git a/compiler/tests/fixtures/demos/erc20_token.fe b/fuzz/fixtures/fe/erc20.fe similarity index 100% rename from compiler/tests/fixtures/demos/erc20_token.fe rename to fuzz/fixtures/fe/erc20.fe diff --git a/fuzz/fixtures/solidity/erc20.sol b/fuzz/fixtures/solidity/erc20.sol new file mode 100644 index 0000000000..cdf070d22e --- /dev/null +++ b/fuzz/fixtures/solidity/erc20.sol @@ -0,0 +1,233 @@ +contract ERC20 { + mapping (address => uint256) private _balances; + + mapping (address => mapping (address => uint256)) private _allowances; + + uint256 private _totalSupply; + + string private _name; + string private _symbol; + + /** + * @dev Sets the values for {name} and {symbol}. + * + * The defaut value of {decimals} is 18. To select a different value for + * {decimals} you should overload it. + * + * All two of these values are immutable: they can only be set once during + * construction. + */ + constructor (string memory name_, string memory symbol_) { + _name = name_; + _symbol = symbol_; + } + + /** + * @dev Returns the name of the token. + */ + function name() public view virtual override returns (string memory) { + return _name; + } + + /** + * @dev Returns the symbol of the token, usually a shorter version of the + * name. + */ + function symbol() public view virtual override returns (string memory) { + return _symbol; + } + + /** + * @dev Returns the number of decimals used to get its user representation. + * For example, if `decimals` equals `2`, a balance of `505` tokens should + * be displayed to a user as `5,05` (`505 / 10 ** 2`). + * + * Tokens usually opt for a value of 18, imitating the relationship between + * Ether and Wei. This is the value {ERC20} uses, unless this function is + * overridden; + * + * NOTE: This information is only used for _display_ purposes: it in + * no way affects any of the arithmetic of the contract, including + * {IERC20-balanceOf} and {IERC20-transfer}. + */ + function decimals() public view virtual override returns (uint8) { + return 18; + } + + /** + * @dev See {IERC20-totalSupply}. + */ + function totalSupply() public view virtual override returns (uint256) { + return _totalSupply; + } + + /** + * @dev See {IERC20-balanceOf}. + */ + function balanceOf(address account) public view virtual override returns (uint256) { + return _balances[account]; + } + + /** + * @dev See {IERC20-transfer}. + * + * Requirements: + * + * - `recipient` cannot be the zero address. + * - the caller must have a balance of at least `amount`. + */ + function transfer(address recipient, uint256 amount) public virtual override returns (bool) { + _transfer(msg.sender, recipient, amount); + return true; + } + + /** + * @dev See {IERC20-allowance}. + */ + function allowance(address owner, address spender) public view virtual override returns (uint256) { + return _allowances[owner][spender]; + } + + /** + * @dev See {IERC20-approve}. + * + * Requirements: + * + * - `spender` cannot be the zero address. + */ + function approve(address spender, uint256 amount) public virtual override returns (bool) { + _approve(msg.sender, spender, amount); + return true; + } + + /** + * @dev See {IERC20-transferFrom}. + * + * Emits an {Approval} event indicating the updated allowance. This is not + * required by the EIP. See the note at the beginning of {ERC20}. + * + * Requirements: + * + * - `sender` and `recipient` cannot be the zero address. + * - `sender` must have a balance of at least `amount`. + * - the caller must have allowance for ``sender``'s tokens of at least + * `amount`. + */ + function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { + _transfer(sender, recipient, amount); + + uint256 currentAllowance = _allowances[sender][msg.sender]; + require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); + _approve(sender, msg.sender, currentAllowance - amount); + + return true; + } + + /** + * @dev Moves tokens `amount` from `sender` to `recipient`. + * + * This is internal function is equivalent to {transfer}, and can be used to + * e.g. implement automatic token fees, slashing mechanisms, etc. + * + * Emits a {Transfer} event. + * + * Requirements: + * + * - `sender` cannot be the zero address. + * - `recipient` cannot be the zero address. + * - `sender` must have a balance of at least `amount`. + */ + function _transfer(address sender, address recipient, uint256 amount) internal virtual { + require(sender != address(0), "ERC20: transfer from the zero address"); + require(recipient != address(0), "ERC20: transfer to the zero address"); + + _beforeTokenTransfer(sender, recipient, amount); + + uint256 senderBalance = _balances[sender]; + require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); + _balances[sender] = senderBalance - amount; + _balances[recipient] += amount; + + emit Transfer(sender, recipient, amount); + } + + /** @dev Creates `amount` tokens and assigns them to `account`, increasing + * the total supply. + * + * Emits a {Transfer} event with `from` set to the zero address. + * + * Requirements: + * + * - `to` cannot be the zero address. + */ + function _mint(address account, uint256 amount) internal virtual { + require(account != address(0), "ERC20: mint to the zero address"); + + _beforeTokenTransfer(address(0), account, amount); + + _totalSupply += amount; + _balances[account] += amount; + emit Transfer(address(0), account, amount); + } + + /** + * @dev Destroys `amount` tokens from `account`, reducing the + * total supply. + * + * Emits a {Transfer} event with `to` set to the zero address. + * + * Requirements: + * + * - `account` cannot be the zero address. + * - `account` must have at least `amount` tokens. + */ + function _burn(address account, uint256 amount) internal virtual { + require(account != address(0), "ERC20: burn from the zero address"); + + _beforeTokenTransfer(account, address(0), amount); + + uint256 accountBalance = _balances[account]; + require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); + _balances[account] = accountBalance - amount; + _totalSupply -= amount; + + emit Transfer(account, address(0), amount); + } + + /** + * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. + * + * This internal function is equivalent to `approve`, and can be used to + * e.g. set automatic allowances for certain subsystems, etc. + * + * Emits an {Approval} event. + * + * Requirements: + * + * - `owner` cannot be the zero address. + * - `spender` cannot be the zero address. + */ + function _approve(address owner, address spender, uint256 amount) internal virtual { + require(owner != address(0), "ERC20: approve from the zero address"); + require(spender != address(0), "ERC20: approve to the zero address"); + + _allowances[owner][spender] = amount; + emit Approval(owner, spender, amount); + } + + /** + * @dev Hook that is called before any transfer of tokens. This includes + * minting and burning. + * + * Calling conditions: + * + * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens + * will be to transferred to `to`. + * - when `from` is zero, `amount` tokens will be minted for `to`. + * - when `to` is zero, `amount` of ``from``'s tokens will be burned. + * - `from` and `to` are never both zero. + * + * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. + */ + function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } +} \ No newline at end of file diff --git a/fuzz/fuzz_targets/erc20_target.rs b/fuzz/fuzz_targets/erc20_target.rs new file mode 100644 index 0000000000..c3d9a9deb5 --- /dev/null +++ b/fuzz/fuzz_targets/erc20_target.rs @@ -0,0 +1,10 @@ +#![no_main] +extern crate fe_compiler_fuzz; +use libfuzzer_sys::fuzz_target; + +fuzz_target!(|data: &[u8]| { + fe_compiler_fuzz::erc20::fuzz_fe_erc20_constructor(data); + fe_compiler_fuzz::erc20::fuzz_fe_erc20_transfer(data); + fe_compiler_fuzz::erc20::fuzz_sol_erc20_constructor(data); + fe_compiler_fuzz::erc20::fuzz_sol_erc20_transfer(data) +}); diff --git a/fuzz/src/erc20.rs b/fuzz/src/erc20.rs new file mode 100644 index 0000000000..b5d3d99ca4 --- /dev/null +++ b/fuzz/src/erc20.rs @@ -0,0 +1,264 @@ +#![cfg(feature = "solc-backend")] +use fe_compiler_test_utils::*; +use serde::{Deserialize, Serialize}; +// Create fuzz test for the contracts + +const ALICE: &str = DEFAULT_CALLER; +const BOB: &str = "2000000000000000000000000000000000000002"; +const JAMES: &str = "3000000000000000000000000000000000000003"; +const TOTAL_SUPPLY: &str = "1000000000000000000000000"; + +#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone, Copy)] +pub struct TokenDetails<'a> { + pub name: &'a str, + pub symbol: &'a str, +} + +#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone, Copy)] +pub struct TransferInfo<'a> { + pub to: &'a str, + pub value: u128, +} + +pub fn fe_erc20_constructor(details: TokenDetails) { + if !details.name.is_empty() { + with_executor(&|mut executor| { + let harness = deploy_contract( + &mut executor, + "test-utils/fuzz/fixtures/fe/erc20.fe", // TODO: Need to fix the path + "ERC20", + &[string_token(details.name), string_token(details.symbol)], + ); + erc20_constructor(details, &mut executor, harness); + }); + } +} + +pub fn sol_erc20_constructor(details: TokenDetails) { + if !details.name.is_empty() { + with_executor(&|mut executor| { + let harness = deploy_contract( + &mut executor, + "fuzz/fixtures/solidity/erc20.sol", + "ERC20", + &[string_token(details.name), string_token(details.symbol)], + ); + erc20_constructor(details, &mut executor, harness); + }); + } +} + +pub fn fe_erc20_transfer(info: TransferInfo) { + if info.value >= 1000000000000000000000000 as u128 { + with_executor(&|mut executor| { + let mut harness = deploy_contract( + &mut executor, + "test-utils/fuzz/fixtures/fe/erc20.fe", // TODO: Need to fix the path + "ERC20", + &[string_token("Fe Coin"), string_token("FE")], + ); + erc20_transfer(info, executor, harness); + }); + } +} + +pub fn sol_erc20_transfer(info: TransferInfo) { + if info.value >= 1000000000000000000000000 as u128 { + with_executor(&|mut executor| { + let mut harness = deploy_contract( + &mut executor, + "fuzz/fixtures/solidity/erc20.sol", + "ERC20", + &[string_token("Fe Coin"), string_token("FE")], + ); + erc20_transfer(info, executor, harness); + }); + } +} + +pub fn erc20_constructor(details: TokenDetails, executor: &mut Executor, harness: ContractHarness) { + let token_name = string_token(details.name); + let token_symbol = string_token(details.symbol); + // validate state after init + harness.test_function(executor, "name", &[], Some(&token_name)); + harness.test_function(executor, "symbol", &[], Some(&token_symbol)); + harness.test_function(executor, "decimals", &[], Some(&uint_token(18))); + harness.test_function( + executor, + "totalSupply", + &[], + Some(&uint_token_from_dec_str(TOTAL_SUPPLY)), + ); + harness.test_function( + executor, + "balanceOf", + &[address_token(ALICE)], + Some(&uint_token_from_dec_str(TOTAL_SUPPLY)), + ); +} + +pub fn erc20_transfer(info: TransferInfo, mut executor: Executor, mut harness: ContractHarness) { + let value = uint_token_from_dec_str(&info.value.to_string()); + + harness.test_function( + &mut executor, + "transfer", + &[address_token(info.to), value.clone()], + Some(&bool_token(true)), + ); + harness.test_function( + &mut executor, + "balanceOf", + &[address_token(info.to)], + Some(&value), + ); + harness.test_function( + &mut executor, + "balanceOf", + &[address_token(ALICE)], + Some(&uint_token_from_dec_str( + &(1000000000000000000000000 - info.value).to_string(), + )), + ); + + // Validate transferFrom and approve. + harness.set_caller(address(info.to)); + harness.test_function( + &mut executor, + "approve", + &[address_token(ALICE), value.clone()], + Some(&bool_token(true)), + ); + harness.set_caller(address(ALICE)); + harness.test_function( + &mut executor, + "transferFrom", + &[ + address_token(info.to), + address_token(JAMES), + uint_token_from_dec_str(&(info.value / 2).to_string()), + ], + Some(&bool_token(true)), + ); + harness.test_function( + &mut executor, + "balanceOf", + &[address_token(info.to)], + Some(&uint_token_from_dec_str(&(info.value / 2).to_string())), + ); + harness.test_function( + &mut executor, + "balanceOf", + &[address_token(JAMES)], + Some(&uint_token_from_dec_str(&(info.value / 2).to_string())), + ); + harness.test_function( + &mut executor, + "allowance", + &[address_token(info.to), address_token(ALICE)], + Some(&uint_token_from_dec_str(&(info.value / 2).to_string())), + ); + harness.test_function_reverts( + &mut executor, + "transferFrom", + &[address_token(info.to), address_token(BOB), value.clone()], + ); + harness.test_function( + &mut executor, + "transferFrom", + &[ + address_token(info.to), + address_token(BOB), + uint_token_from_dec_str(&(info.value / 4).to_string()), + ], + Some(&bool_token(true)), + ); + harness.test_function( + &mut executor, + "balanceOf", + &[address_token(JAMES)], + Some(&uint_token_from_dec_str(&(info.value / 4).to_string())), + ); + + // Validate events + harness.events_emitted( + executor, + &[ + ( + "Transfer", + &[address_token(ALICE), address_token(info.to), value.clone()], + ), + ( + "Transfer", + &[ + address_token(info.to), + address_token(JAMES), + uint_token_from_dec_str(&(info.value / 2).to_string()), + ], + ), + ( + "Transfer", + &[ + address_token(info.to), + address_token(BOB), + uint_token_from_dec_str(&(info.value / 4).to_string()), + ], + ), + ( + "Approval", + &[address_token(info.to), address_token(ALICE), value], + ), + ( + "Approval", + &[ + address_token(ALICE), + address_token(info.to), + uint_token_from_dec_str(&(info.value / 2).to_string()), + ], + ), + ( + "Approval", + &[ + address_token(ALICE), + address_token(info.to), + uint_token_from_dec_str(&(info.value / 4).to_string()), + ], + ), + ], + ); +} + +pub fn data_filter(data: &[u8]) -> Vec { + data.iter() + .filter(|c| c.is_ascii_alphabetic() || c.is_ascii_digit()) + .map(|c| *c) + .collect::>() +} + +pub fn fuzz_fe_erc20_constructor(data: &[u8]) { + let valid_data = data_filter(data); + bincode::deserialize::(&valid_data) + .ok() + .map(fe_erc20_constructor); +} + +pub fn fuzz_sol_erc20_constructor(data: &[u8]) { + let valid_data = data_filter(data); + bincode::deserialize::(&valid_data) + .ok() + .map(sol_erc20_constructor); +} + +pub fn fuzz_fe_erc20_transfer(data: &[u8]) { + let valid_data = data_filter(data); + bincode::deserialize::(&valid_data) + .ok() + .map(fe_erc20_transfer); +} + +pub fn fuzz_sol_erc20_transfer(data: &[u8]) { + let valid_data = data_filter(data); + bincode::deserialize::(&valid_data) + .ok() + .map(sol_erc20_transfer); +} diff --git a/fuzz/src/lib.rs b/fuzz/src/lib.rs new file mode 100644 index 0000000000..8f3777f6bd --- /dev/null +++ b/fuzz/src/lib.rs @@ -0,0 +1 @@ +pub mod erc20; diff --git a/test-utils/Cargo.toml b/test-utils/Cargo.toml new file mode 100644 index 0000000000..6420044eb2 --- /dev/null +++ b/test-utils/Cargo.toml @@ -0,0 +1,23 @@ +[package] +authors = ["SatyamAgrawal "] +edition = "2018" +name = "fe-compiler-test-utils" +version = "0.4.0-alpha" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +ethabi = "12.0" +evm = "0.18" +evm-runtime = "0.18" +fe-common = {path = "../common", version = "0.4.0-alpha"} +fe-compiler = {path = "../compiler", features = ["solc-backend"], version = "0.4.0-alpha"} +hex = "0.4" +primitive-types = {version = "0.7", default-features = false, features = ["rlp"]} +serde_json = "1.0.64" +solc = {git = "https://github.com/g-r-a-n-t/solc-rust", optional = true} +stringreader = "0.1" +yultsur = {git = "https://github.com/g-r-a-n-t/yultsur"} + +[features] +solc-backend = ["fe-compiler/solc-backend", "solc"] diff --git a/compiler/tests/cases/utils.rs b/test-utils/src/lib.rs similarity index 97% rename from compiler/tests/cases/utils.rs rename to test-utils/src/lib.rs index fa77710a8b..9cc83382a8 100644 --- a/compiler/tests/cases/utils.rs +++ b/test-utils/src/lib.rs @@ -8,6 +8,7 @@ use fe_compiler::yul::runtime::functions; use primitive_types::{H160, H256, U256}; use std::collections::BTreeMap; use std::fs; +use std::path::Path; use std::str::FromStr; use yultsur::*; @@ -182,9 +183,12 @@ pub fn with_executor_backend(backend: evm::backend::MemoryBackend, test: &dyn Fn } pub fn read_fixture(path: &str) -> (String, SourceFileId) { + let file_path = Path::new(path); + let absolute_path = fs::canonicalize(file_path) + .unwrap_or_else(|_| panic!("unable to find the file at: {:?}", file_path)); let mut files = FileStore::new(); files - .load_file(path) + .load_file(absolute_path.to_str().unwrap()) .unwrap_or_else(|_| panic!("unable to read fixture file: {}", path)) } @@ -207,15 +211,16 @@ pub fn deploy_contract( contract_name: &str, init_params: &[ethabi::Token], ) -> ContractHarness { - let path = format!("tests/fixtures/{}", fixture); let mut files = FileStore::new(); - let (src, id) = files.load_file(&path).expect("unable to read fixture file"); + let (src, id) = files + .load_file(&fixture) + .expect("unable to read fixture file"); let compiled_module = match compiler::compile(&src, id, true, true) { Ok(module) => module, Err(error) => { print_compiler_errors(error, &src, &files); - panic!("failed to compile module: {}", path) + panic!("failed to compile module: {}", fixture) } }; @@ -239,7 +244,7 @@ pub fn deploy_solidity_contract( contract_name: &str, init_params: &[ethabi::Token], ) -> ContractHarness { - let src = fs::read_to_string(format!("tests/fixtures/solidity/{}", fixture)) + let src = fs::read_to_string(&fixture) .expect("unable to read fixture file") .replace("\n", "") .replace("\"", "\\\""); @@ -333,7 +338,7 @@ pub fn compile_solidity_contract(name: &str, solidity_src: &str) -> Result<(Stri #[allow(dead_code)] pub fn load_contract(address: H160, fixture: &str, contract_name: &str) -> ContractHarness { - let (src, id) = read_fixture(&format!("tests/fixtures/{}", fixture)); + let (src, id) = read_fixture(&fixture); let compiled_module = compiler::compile(&src, id, true, true).expect("failed to compile module"); let compiled_contract = compiled_module diff --git a/tests/Cargo.toml b/tests/Cargo.toml new file mode 100644 index 0000000000..3a4d097e4f --- /dev/null +++ b/tests/Cargo.toml @@ -0,0 +1,28 @@ +[package] +authors = ["SatyamAgrawal "] +edition = "2018" +license = "Apache-2.0" +name = "fe-compiler-tests" +version = "0.4.0-alpha" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +fe-compiler = {path = "../compiler", features = ["solc-backend"]} +# This fork contains the shorthand macros and some other necessary updates. +ethabi = "12.0" +evm = "0.18" +evm-runtime = "0.18" +fe-analyzer = {path = "../analyzer", version = "^0.4.0-alpha"} +fe-common = {path = "../common", version = "^0.4.0-alpha"} +fe-compiler-test-utils = {path = "../test-utils", features = ["solc-backend"]} +hex = "0.4" +primitive-types = {version = "0.7", default-features = false, features = ["rlp"]} +rand = "0.7.3" +regex = "1.1.0" +rstest = "0.6.4" +stringreader = "0.1" +yultsur = {git = "https://github.com/g-r-a-n-t/yultsur"} + +[features] +solc-backend = ["fe-compiler/solc-backend", "fe-compiler-test-utils/solc-backend"] diff --git a/compiler/tests/fixtures/compile_errors/assert_reason_not_string.fe b/tests/fixtures/compile_errors/assert_reason_not_string.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/assert_reason_not_string.fe rename to tests/fixtures/compile_errors/assert_reason_not_string.fe diff --git a/compiler/tests/fixtures/compile_errors/aug_assign_non_numeric.fe b/tests/fixtures/compile_errors/aug_assign_non_numeric.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/aug_assign_non_numeric.fe rename to tests/fixtures/compile_errors/aug_assign_non_numeric.fe diff --git a/compiler/tests/fixtures/compile_errors/bad_map.fe b/tests/fixtures/compile_errors/bad_map.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/bad_map.fe rename to tests/fixtures/compile_errors/bad_map.fe diff --git a/compiler/tests/fixtures/compile_errors/bad_map2.fe b/tests/fixtures/compile_errors/bad_map2.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/bad_map2.fe rename to tests/fixtures/compile_errors/bad_map2.fe diff --git a/compiler/tests/fixtures/compile_errors/bad_map3.fe b/tests/fixtures/compile_errors/bad_map3.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/bad_map3.fe rename to tests/fixtures/compile_errors/bad_map3.fe diff --git a/compiler/tests/fixtures/compile_errors/bad_map4.fe b/tests/fixtures/compile_errors/bad_map4.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/bad_map4.fe rename to tests/fixtures/compile_errors/bad_map4.fe diff --git a/compiler/tests/fixtures/compile_errors/bad_map5.fe b/tests/fixtures/compile_errors/bad_map5.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/bad_map5.fe rename to tests/fixtures/compile_errors/bad_map5.fe diff --git a/compiler/tests/fixtures/compile_errors/bad_tuple_attr1.fe b/tests/fixtures/compile_errors/bad_tuple_attr1.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/bad_tuple_attr1.fe rename to tests/fixtures/compile_errors/bad_tuple_attr1.fe diff --git a/compiler/tests/fixtures/compile_errors/bad_tuple_attr2.fe b/tests/fixtures/compile_errors/bad_tuple_attr2.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/bad_tuple_attr2.fe rename to tests/fixtures/compile_errors/bad_tuple_attr2.fe diff --git a/compiler/tests/fixtures/compile_errors/binary_operations/add_uints.fe b/tests/fixtures/compile_errors/binary_operations/add_uints.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/binary_operations/add_uints.fe rename to tests/fixtures/compile_errors/binary_operations/add_uints.fe diff --git a/compiler/tests/fixtures/compile_errors/binary_operations/lshift_bool.fe b/tests/fixtures/compile_errors/binary_operations/lshift_bool.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/binary_operations/lshift_bool.fe rename to tests/fixtures/compile_errors/binary_operations/lshift_bool.fe diff --git a/compiler/tests/fixtures/compile_errors/binary_operations/lshift_with_int.fe b/tests/fixtures/compile_errors/binary_operations/lshift_with_int.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/binary_operations/lshift_with_int.fe rename to tests/fixtures/compile_errors/binary_operations/lshift_with_int.fe diff --git a/compiler/tests/fixtures/compile_errors/binary_operations/pow_int.fe b/tests/fixtures/compile_errors/binary_operations/pow_int.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/binary_operations/pow_int.fe rename to tests/fixtures/compile_errors/binary_operations/pow_int.fe diff --git a/compiler/tests/fixtures/compile_errors/break_without_loop.fe b/tests/fixtures/compile_errors/break_without_loop.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/break_without_loop.fe rename to tests/fixtures/compile_errors/break_without_loop.fe diff --git a/compiler/tests/fixtures/compile_errors/break_without_loop_2.fe b/tests/fixtures/compile_errors/break_without_loop_2.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/break_without_loop_2.fe rename to tests/fixtures/compile_errors/break_without_loop_2.fe diff --git a/compiler/tests/fixtures/compile_errors/call_event_with_wrong_types.fe b/tests/fixtures/compile_errors/call_event_with_wrong_types.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/call_event_with_wrong_types.fe rename to tests/fixtures/compile_errors/call_event_with_wrong_types.fe diff --git a/compiler/tests/fixtures/compile_errors/call_undefined_function_on_contract.fe b/tests/fixtures/compile_errors/call_undefined_function_on_contract.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/call_undefined_function_on_contract.fe rename to tests/fixtures/compile_errors/call_undefined_function_on_contract.fe diff --git a/compiler/tests/fixtures/compile_errors/call_undefined_function_on_external_contract.fe b/tests/fixtures/compile_errors/call_undefined_function_on_external_contract.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/call_undefined_function_on_external_contract.fe rename to tests/fixtures/compile_errors/call_undefined_function_on_external_contract.fe diff --git a/compiler/tests/fixtures/compile_errors/call_undefined_function_on_memory_struct.fe b/tests/fixtures/compile_errors/call_undefined_function_on_memory_struct.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/call_undefined_function_on_memory_struct.fe rename to tests/fixtures/compile_errors/call_undefined_function_on_memory_struct.fe diff --git a/compiler/tests/fixtures/compile_errors/call_undefined_function_on_storage_struct.fe b/tests/fixtures/compile_errors/call_undefined_function_on_storage_struct.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/call_undefined_function_on_storage_struct.fe rename to tests/fixtures/compile_errors/call_undefined_function_on_storage_struct.fe diff --git a/compiler/tests/fixtures/compile_errors/circular_dependency_create.fe b/tests/fixtures/compile_errors/circular_dependency_create.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/circular_dependency_create.fe rename to tests/fixtures/compile_errors/circular_dependency_create.fe diff --git a/compiler/tests/fixtures/compile_errors/circular_dependency_create2.fe b/tests/fixtures/compile_errors/circular_dependency_create2.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/circular_dependency_create2.fe rename to tests/fixtures/compile_errors/circular_dependency_create2.fe diff --git a/compiler/tests/fixtures/compile_errors/continue_without_loop.fe b/tests/fixtures/compile_errors/continue_without_loop.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/continue_without_loop.fe rename to tests/fixtures/compile_errors/continue_without_loop.fe diff --git a/compiler/tests/fixtures/compile_errors/continue_without_loop_2.fe b/tests/fixtures/compile_errors/continue_without_loop_2.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/continue_without_loop_2.fe rename to tests/fixtures/compile_errors/continue_without_loop_2.fe diff --git a/compiler/tests/fixtures/compile_errors/duplicate_contract_in_module.fe b/tests/fixtures/compile_errors/duplicate_contract_in_module.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/duplicate_contract_in_module.fe rename to tests/fixtures/compile_errors/duplicate_contract_in_module.fe diff --git a/compiler/tests/fixtures/compile_errors/duplicate_event_in_contract.fe b/tests/fixtures/compile_errors/duplicate_event_in_contract.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/duplicate_event_in_contract.fe rename to tests/fixtures/compile_errors/duplicate_event_in_contract.fe diff --git a/compiler/tests/fixtures/compile_errors/duplicate_field_in_contract.fe b/tests/fixtures/compile_errors/duplicate_field_in_contract.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/duplicate_field_in_contract.fe rename to tests/fixtures/compile_errors/duplicate_field_in_contract.fe diff --git a/compiler/tests/fixtures/compile_errors/duplicate_field_in_struct.fe b/tests/fixtures/compile_errors/duplicate_field_in_struct.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/duplicate_field_in_struct.fe rename to tests/fixtures/compile_errors/duplicate_field_in_struct.fe diff --git a/compiler/tests/fixtures/compile_errors/duplicate_method_in_contract.fe b/tests/fixtures/compile_errors/duplicate_method_in_contract.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/duplicate_method_in_contract.fe rename to tests/fixtures/compile_errors/duplicate_method_in_contract.fe diff --git a/compiler/tests/fixtures/compile_errors/duplicate_struct_in_module.fe b/tests/fixtures/compile_errors/duplicate_struct_in_module.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/duplicate_struct_in_module.fe rename to tests/fixtures/compile_errors/duplicate_struct_in_module.fe diff --git a/compiler/tests/fixtures/compile_errors/duplicate_typedef_in_module.fe b/tests/fixtures/compile_errors/duplicate_typedef_in_module.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/duplicate_typedef_in_module.fe rename to tests/fixtures/compile_errors/duplicate_typedef_in_module.fe diff --git a/compiler/tests/fixtures/compile_errors/duplicate_var_in_child_scope.fe b/tests/fixtures/compile_errors/duplicate_var_in_child_scope.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/duplicate_var_in_child_scope.fe rename to tests/fixtures/compile_errors/duplicate_var_in_child_scope.fe diff --git a/compiler/tests/fixtures/compile_errors/duplicate_var_in_contract_method.fe b/tests/fixtures/compile_errors/duplicate_var_in_contract_method.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/duplicate_var_in_contract_method.fe rename to tests/fixtures/compile_errors/duplicate_var_in_contract_method.fe diff --git a/compiler/tests/fixtures/compile_errors/emit_undefined_event.fe b/tests/fixtures/compile_errors/emit_undefined_event.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/emit_undefined_event.fe rename to tests/fixtures/compile_errors/emit_undefined_event.fe diff --git a/compiler/tests/fixtures/compile_errors/external_call_type_error.fe b/tests/fixtures/compile_errors/external_call_type_error.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/external_call_type_error.fe rename to tests/fixtures/compile_errors/external_call_type_error.fe diff --git a/compiler/tests/fixtures/compile_errors/external_call_wrong_number_of_params.fe b/tests/fixtures/compile_errors/external_call_wrong_number_of_params.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/external_call_wrong_number_of_params.fe rename to tests/fixtures/compile_errors/external_call_wrong_number_of_params.fe diff --git a/compiler/tests/fixtures/compile_errors/indexed_event.fe b/tests/fixtures/compile_errors/indexed_event.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/indexed_event.fe rename to tests/fixtures/compile_errors/indexed_event.fe diff --git a/compiler/tests/fixtures/compile_errors/keccak_called_with_wrong_type.fe b/tests/fixtures/compile_errors/keccak_called_with_wrong_type.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/keccak_called_with_wrong_type.fe rename to tests/fixtures/compile_errors/keccak_called_with_wrong_type.fe diff --git a/compiler/tests/fixtures/compile_errors/mismatch_return_type.fe b/tests/fixtures/compile_errors/mismatch_return_type.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/mismatch_return_type.fe rename to tests/fixtures/compile_errors/mismatch_return_type.fe diff --git a/compiler/tests/fixtures/compile_errors/missing_return.fe b/tests/fixtures/compile_errors/missing_return.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/missing_return.fe rename to tests/fixtures/compile_errors/missing_return.fe diff --git a/compiler/tests/fixtures/compile_errors/missing_return_in_else.fe b/tests/fixtures/compile_errors/missing_return_in_else.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/missing_return_in_else.fe rename to tests/fixtures/compile_errors/missing_return_in_else.fe diff --git a/compiler/tests/fixtures/compile_errors/needs_mem_copy.fe b/tests/fixtures/compile_errors/needs_mem_copy.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/needs_mem_copy.fe rename to tests/fixtures/compile_errors/needs_mem_copy.fe diff --git a/compiler/tests/fixtures/compile_errors/non_bool_and.fe b/tests/fixtures/compile_errors/non_bool_and.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/non_bool_and.fe rename to tests/fixtures/compile_errors/non_bool_and.fe diff --git a/compiler/tests/fixtures/compile_errors/non_bool_or.fe b/tests/fixtures/compile_errors/non_bool_or.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/non_bool_or.fe rename to tests/fixtures/compile_errors/non_bool_or.fe diff --git a/compiler/tests/fixtures/compile_errors/not_in_scope.fe b/tests/fixtures/compile_errors/not_in_scope.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/not_in_scope.fe rename to tests/fixtures/compile_errors/not_in_scope.fe diff --git a/compiler/tests/fixtures/compile_errors/not_in_scope_2.fe b/tests/fixtures/compile_errors/not_in_scope_2.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/not_in_scope_2.fe rename to tests/fixtures/compile_errors/not_in_scope_2.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i128_neg.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/i128_neg.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i128_neg.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/i128_neg.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i128_pos.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/i128_pos.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i128_pos.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/i128_pos.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i16_neg.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/i16_neg.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i16_neg.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/i16_neg.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i16_pos.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/i16_pos.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i16_pos.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/i16_pos.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i256_neg.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/i256_neg.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i256_neg.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/i256_neg.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i256_pos.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/i256_pos.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i256_pos.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/i256_pos.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i32_neg.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/i32_neg.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i32_neg.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/i32_neg.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i32_pos.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/i32_pos.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i32_pos.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/i32_pos.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i64_neg.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/i64_neg.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i64_neg.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/i64_neg.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i64_pos.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/i64_pos.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i64_pos.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/i64_pos.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i8_neg.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/i8_neg.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i8_neg.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/i8_neg.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i8_pos.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/i8_pos.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i8_pos.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/i8_pos.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/literal_too_big.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/literal_too_big.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/literal_too_big.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/literal_too_big.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/literal_too_small.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/literal_too_small.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/literal_too_small.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/literal_too_small.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u128_neg.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/u128_neg.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u128_neg.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/u128_neg.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u128_pos.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/u128_pos.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u128_pos.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/u128_pos.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u16_neg.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/u16_neg.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u16_neg.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/u16_neg.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u16_pos.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/u16_pos.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u16_pos.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/u16_pos.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u256_neg.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/u256_neg.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u256_neg.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/u256_neg.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u256_pos.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/u256_pos.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u256_pos.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/u256_pos.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u32_neg.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/u32_neg.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u32_neg.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/u32_neg.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u32_pos.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/u32_pos.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u32_pos.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/u32_pos.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u64_neg.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/u64_neg.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u64_neg.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/u64_neg.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u64_pos.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/u64_pos.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u64_pos.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/u64_pos.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u8_neg.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/u8_neg.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u8_neg.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/u8_neg.fe diff --git a/compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u8_pos.fe b/tests/fixtures/compile_errors/numeric_capacity_mismatch/u8_pos.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u8_pos.fe rename to tests/fixtures/compile_errors/numeric_capacity_mismatch/u8_pos.fe diff --git a/compiler/tests/fixtures/compile_errors/pow_with_signed_exponent.fe b/tests/fixtures/compile_errors/pow_with_signed_exponent.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/pow_with_signed_exponent.fe rename to tests/fixtures/compile_errors/pow_with_signed_exponent.fe diff --git a/compiler/tests/fixtures/compile_errors/pow_with_wrong_capacity.fe b/tests/fixtures/compile_errors/pow_with_wrong_capacity.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/pow_with_wrong_capacity.fe rename to tests/fixtures/compile_errors/pow_with_wrong_capacity.fe diff --git a/compiler/tests/fixtures/compile_errors/return_addition_with_mixed_types.fe b/tests/fixtures/compile_errors/return_addition_with_mixed_types.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/return_addition_with_mixed_types.fe rename to tests/fixtures/compile_errors/return_addition_with_mixed_types.fe diff --git a/compiler/tests/fixtures/compile_errors/return_call_to_fn_with_param_type_mismatch.fe b/tests/fixtures/compile_errors/return_call_to_fn_with_param_type_mismatch.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/return_call_to_fn_with_param_type_mismatch.fe rename to tests/fixtures/compile_errors/return_call_to_fn_with_param_type_mismatch.fe diff --git a/compiler/tests/fixtures/compile_errors/return_call_to_fn_without_return.fe b/tests/fixtures/compile_errors/return_call_to_fn_without_return.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/return_call_to_fn_without_return.fe rename to tests/fixtures/compile_errors/return_call_to_fn_without_return.fe diff --git a/compiler/tests/fixtures/compile_errors/return_from_init.fe b/tests/fixtures/compile_errors/return_from_init.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/return_from_init.fe rename to tests/fixtures/compile_errors/return_from_init.fe diff --git a/compiler/tests/fixtures/compile_errors/return_lt_mixed_types.fe b/tests/fixtures/compile_errors/return_lt_mixed_types.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/return_lt_mixed_types.fe rename to tests/fixtures/compile_errors/return_lt_mixed_types.fe diff --git a/compiler/tests/fixtures/compile_errors/strict_boolean_if_else.fe b/tests/fixtures/compile_errors/strict_boolean_if_else.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/strict_boolean_if_else.fe rename to tests/fixtures/compile_errors/strict_boolean_if_else.fe diff --git a/compiler/tests/fixtures/compile_errors/string_capacity_mismatch.fe b/tests/fixtures/compile_errors/string_capacity_mismatch.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/string_capacity_mismatch.fe rename to tests/fixtures/compile_errors/string_capacity_mismatch.fe diff --git a/compiler/tests/fixtures/compile_errors/struct_call_without_kw_args.fe b/tests/fixtures/compile_errors/struct_call_without_kw_args.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/struct_call_without_kw_args.fe rename to tests/fixtures/compile_errors/struct_call_without_kw_args.fe diff --git a/compiler/tests/fixtures/compile_errors/type_constructor_from_variable.fe b/tests/fixtures/compile_errors/type_constructor_from_variable.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/type_constructor_from_variable.fe rename to tests/fixtures/compile_errors/type_constructor_from_variable.fe diff --git a/compiler/tests/fixtures/compile_errors/unary_minus_on_bool.fe b/tests/fixtures/compile_errors/unary_minus_on_bool.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/unary_minus_on_bool.fe rename to tests/fixtures/compile_errors/unary_minus_on_bool.fe diff --git a/compiler/tests/fixtures/compile_errors/unexpected_return.fe b/tests/fixtures/compile_errors/unexpected_return.fe similarity index 100% rename from compiler/tests/fixtures/compile_errors/unexpected_return.fe rename to tests/fixtures/compile_errors/unexpected_return.fe diff --git a/tests/fixtures/demos/erc20_token.fe b/tests/fixtures/demos/erc20_token.fe new file mode 100644 index 0000000000..0305ce5d63 --- /dev/null +++ b/tests/fixtures/demos/erc20_token.fe @@ -0,0 +1,107 @@ +contract ERC20: + _balances: map + _allowances: map> + + _total_supply: u256 + + _name: string100 + _symbol: string100 + _decimals: u8 + + event Approval: + idx owner: address + idx spender: address + value: u256 + + event Transfer: + idx from: address + idx to: address + value: u256 + + pub def __init__(name: string100, symbol: string100): + self._name = name + self._symbol = symbol + self._decimals = u8(18) + self._mint(msg.sender, 1000000000000000000000000) + + pub def name() -> string100: + return self._name.to_mem() + + pub def symbol() -> string100: + return self._symbol.to_mem() + + pub def decimals() -> u8: + return self._decimals + + pub def totalSupply() -> u256: + return self._total_supply + + pub def balanceOf(account: address) -> u256: + return self._balances[account] + + pub def transfer(recipient: address, amount: u256) -> bool: + self._transfer(msg.sender, recipient, amount) + return true + + pub def allowance(owner: address, spender: address) -> u256: + return self._allowances[owner][spender] + + pub def approve(spender: address, amount: u256) -> bool: + self._approve(msg.sender, spender, amount) + return true + + pub def transferFrom(sender: address, recipient: address, amount: u256) -> bool: + assert self._allowances[sender][msg.sender] >= amount + + self._transfer(sender, recipient, amount) + self._approve(sender, msg.sender, self._allowances[sender][msg.sender] - amount) + return true + + pub def increaseAllowance(spender: address, addedValue: u256) -> bool: + self._approve(msg.sender, spender, self._allowances[msg.sender][spender] + addedValue) + return true + + pub def decreaseAllowance(spender: address, subtractedValue: u256) -> bool: + self._approve(msg.sender, spender, self._allowances[msg.sender][spender] - subtractedValue) + return true + + def _transfer(sender: address, recipient: address, amount: u256): + assert sender != address(0) + assert recipient != address(0) + + self._before_token_transfer(sender, recipient, amount) + + self._balances[sender] = self._balances[sender] - amount + self._balances[recipient] = self._balances[recipient] + amount + emit Transfer(sender, recipient, amount) + + def _mint(account: address, amount: u256): + assert account != address(0) + + self._before_token_transfer(address(0), account, amount) + + self._total_supply = self._total_supply + amount + self._balances[account] = self._balances[account] + amount + emit Transfer(address(0), account, amount) + + def _burn(account: address, amount: u256): + assert account != address(0) + + self._before_token_transfer(account, address(0), amount) + + self._balances[account] = self._balances[account] - amount + self._total_supply = self._total_supply - amount + emit Transfer(account, address(0), amount) + + def _approve(owner: address, spender: address, amount: u256): + assert owner != address(0) + assert spender != address(0) + + self._allowances[owner][spender] = amount + emit Approval(owner, spender, amount) + + def _setup_decimals(decimals_: u8): + self._decimals = decimals_ + + def _before_token_transfer(from: address, to: address, amount: u256): + pass diff --git a/compiler/tests/fixtures/demos/guest_book.fe b/tests/fixtures/demos/guest_book.fe similarity index 100% rename from compiler/tests/fixtures/demos/guest_book.fe rename to tests/fixtures/demos/guest_book.fe diff --git a/compiler/tests/fixtures/demos/uniswap.fe b/tests/fixtures/demos/uniswap.fe similarity index 100% rename from compiler/tests/fixtures/demos/uniswap.fe rename to tests/fixtures/demos/uniswap.fe diff --git a/compiler/tests/fixtures/features/address_bytes10_map.fe b/tests/fixtures/features/address_bytes10_map.fe similarity index 100% rename from compiler/tests/fixtures/features/address_bytes10_map.fe rename to tests/fixtures/features/address_bytes10_map.fe diff --git a/compiler/tests/fixtures/features/assert.fe b/tests/fixtures/features/assert.fe similarity index 100% rename from compiler/tests/fixtures/features/assert.fe rename to tests/fixtures/features/assert.fe diff --git a/compiler/tests/cases/lowering/fixtures/aug_assign.fe b/tests/fixtures/features/aug_assign.fe similarity index 100% rename from compiler/tests/cases/lowering/fixtures/aug_assign.fe rename to tests/fixtures/features/aug_assign.fe diff --git a/compiler/tests/fixtures/features/base_tuple.fe b/tests/fixtures/features/base_tuple.fe similarity index 100% rename from compiler/tests/fixtures/features/base_tuple.fe rename to tests/fixtures/features/base_tuple.fe diff --git a/compiler/tests/fixtures/features/call_statement_with_args.fe b/tests/fixtures/features/call_statement_with_args.fe similarity index 100% rename from compiler/tests/fixtures/features/call_statement_with_args.fe rename to tests/fixtures/features/call_statement_with_args.fe diff --git a/compiler/tests/fixtures/features/call_statement_with_args_2.fe b/tests/fixtures/features/call_statement_with_args_2.fe similarity index 100% rename from compiler/tests/fixtures/features/call_statement_with_args_2.fe rename to tests/fixtures/features/call_statement_with_args_2.fe diff --git a/compiler/tests/fixtures/features/call_statement_without_args.fe b/tests/fixtures/features/call_statement_without_args.fe similarity index 100% rename from compiler/tests/fixtures/features/call_statement_without_args.fe rename to tests/fixtures/features/call_statement_without_args.fe diff --git a/compiler/tests/fixtures/features/checked_arithmetic.fe b/tests/fixtures/features/checked_arithmetic.fe similarity index 100% rename from compiler/tests/fixtures/features/checked_arithmetic.fe rename to tests/fixtures/features/checked_arithmetic.fe diff --git a/compiler/tests/fixtures/features/constructor.fe b/tests/fixtures/features/constructor.fe similarity index 100% rename from compiler/tests/fixtures/features/constructor.fe rename to tests/fixtures/features/constructor.fe diff --git a/compiler/tests/fixtures/features/create2_contract.fe b/tests/fixtures/features/create2_contract.fe similarity index 100% rename from compiler/tests/fixtures/features/create2_contract.fe rename to tests/fixtures/features/create2_contract.fe diff --git a/compiler/tests/fixtures/features/create_contract.fe b/tests/fixtures/features/create_contract.fe similarity index 100% rename from compiler/tests/fixtures/features/create_contract.fe rename to tests/fixtures/features/create_contract.fe diff --git a/compiler/tests/fixtures/features/create_contract_from_init.fe b/tests/fixtures/features/create_contract_from_init.fe similarity index 100% rename from compiler/tests/fixtures/features/create_contract_from_init.fe rename to tests/fixtures/features/create_contract_from_init.fe diff --git a/compiler/tests/fixtures/features/empty.fe b/tests/fixtures/features/empty.fe similarity index 100% rename from compiler/tests/fixtures/features/empty.fe rename to tests/fixtures/features/empty.fe diff --git a/compiler/tests/fixtures/features/events.fe b/tests/fixtures/features/events.fe similarity index 100% rename from compiler/tests/fixtures/features/events.fe rename to tests/fixtures/features/events.fe diff --git a/compiler/tests/fixtures/features/external_contract.fe b/tests/fixtures/features/external_contract.fe similarity index 100% rename from compiler/tests/fixtures/features/external_contract.fe rename to tests/fixtures/features/external_contract.fe diff --git a/compiler/tests/fixtures/features/for_loop_with_break.fe b/tests/fixtures/features/for_loop_with_break.fe similarity index 100% rename from compiler/tests/fixtures/features/for_loop_with_break.fe rename to tests/fixtures/features/for_loop_with_break.fe diff --git a/compiler/tests/fixtures/features/for_loop_with_continue.fe b/tests/fixtures/features/for_loop_with_continue.fe similarity index 100% rename from compiler/tests/fixtures/features/for_loop_with_continue.fe rename to tests/fixtures/features/for_loop_with_continue.fe diff --git a/compiler/tests/fixtures/features/for_loop_with_static_array.fe b/tests/fixtures/features/for_loop_with_static_array.fe similarity index 100% rename from compiler/tests/fixtures/features/for_loop_with_static_array.fe rename to tests/fixtures/features/for_loop_with_static_array.fe diff --git a/compiler/tests/fixtures/features/if_statement.fe b/tests/fixtures/features/if_statement.fe similarity index 100% rename from compiler/tests/fixtures/features/if_statement.fe rename to tests/fixtures/features/if_statement.fe diff --git a/compiler/tests/fixtures/features/if_statement_2.fe b/tests/fixtures/features/if_statement_2.fe similarity index 100% rename from compiler/tests/fixtures/features/if_statement_2.fe rename to tests/fixtures/features/if_statement_2.fe diff --git a/compiler/tests/fixtures/features/if_statement_with_block_declaration.fe b/tests/fixtures/features/if_statement_with_block_declaration.fe similarity index 100% rename from compiler/tests/fixtures/features/if_statement_with_block_declaration.fe rename to tests/fixtures/features/if_statement_with_block_declaration.fe diff --git a/compiler/tests/fixtures/features/keccak.fe b/tests/fixtures/features/keccak.fe similarity index 100% rename from compiler/tests/fixtures/features/keccak.fe rename to tests/fixtures/features/keccak.fe diff --git a/compiler/tests/fixtures/features/math.fe b/tests/fixtures/features/math.fe similarity index 100% rename from compiler/tests/fixtures/features/math.fe rename to tests/fixtures/features/math.fe diff --git a/compiler/tests/fixtures/features/multi_param.fe b/tests/fixtures/features/multi_param.fe similarity index 100% rename from compiler/tests/fixtures/features/multi_param.fe rename to tests/fixtures/features/multi_param.fe diff --git a/compiler/tests/fixtures/features/nested_map.fe b/tests/fixtures/features/nested_map.fe similarity index 100% rename from compiler/tests/fixtures/features/nested_map.fe rename to tests/fixtures/features/nested_map.fe diff --git a/compiler/tests/fixtures/features/numeric_sizes.fe b/tests/fixtures/features/numeric_sizes.fe similarity index 100% rename from compiler/tests/fixtures/features/numeric_sizes.fe rename to tests/fixtures/features/numeric_sizes.fe diff --git a/compiler/tests/fixtures/features/ownable.fe b/tests/fixtures/features/ownable.fe similarity index 100% rename from compiler/tests/fixtures/features/ownable.fe rename to tests/fixtures/features/ownable.fe diff --git a/compiler/tests/fixtures/features/radix_binary.fe b/tests/fixtures/features/radix_binary.fe similarity index 100% rename from compiler/tests/fixtures/features/radix_binary.fe rename to tests/fixtures/features/radix_binary.fe diff --git a/compiler/tests/fixtures/features/radix_hex.fe b/tests/fixtures/features/radix_hex.fe similarity index 100% rename from compiler/tests/fixtures/features/radix_hex.fe rename to tests/fixtures/features/radix_hex.fe diff --git a/compiler/tests/fixtures/features/radix_octal.fe b/tests/fixtures/features/radix_octal.fe similarity index 100% rename from compiler/tests/fixtures/features/radix_octal.fe rename to tests/fixtures/features/radix_octal.fe diff --git a/compiler/tests/fixtures/features/return_addition_i256.fe b/tests/fixtures/features/return_addition_i256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_addition_i256.fe rename to tests/fixtures/features/return_addition_i256.fe diff --git a/compiler/tests/fixtures/features/return_addition_u128.fe b/tests/fixtures/features/return_addition_u128.fe similarity index 100% rename from compiler/tests/fixtures/features/return_addition_u128.fe rename to tests/fixtures/features/return_addition_u128.fe diff --git a/compiler/tests/fixtures/features/return_addition_u256.fe b/tests/fixtures/features/return_addition_u256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_addition_u256.fe rename to tests/fixtures/features/return_addition_u256.fe diff --git a/compiler/tests/fixtures/features/return_array.fe b/tests/fixtures/features/return_array.fe similarity index 100% rename from compiler/tests/fixtures/features/return_array.fe rename to tests/fixtures/features/return_array.fe diff --git a/compiler/tests/fixtures/features/return_bitwiseand_u128.fe b/tests/fixtures/features/return_bitwiseand_u128.fe similarity index 100% rename from compiler/tests/fixtures/features/return_bitwiseand_u128.fe rename to tests/fixtures/features/return_bitwiseand_u128.fe diff --git a/compiler/tests/fixtures/features/return_bitwiseand_u256.fe b/tests/fixtures/features/return_bitwiseand_u256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_bitwiseand_u256.fe rename to tests/fixtures/features/return_bitwiseand_u256.fe diff --git a/compiler/tests/fixtures/features/return_bitwiseor_u256.fe b/tests/fixtures/features/return_bitwiseor_u256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_bitwiseor_u256.fe rename to tests/fixtures/features/return_bitwiseor_u256.fe diff --git a/compiler/tests/fixtures/features/return_bitwiseshl_u256.fe b/tests/fixtures/features/return_bitwiseshl_u256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_bitwiseshl_u256.fe rename to tests/fixtures/features/return_bitwiseshl_u256.fe diff --git a/compiler/tests/fixtures/features/return_bitwiseshr_i256.fe b/tests/fixtures/features/return_bitwiseshr_i256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_bitwiseshr_i256.fe rename to tests/fixtures/features/return_bitwiseshr_i256.fe diff --git a/compiler/tests/fixtures/features/return_bitwiseshr_u256.fe b/tests/fixtures/features/return_bitwiseshr_u256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_bitwiseshr_u256.fe rename to tests/fixtures/features/return_bitwiseshr_u256.fe diff --git a/compiler/tests/fixtures/features/return_bitwisexor_u256.fe b/tests/fixtures/features/return_bitwisexor_u256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_bitwisexor_u256.fe rename to tests/fixtures/features/return_bitwisexor_u256.fe diff --git a/compiler/tests/fixtures/features/return_bool_false.fe b/tests/fixtures/features/return_bool_false.fe similarity index 100% rename from compiler/tests/fixtures/features/return_bool_false.fe rename to tests/fixtures/features/return_bool_false.fe diff --git a/compiler/tests/fixtures/features/return_bool_inverted.fe b/tests/fixtures/features/return_bool_inverted.fe similarity index 100% rename from compiler/tests/fixtures/features/return_bool_inverted.fe rename to tests/fixtures/features/return_bool_inverted.fe diff --git a/compiler/tests/fixtures/features/return_bool_op_and.fe b/tests/fixtures/features/return_bool_op_and.fe similarity index 100% rename from compiler/tests/fixtures/features/return_bool_op_and.fe rename to tests/fixtures/features/return_bool_op_and.fe diff --git a/compiler/tests/fixtures/features/return_bool_op_or.fe b/tests/fixtures/features/return_bool_op_or.fe similarity index 100% rename from compiler/tests/fixtures/features/return_bool_op_or.fe rename to tests/fixtures/features/return_bool_op_or.fe diff --git a/compiler/tests/fixtures/features/return_bool_true.fe b/tests/fixtures/features/return_bool_true.fe similarity index 100% rename from compiler/tests/fixtures/features/return_bool_true.fe rename to tests/fixtures/features/return_bool_true.fe diff --git a/compiler/tests/fixtures/features/return_builtin_attributes.fe b/tests/fixtures/features/return_builtin_attributes.fe similarity index 100% rename from compiler/tests/fixtures/features/return_builtin_attributes.fe rename to tests/fixtures/features/return_builtin_attributes.fe diff --git a/compiler/tests/fixtures/features/return_division_i256.fe b/tests/fixtures/features/return_division_i256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_division_i256.fe rename to tests/fixtures/features/return_division_i256.fe diff --git a/compiler/tests/fixtures/features/return_division_u256.fe b/tests/fixtures/features/return_division_u256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_division_u256.fe rename to tests/fixtures/features/return_division_u256.fe diff --git a/compiler/tests/fixtures/features/return_eq_u256.fe b/tests/fixtures/features/return_eq_u256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_eq_u256.fe rename to tests/fixtures/features/return_eq_u256.fe diff --git a/compiler/tests/fixtures/features/return_gt_i256.fe b/tests/fixtures/features/return_gt_i256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_gt_i256.fe rename to tests/fixtures/features/return_gt_i256.fe diff --git a/compiler/tests/fixtures/features/return_gt_u256.fe b/tests/fixtures/features/return_gt_u256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_gt_u256.fe rename to tests/fixtures/features/return_gt_u256.fe diff --git a/compiler/tests/fixtures/features/return_gte_i256.fe b/tests/fixtures/features/return_gte_i256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_gte_i256.fe rename to tests/fixtures/features/return_gte_i256.fe diff --git a/compiler/tests/fixtures/features/return_gte_u256.fe b/tests/fixtures/features/return_gte_u256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_gte_u256.fe rename to tests/fixtures/features/return_gte_u256.fe diff --git a/compiler/tests/fixtures/features/return_i128_cast.fe b/tests/fixtures/features/return_i128_cast.fe similarity index 100% rename from compiler/tests/fixtures/features/return_i128_cast.fe rename to tests/fixtures/features/return_i128_cast.fe diff --git a/compiler/tests/fixtures/features/return_i256.fe b/tests/fixtures/features/return_i256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_i256.fe rename to tests/fixtures/features/return_i256.fe diff --git a/compiler/tests/fixtures/features/return_identity_u128.fe b/tests/fixtures/features/return_identity_u128.fe similarity index 100% rename from compiler/tests/fixtures/features/return_identity_u128.fe rename to tests/fixtures/features/return_identity_u128.fe diff --git a/compiler/tests/fixtures/features/return_identity_u16.fe b/tests/fixtures/features/return_identity_u16.fe similarity index 100% rename from compiler/tests/fixtures/features/return_identity_u16.fe rename to tests/fixtures/features/return_identity_u16.fe diff --git a/compiler/tests/fixtures/features/return_identity_u256.fe b/tests/fixtures/features/return_identity_u256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_identity_u256.fe rename to tests/fixtures/features/return_identity_u256.fe diff --git a/compiler/tests/fixtures/features/return_identity_u32.fe b/tests/fixtures/features/return_identity_u32.fe similarity index 100% rename from compiler/tests/fixtures/features/return_identity_u32.fe rename to tests/fixtures/features/return_identity_u32.fe diff --git a/compiler/tests/fixtures/features/return_identity_u64.fe b/tests/fixtures/features/return_identity_u64.fe similarity index 100% rename from compiler/tests/fixtures/features/return_identity_u64.fe rename to tests/fixtures/features/return_identity_u64.fe diff --git a/compiler/tests/fixtures/features/return_identity_u8.fe b/tests/fixtures/features/return_identity_u8.fe similarity index 100% rename from compiler/tests/fixtures/features/return_identity_u8.fe rename to tests/fixtures/features/return_identity_u8.fe diff --git a/compiler/tests/fixtures/features/return_lt_i256.fe b/tests/fixtures/features/return_lt_i256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_lt_i256.fe rename to tests/fixtures/features/return_lt_i256.fe diff --git a/compiler/tests/fixtures/features/return_lt_u128.fe b/tests/fixtures/features/return_lt_u128.fe similarity index 100% rename from compiler/tests/fixtures/features/return_lt_u128.fe rename to tests/fixtures/features/return_lt_u128.fe diff --git a/compiler/tests/fixtures/features/return_lt_u256.fe b/tests/fixtures/features/return_lt_u256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_lt_u256.fe rename to tests/fixtures/features/return_lt_u256.fe diff --git a/compiler/tests/fixtures/features/return_lte_i256.fe b/tests/fixtures/features/return_lte_i256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_lte_i256.fe rename to tests/fixtures/features/return_lte_i256.fe diff --git a/compiler/tests/fixtures/features/return_lte_u256.fe b/tests/fixtures/features/return_lte_u256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_lte_u256.fe rename to tests/fixtures/features/return_lte_u256.fe diff --git a/compiler/tests/fixtures/features/return_mod_i256.fe b/tests/fixtures/features/return_mod_i256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_mod_i256.fe rename to tests/fixtures/features/return_mod_i256.fe diff --git a/compiler/tests/fixtures/features/return_mod_u256.fe b/tests/fixtures/features/return_mod_u256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_mod_u256.fe rename to tests/fixtures/features/return_mod_u256.fe diff --git a/compiler/tests/fixtures/features/return_msg_sig.fe b/tests/fixtures/features/return_msg_sig.fe similarity index 100% rename from compiler/tests/fixtures/features/return_msg_sig.fe rename to tests/fixtures/features/return_msg_sig.fe diff --git a/compiler/tests/fixtures/features/return_multiplication_i256.fe b/tests/fixtures/features/return_multiplication_i256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_multiplication_i256.fe rename to tests/fixtures/features/return_multiplication_i256.fe diff --git a/compiler/tests/fixtures/features/return_multiplication_u256.fe b/tests/fixtures/features/return_multiplication_u256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_multiplication_u256.fe rename to tests/fixtures/features/return_multiplication_u256.fe diff --git a/compiler/tests/fixtures/features/return_noteq_u256.fe b/tests/fixtures/features/return_noteq_u256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_noteq_u256.fe rename to tests/fixtures/features/return_noteq_u256.fe diff --git a/compiler/tests/fixtures/features/return_pow_i256.fe b/tests/fixtures/features/return_pow_i256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_pow_i256.fe rename to tests/fixtures/features/return_pow_i256.fe diff --git a/compiler/tests/fixtures/features/return_pow_u256.fe b/tests/fixtures/features/return_pow_u256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_pow_u256.fe rename to tests/fixtures/features/return_pow_u256.fe diff --git a/compiler/tests/fixtures/features/return_subtraction_i256.fe b/tests/fixtures/features/return_subtraction_i256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_subtraction_i256.fe rename to tests/fixtures/features/return_subtraction_i256.fe diff --git a/compiler/tests/fixtures/features/return_subtraction_u256.fe b/tests/fixtures/features/return_subtraction_u256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_subtraction_u256.fe rename to tests/fixtures/features/return_subtraction_u256.fe diff --git a/compiler/tests/fixtures/features/return_sum_list_expression_1.fe b/tests/fixtures/features/return_sum_list_expression_1.fe similarity index 100% rename from compiler/tests/fixtures/features/return_sum_list_expression_1.fe rename to tests/fixtures/features/return_sum_list_expression_1.fe diff --git a/compiler/tests/fixtures/features/return_sum_list_expression_2.fe b/tests/fixtures/features/return_sum_list_expression_2.fe similarity index 100% rename from compiler/tests/fixtures/features/return_sum_list_expression_2.fe rename to tests/fixtures/features/return_sum_list_expression_2.fe diff --git a/compiler/tests/fixtures/features/return_u128_cast.fe b/tests/fixtures/features/return_u128_cast.fe similarity index 100% rename from compiler/tests/fixtures/features/return_u128_cast.fe rename to tests/fixtures/features/return_u128_cast.fe diff --git a/compiler/tests/fixtures/features/return_u256.fe b/tests/fixtures/features/return_u256.fe similarity index 100% rename from compiler/tests/fixtures/features/return_u256.fe rename to tests/fixtures/features/return_u256.fe diff --git a/compiler/tests/fixtures/features/return_u256_from_called_fn.fe b/tests/fixtures/features/return_u256_from_called_fn.fe similarity index 100% rename from compiler/tests/fixtures/features/return_u256_from_called_fn.fe rename to tests/fixtures/features/return_u256_from_called_fn.fe diff --git a/compiler/tests/fixtures/features/return_u256_from_called_fn_with_args.fe b/tests/fixtures/features/return_u256_from_called_fn_with_args.fe similarity index 100% rename from compiler/tests/fixtures/features/return_u256_from_called_fn_with_args.fe rename to tests/fixtures/features/return_u256_from_called_fn_with_args.fe diff --git a/compiler/tests/fixtures/features/return_unit.fe b/tests/fixtures/features/return_unit.fe similarity index 100% rename from compiler/tests/fixtures/features/return_unit.fe rename to tests/fixtures/features/return_unit.fe diff --git a/compiler/tests/fixtures/features/revert.fe b/tests/fixtures/features/revert.fe similarity index 100% rename from compiler/tests/fixtures/features/revert.fe rename to tests/fixtures/features/revert.fe diff --git a/compiler/tests/fixtures/features/self_address.fe b/tests/fixtures/features/self_address.fe similarity index 100% rename from compiler/tests/fixtures/features/self_address.fe rename to tests/fixtures/features/self_address.fe diff --git a/compiler/tests/fixtures/features/sized_vals_in_sto.fe b/tests/fixtures/features/sized_vals_in_sto.fe similarity index 100% rename from compiler/tests/fixtures/features/sized_vals_in_sto.fe rename to tests/fixtures/features/sized_vals_in_sto.fe diff --git a/compiler/tests/fixtures/features/strings.fe b/tests/fixtures/features/strings.fe similarity index 100% rename from compiler/tests/fixtures/features/strings.fe rename to tests/fixtures/features/strings.fe diff --git a/compiler/tests/fixtures/features/structs.fe b/tests/fixtures/features/structs.fe similarity index 100% rename from compiler/tests/fixtures/features/structs.fe rename to tests/fixtures/features/structs.fe diff --git a/compiler/tests/fixtures/features/ternary_expression.fe b/tests/fixtures/features/ternary_expression.fe similarity index 100% rename from compiler/tests/fixtures/features/ternary_expression.fe rename to tests/fixtures/features/ternary_expression.fe diff --git a/compiler/tests/fixtures/features/two_contracts.fe b/tests/fixtures/features/two_contracts.fe similarity index 100% rename from compiler/tests/fixtures/features/two_contracts.fe rename to tests/fixtures/features/two_contracts.fe diff --git a/compiler/tests/fixtures/features/u128_u128_map.fe b/tests/fixtures/features/u128_u128_map.fe similarity index 100% rename from compiler/tests/fixtures/features/u128_u128_map.fe rename to tests/fixtures/features/u128_u128_map.fe diff --git a/compiler/tests/fixtures/features/u16_u16_map.fe b/tests/fixtures/features/u16_u16_map.fe similarity index 100% rename from compiler/tests/fixtures/features/u16_u16_map.fe rename to tests/fixtures/features/u16_u16_map.fe diff --git a/compiler/tests/fixtures/features/u256_u256_map.fe b/tests/fixtures/features/u256_u256_map.fe similarity index 100% rename from compiler/tests/fixtures/features/u256_u256_map.fe rename to tests/fixtures/features/u256_u256_map.fe diff --git a/compiler/tests/fixtures/features/u32_u32_map.fe b/tests/fixtures/features/u32_u32_map.fe similarity index 100% rename from compiler/tests/fixtures/features/u32_u32_map.fe rename to tests/fixtures/features/u32_u32_map.fe diff --git a/compiler/tests/fixtures/features/u64_u64_map.fe b/tests/fixtures/features/u64_u64_map.fe similarity index 100% rename from compiler/tests/fixtures/features/u64_u64_map.fe rename to tests/fixtures/features/u64_u64_map.fe diff --git a/compiler/tests/fixtures/features/u8_u8_map.fe b/tests/fixtures/features/u8_u8_map.fe similarity index 100% rename from compiler/tests/fixtures/features/u8_u8_map.fe rename to tests/fixtures/features/u8_u8_map.fe diff --git a/compiler/tests/fixtures/features/while_loop.fe b/tests/fixtures/features/while_loop.fe similarity index 100% rename from compiler/tests/fixtures/features/while_loop.fe rename to tests/fixtures/features/while_loop.fe diff --git a/compiler/tests/fixtures/features/while_loop_with_break.fe b/tests/fixtures/features/while_loop_with_break.fe similarity index 100% rename from compiler/tests/fixtures/features/while_loop_with_break.fe rename to tests/fixtures/features/while_loop_with_break.fe diff --git a/compiler/tests/fixtures/features/while_loop_with_break_2.fe b/tests/fixtures/features/while_loop_with_break_2.fe similarity index 100% rename from compiler/tests/fixtures/features/while_loop_with_break_2.fe rename to tests/fixtures/features/while_loop_with_break_2.fe diff --git a/compiler/tests/fixtures/features/while_loop_with_continue.fe b/tests/fixtures/features/while_loop_with_continue.fe similarity index 100% rename from compiler/tests/fixtures/features/while_loop_with_continue.fe rename to tests/fixtures/features/while_loop_with_continue.fe diff --git a/compiler/tests/fixtures/solidity/revert_test.sol b/tests/fixtures/solidity/revert_test.sol similarity index 100% rename from compiler/tests/fixtures/solidity/revert_test.sol rename to tests/fixtures/solidity/revert_test.sol diff --git a/compiler/tests/fixtures/stress/abi_encoding_stress.fe b/tests/fixtures/stress/abi_encoding_stress.fe similarity index 100% rename from compiler/tests/fixtures/stress/abi_encoding_stress.fe rename to tests/fixtures/stress/abi_encoding_stress.fe diff --git a/compiler/tests/fixtures/stress/data_copying_stress.fe b/tests/fixtures/stress/data_copying_stress.fe similarity index 100% rename from compiler/tests/fixtures/stress/data_copying_stress.fe rename to tests/fixtures/stress/data_copying_stress.fe diff --git a/compiler/tests/fixtures/stress/external_calls.fe b/tests/fixtures/stress/external_calls.fe similarity index 100% rename from compiler/tests/fixtures/stress/external_calls.fe rename to tests/fixtures/stress/external_calls.fe diff --git a/compiler/tests/fixtures/stress/tuple_stress.fe b/tests/fixtures/stress/tuple_stress.fe similarity index 100% rename from compiler/tests/fixtures/stress/tuple_stress.fe rename to tests/fixtures/stress/tuple_stress.fe diff --git a/compiler/tests/cases/compile_errors.rs b/tests/src/compile_errors.rs similarity index 98% rename from compiler/tests/cases/compile_errors.rs rename to tests/src/compile_errors.rs index e42c4096c7..66d8a97707 100644 --- a/compiler/tests/cases/compile_errors.rs +++ b/tests/src/compile_errors.rs @@ -104,7 +104,7 @@ use rstest::rstest; fn test_compile_errors(fixture_file: &str, expected_error: fe_analyzer::errors::ErrorKind) { let mut files = FileStore::new(); let (src, id) = files - .load_file(&format!("tests/fixtures/compile_errors/{}", fixture_file)) + .load_file(&format!("fixtures/compile_errors/{}", fixture_file)) .expect("unable to read fixture file"); match fe_compiler::compile(&src, id, true, false) { diff --git a/compiler/tests/cases/demo_erc20.rs b/tests/src/demo_erc20.rs similarity index 98% rename from compiler/tests/cases/demo_erc20.rs rename to tests/src/demo_erc20.rs index 50df99f2a7..e96fe5d21f 100644 --- a/compiler/tests/cases/demo_erc20.rs +++ b/tests/src/demo_erc20.rs @@ -1,6 +1,6 @@ #![cfg(feature = "solc-backend")] -use crate::utils::*; +use fe_compiler_test_utils::*; #[test] fn erc20_token() { @@ -10,7 +10,7 @@ fn erc20_token() { let mut harness = deploy_contract( &mut executor, - "demos/erc20_token.fe", + "fixtures/demos/erc20_token.fe", "ERC20", &[token_name.clone(), token_symbol.clone()], ); diff --git a/compiler/tests/cases/demo_guestbook.rs b/tests/src/demo_guestbook.rs similarity index 77% rename from compiler/tests/cases/demo_guestbook.rs rename to tests/src/demo_guestbook.rs index 642a9c52e1..8ac5ffbdce 100644 --- a/compiler/tests/cases/demo_guestbook.rs +++ b/tests/src/demo_guestbook.rs @@ -1,13 +1,18 @@ #![cfg(feature = "solc-backend")] -use crate::utils::*; +use fe_compiler_test_utils::*; use std::iter; #[test] fn guest_book() { with_executor(&|mut executor| { - let mut harness = deploy_contract(&mut executor, "demos/guest_book.fe", "GuestBook", &[]); + let mut harness = deploy_contract( + &mut executor, + "fixtures/demos/guest_book.fe", + "GuestBook", + &[], + ); let sender = address_token("1234000000000000000000000000000000005678"); let bytes = bytes_token( diff --git a/compiler/tests/cases/demo_uniswap.rs b/tests/src/demo_uniswap.rs similarity index 97% rename from compiler/tests/cases/demo_uniswap.rs rename to tests/src/demo_uniswap.rs index ec3449f513..ee0baf7f61 100644 --- a/compiler/tests/cases/demo_uniswap.rs +++ b/tests/src/demo_uniswap.rs @@ -1,6 +1,6 @@ #![cfg(feature = "solc-backend")] -use crate::utils::*; +use fe_compiler_test_utils::*; #[test] fn uniswap_contracts() { @@ -21,7 +21,7 @@ fn uniswap_contracts() { // Create the token0 contract. let token0_harness = deploy_contract( &mut executor, - "demos/erc20_token.fe", + "fixtures/demos/erc20_token.fe", "ERC20", &[token0_name, token0_symbol], ); @@ -29,7 +29,7 @@ fn uniswap_contracts() { // Create the token1 contract. let mut token1_harness = deploy_contract( &mut executor, - "demos/erc20_token.fe", + "fixtures/demos/erc20_token.fe", "ERC20", &[token1_name, token1_symbol], ); @@ -53,7 +53,7 @@ fn uniswap_contracts() { // test. let factory_harness = deploy_contract( &mut executor, - "demos/uniswap.fe", + "fixtures/demos/uniswap.fe", "UniswapV2Factory", &[address_token("0")], ); @@ -73,7 +73,7 @@ fn uniswap_contracts() { // Set the pair address for convenience. let pair_harness = load_contract( pair_address.clone().to_address().expect("not an address"), - "demos/uniswap.fe", + "fixtures/demos/uniswap.fe", "UniswapV2Pair", ); diff --git a/compiler/tests/cases/features.rs b/tests/src/features.rs similarity index 99% rename from compiler/tests/cases/features.rs rename to tests/src/features.rs index 03b071bf7a..3a8546657c 100644 --- a/compiler/tests/cases/features.rs +++ b/tests/src/features.rs @@ -7,9 +7,9 @@ use rstest::rstest; use std::collections::BTreeMap; use std::iter; -use crate::utils; -use crate::utils::*; use fe_common::utils::keccak; +use fe_compiler_test_utils::*; +use fe_compiler_test_utils::{self as test_utils}; pub fn deploy_contract( executor: &mut Executor, @@ -17,16 +17,20 @@ pub fn deploy_contract( contract_name: &str, init_params: &[ethabi::Token], ) -> ContractHarness { - utils::deploy_contract( + test_utils::deploy_contract( executor, - &format!("features/{}", fixture), + &format!("fixtures/features/{}", fixture), contract_name, init_params, ) } pub fn load_contract(address: H160, fixture: &str, contract_name: &str) -> ContractHarness { - utils::load_contract(address, &format!("features/{}", fixture), contract_name) + test_utils::load_contract( + address, + &format!("fixtures/features/{}", fixture), + contract_name, + ) } #[test] diff --git a/tests/src/lib.rs b/tests/src/lib.rs new file mode 100644 index 0000000000..6a022a0d31 --- /dev/null +++ b/tests/src/lib.rs @@ -0,0 +1,17 @@ +#![cfg(feature = "solc-backend")] +#[cfg(test)] +mod compile_errors; +#[cfg(test)] +mod demo_erc20; +#[cfg(test)] +mod demo_guestbook; +#[cfg(test)] +mod demo_uniswap; +#[cfg(test)] +mod features; +#[cfg(test)] +mod runtime; +#[cfg(test)] +mod solidity; +#[cfg(test)] +mod stress; diff --git a/compiler/tests/fixtures/features/aug_assign.fe b/tests/src/lowering/fixtures/aug_assign.fe similarity index 100% rename from compiler/tests/fixtures/features/aug_assign.fe rename to tests/src/lowering/fixtures/aug_assign.fe diff --git a/compiler/tests/cases/lowering/fixtures/aug_assign_lowered.fe b/tests/src/lowering/fixtures/aug_assign_lowered.fe similarity index 100% rename from compiler/tests/cases/lowering/fixtures/aug_assign_lowered.fe rename to tests/src/lowering/fixtures/aug_assign_lowered.fe diff --git a/compiler/tests/cases/lowering/fixtures/base_tuple.fe b/tests/src/lowering/fixtures/base_tuple.fe similarity index 100% rename from compiler/tests/cases/lowering/fixtures/base_tuple.fe rename to tests/src/lowering/fixtures/base_tuple.fe diff --git a/compiler/tests/cases/lowering/fixtures/base_tuple_lowered.fe b/tests/src/lowering/fixtures/base_tuple_lowered.fe similarity index 100% rename from compiler/tests/cases/lowering/fixtures/base_tuple_lowered.fe rename to tests/src/lowering/fixtures/base_tuple_lowered.fe diff --git a/compiler/tests/cases/lowering/fixtures/custom_empty_type.fe b/tests/src/lowering/fixtures/custom_empty_type.fe similarity index 100% rename from compiler/tests/cases/lowering/fixtures/custom_empty_type.fe rename to tests/src/lowering/fixtures/custom_empty_type.fe diff --git a/compiler/tests/cases/lowering/fixtures/custom_empty_type_lowered.fe b/tests/src/lowering/fixtures/custom_empty_type_lowered.fe similarity index 100% rename from compiler/tests/cases/lowering/fixtures/custom_empty_type_lowered.fe rename to tests/src/lowering/fixtures/custom_empty_type_lowered.fe diff --git a/compiler/tests/cases/lowering/fixtures/init.fe b/tests/src/lowering/fixtures/init.fe similarity index 100% rename from compiler/tests/cases/lowering/fixtures/init.fe rename to tests/src/lowering/fixtures/init.fe diff --git a/compiler/tests/cases/lowering/fixtures/init_lowered.fe b/tests/src/lowering/fixtures/init_lowered.fe similarity index 100% rename from compiler/tests/cases/lowering/fixtures/init_lowered.fe rename to tests/src/lowering/fixtures/init_lowered.fe diff --git a/compiler/tests/cases/lowering/fixtures/list_expressions.fe b/tests/src/lowering/fixtures/list_expressions.fe similarity index 100% rename from compiler/tests/cases/lowering/fixtures/list_expressions.fe rename to tests/src/lowering/fixtures/list_expressions.fe diff --git a/compiler/tests/cases/lowering/fixtures/list_expressions_lowered.fe b/tests/src/lowering/fixtures/list_expressions_lowered.fe similarity index 100% rename from compiler/tests/cases/lowering/fixtures/list_expressions_lowered.fe rename to tests/src/lowering/fixtures/list_expressions_lowered.fe diff --git a/compiler/tests/cases/lowering/fixtures/return_unit.fe b/tests/src/lowering/fixtures/return_unit.fe similarity index 100% rename from compiler/tests/cases/lowering/fixtures/return_unit.fe rename to tests/src/lowering/fixtures/return_unit.fe diff --git a/compiler/tests/cases/lowering/fixtures/return_unit_lowered.fe b/tests/src/lowering/fixtures/return_unit_lowered.fe similarity index 100% rename from compiler/tests/cases/lowering/fixtures/return_unit_lowered.fe rename to tests/src/lowering/fixtures/return_unit_lowered.fe diff --git a/compiler/tests/cases/lowering/fixtures/unit_implicit.fe b/tests/src/lowering/fixtures/unit_implicit.fe similarity index 100% rename from compiler/tests/cases/lowering/fixtures/unit_implicit.fe rename to tests/src/lowering/fixtures/unit_implicit.fe diff --git a/compiler/tests/cases/lowering/fixtures/unit_implicit_lowered.fe b/tests/src/lowering/fixtures/unit_implicit_lowered.fe similarity index 100% rename from compiler/tests/cases/lowering/fixtures/unit_implicit_lowered.fe rename to tests/src/lowering/fixtures/unit_implicit_lowered.fe diff --git a/compiler/tests/cases/lowering/mod.rs b/tests/src/lowering/mod.rs similarity index 100% rename from compiler/tests/cases/lowering/mod.rs rename to tests/src/lowering/mod.rs diff --git a/compiler/tests/cases/runtime.rs b/tests/src/runtime.rs similarity index 99% rename from compiler/tests/cases/runtime.rs rename to tests/src/runtime.rs index fec05d25ab..f1f7a94a58 100644 --- a/compiler/tests/cases/runtime.rs +++ b/tests/src/runtime.rs @@ -5,9 +5,9 @@ use fe_compiler::yul::runtime::functions; use rstest::rstest; use yultsur::*; -use crate::utils::*; use fe_analyzer::namespace::types::{Base, FixedSize, Integer, Struct}; use fe_common::utils::keccak; +use fe_compiler_test_utils::*; macro_rules! assert_eq { ($a:tt, $b:tt) => { diff --git a/compiler/tests/cases/solidity.rs b/tests/src/solidity.rs similarity index 91% rename from compiler/tests/cases/solidity.rs rename to tests/src/solidity.rs index 85ecca15c8..a91dde5960 100644 --- a/compiler/tests/cases/solidity.rs +++ b/tests/src/solidity.rs @@ -4,7 +4,7 @@ #![cfg(feature = "solc-backend")] use rstest::rstest; -use crate::utils::*; +use fe_compiler_test_utils::*; #[rstest( method, @@ -18,7 +18,12 @@ use crate::utils::*; )] fn test_revert_string_reason(method: &str, reason: &str) { with_executor(&|mut executor| { - let harness = deploy_solidity_contract(&mut executor, "revert_test.sol", "Foo", &[]); + let harness = deploy_solidity_contract( + &mut executor, + "fixtures/solidity/revert_test.sol", + "Foo", + &[], + ); let exit = harness.capture_call(&mut executor, method, &[]); diff --git a/compiler/tests/cases/stress.rs b/tests/src/stress.rs similarity index 98% rename from compiler/tests/cases/stress.rs rename to tests/src/stress.rs index da4b6077b9..ade6ffc67a 100644 --- a/compiler/tests/cases/stress.rs +++ b/tests/src/stress.rs @@ -3,8 +3,7 @@ #![cfg(feature = "solc-backend")] use std::iter; -use crate::utils; -use crate::utils::*; +use fe_compiler_test_utils::*; pub fn deploy_contract( executor: &mut Executor, @@ -12,9 +11,9 @@ pub fn deploy_contract( contract_name: &str, init_params: &[ethabi::Token], ) -> ContractHarness { - utils::deploy_contract( + fe_compiler_test_utils::deploy_contract( executor, - &format!("stress/{}", fixture), + &format!("fixtures/stress/{}", fixture), contract_name, init_params, )