Revert "Disable aevm related tests"
This reverts commit e828099bd97dffe11438f2e48f3a92ce3641e85b.
This commit is contained in:
parent
a715cccd03
commit
8f54fe4fac
@ -56,37 +56,36 @@ encode_decode_test() ->
|
||||
0 = encode_decode(word, 0),
|
||||
ok.
|
||||
|
||||
encode_decode_sophia_test() -> ok.
|
||||
%encode_decode_sophia_test() ->
|
||||
% Check = fun(Type, Str) -> case {encode_decode_sophia_string(Type, Str), Str} of
|
||||
% {X, X} -> ok;
|
||||
% Other -> Other
|
||||
% end end,
|
||||
% ok = Check("int", "42"),
|
||||
% ok = Check("int", "- 42"),
|
||||
% ok = Check("bool", "true"),
|
||||
% ok = Check("bool", "false"),
|
||||
% ok = Check("string", "\"Hello\""),
|
||||
% ok = Check("string * list(int) * option(bool)",
|
||||
% "(\"Hello\", [1, 2, 3], Some(true))"),
|
||||
% ok = Check("variant", "Blue({[\"x\"] = 1})"),
|
||||
% ok = Check("r", "{x = (\"foo\", 0), y = Red}"),
|
||||
% ok.
|
||||
%
|
||||
%to_sophia_value_neg_test() ->
|
||||
% Code = [ "contract Foo =\n"
|
||||
% " entrypoint x(y : int) : string = \"hello\"\n" ],
|
||||
%
|
||||
% {error, [Err1]} = aeso_compiler:to_sophia_value(Code, "x", ok, encode(12)),
|
||||
% ?assertEqual("Data error:\nFailed to decode binary as type string\n", aeso_errors:pp(Err1)),
|
||||
% {error, [Err2]} = aeso_compiler:to_sophia_value(Code, "x", ok, encode(12), [{backend, fate}]),
|
||||
% ?assertEqual("Data error:\nFailed to decode binary as type string\n", aeso_errors:pp(Err2)),
|
||||
%
|
||||
% {error, [Err3]} = aeso_compiler:to_sophia_value(Code, "x", revert, encode(12)),
|
||||
% ?assertEqual("Data error:\nCould not interpret the revert message\n", aeso_errors:pp(Err3)),
|
||||
% {error, [Err4]} = aeso_compiler:to_sophia_value(Code, "x", revert, encode(12), [{backend, fate}]),
|
||||
% ?assertEqual("Data error:\nCould not deserialize the revert message\n", aeso_errors:pp(Err4)),
|
||||
% ok.
|
||||
encode_decode_sophia_test() ->
|
||||
Check = fun(Type, Str) -> case {encode_decode_sophia_string(Type, Str), Str} of
|
||||
{X, X} -> ok;
|
||||
Other -> Other
|
||||
end end,
|
||||
ok = Check("int", "42"),
|
||||
ok = Check("int", "- 42"),
|
||||
ok = Check("bool", "true"),
|
||||
ok = Check("bool", "false"),
|
||||
ok = Check("string", "\"Hello\""),
|
||||
ok = Check("string * list(int) * option(bool)",
|
||||
"(\"Hello\", [1, 2, 3], Some(true))"),
|
||||
ok = Check("variant", "Blue({[\"x\"] = 1})"),
|
||||
ok = Check("r", "{x = (\"foo\", 0), y = Red}"),
|
||||
ok.
|
||||
|
||||
to_sophia_value_neg_test() ->
|
||||
Code = [ "contract Foo =\n"
|
||||
" entrypoint x(y : int) : string = \"hello\"\n" ],
|
||||
|
||||
{error, [Err1]} = aeso_compiler:to_sophia_value(Code, "x", ok, encode(12)),
|
||||
?assertEqual("Data error:\nFailed to decode binary as type string\n", aeso_errors:pp(Err1)),
|
||||
{error, [Err2]} = aeso_compiler:to_sophia_value(Code, "x", ok, encode(12), [{backend, fate}]),
|
||||
?assertEqual("Data error:\nFailed to decode binary as type string\n", aeso_errors:pp(Err2)),
|
||||
|
||||
{error, [Err3]} = aeso_compiler:to_sophia_value(Code, "x", revert, encode(12)),
|
||||
?assertEqual("Data error:\nCould not interpret the revert message\n", aeso_errors:pp(Err3)),
|
||||
{error, [Err4]} = aeso_compiler:to_sophia_value(Code, "x", revert, encode(12), [{backend, fate}]),
|
||||
?assertEqual("Data error:\nCould not deserialize the revert message\n", aeso_errors:pp(Err4)),
|
||||
ok.
|
||||
|
||||
encode_calldata_neg_test() ->
|
||||
Code = [ "contract Foo =\n"
|
||||
@ -102,28 +101,27 @@ encode_calldata_neg_test() ->
|
||||
|
||||
ok.
|
||||
|
||||
decode_calldata_neg_test() -> ok.
|
||||
%decode_calldata_neg_test() ->
|
||||
% Code1 = [ "contract Foo =\n"
|
||||
% " entrypoint x(y : int) : string = \"hello\"\n" ],
|
||||
% Code2 = [ "contract Foo =\n"
|
||||
% " entrypoint x(y : string) : int = 42\n" ],
|
||||
%
|
||||
% {ok, CallDataAEVM} = aeso_compiler:create_calldata(Code1, "x", ["42"]),
|
||||
% {ok, CallDataFATE} = aeso_compiler:create_calldata(Code1, "x", ["42"], [{backend, fate}]),
|
||||
%
|
||||
% {error, [Err1]} = aeso_compiler:decode_calldata(Code2, "x", CallDataAEVM),
|
||||
% ?assertEqual("Data error:\nFailed to decode calldata as type {tuple,[string]}\n", aeso_errors:pp(Err1)),
|
||||
% {error, [Err2]} = aeso_compiler:decode_calldata(Code2, "x", <<1,2,3>>, [{backend, fate}]),
|
||||
% ?assertEqual("Data error:\nFailed to decode calldata binary\n", aeso_errors:pp(Err2)),
|
||||
% {error, [Err3]} = aeso_compiler:decode_calldata(Code2, "x", CallDataFATE, [{backend, fate}]),
|
||||
% ?assertEqual("Data error:\nCannot translate FATE value \"*\"\n to Sophia type (string)\n", aeso_errors:pp(Err3)),
|
||||
%
|
||||
% {error, [Err4]} = aeso_compiler:decode_calldata(Code2, "y", CallDataAEVM),
|
||||
% ?assertEqual("Data error at line 1, col 1:\nFunction 'y' is missing in contract\n", aeso_errors:pp(Err4)),
|
||||
% {error, [Err5]} = aeso_compiler:decode_calldata(Code2, "y", CallDataFATE, [{backend, fate}]),
|
||||
% ?assertEqual("Data error at line 1, col 1:\nFunction 'y' is missing in contract\n", aeso_errors:pp(Err5)),
|
||||
% ok.
|
||||
decode_calldata_neg_test() ->
|
||||
Code1 = [ "contract Foo =\n"
|
||||
" entrypoint x(y : int) : string = \"hello\"\n" ],
|
||||
Code2 = [ "contract Foo =\n"
|
||||
" entrypoint x(y : string) : int = 42\n" ],
|
||||
|
||||
{ok, CallDataAEVM} = aeso_compiler:create_calldata(Code1, "x", ["42"]),
|
||||
{ok, CallDataFATE} = aeso_compiler:create_calldata(Code1, "x", ["42"], [{backend, fate}]),
|
||||
|
||||
{error, [Err1]} = aeso_compiler:decode_calldata(Code2, "x", CallDataAEVM),
|
||||
?assertEqual("Data error:\nFailed to decode calldata as type {tuple,[string]}\n", aeso_errors:pp(Err1)),
|
||||
{error, [Err2]} = aeso_compiler:decode_calldata(Code2, "x", <<1,2,3>>, [{backend, fate}]),
|
||||
?assertEqual("Data error:\nFailed to decode calldata binary\n", aeso_errors:pp(Err2)),
|
||||
{error, [Err3]} = aeso_compiler:decode_calldata(Code2, "x", CallDataFATE, [{backend, fate}]),
|
||||
?assertEqual("Data error:\nCannot translate FATE value \"*\"\n to Sophia type (string)\n", aeso_errors:pp(Err3)),
|
||||
|
||||
{error, [Err4]} = aeso_compiler:decode_calldata(Code2, "y", CallDataAEVM),
|
||||
?assertEqual("Data error at line 1, col 1:\nFunction 'y' is missing in contract\n", aeso_errors:pp(Err4)),
|
||||
{error, [Err5]} = aeso_compiler:decode_calldata(Code2, "y", CallDataFATE, [{backend, fate}]),
|
||||
?assertEqual("Data error at line 1, col 1:\nFunction 'y' is missing in contract\n", aeso_errors:pp(Err5)),
|
||||
ok.
|
||||
|
||||
|
||||
encode_decode_sophia_string(SophiaType, String) ->
|
||||
@ -150,43 +148,40 @@ encode_decode_sophia_string(SophiaType, String) ->
|
||||
{error, Err}
|
||||
end.
|
||||
|
||||
calldata_test() -> ok.
|
||||
%calldata_test() ->
|
||||
% [42, <<"foobar">>] = encode_decode_calldata("foo", ["int", "string"], ["42", "\"foobar\""]),
|
||||
% Map = #{ <<"a">> => 4 },
|
||||
% [{variant, 1, [Map]}, {{<<"b">>, 5}, {variant, 0, []}}] =
|
||||
% encode_decode_calldata("foo", ["variant", "r"], ["Blue({[\"a\"] = 4})", "{x = (\"b\", 5), y = Red}"]),
|
||||
% [?DUMMY_HASH_WORD, 16#456] = encode_decode_calldata("foo", ["bytes(32)", "address"],
|
||||
% [?DUMMY_HASH_LIT, "ak_1111111111111111111111111111113AFEFpt5"]),
|
||||
% [?DUMMY_HASH_WORD, ?DUMMY_HASH_WORD] =
|
||||
% encode_decode_calldata("foo", ["bytes(32)", "hash"], [?DUMMY_HASH_LIT, ?DUMMY_HASH_LIT]),
|
||||
%
|
||||
% [119, {0, 0}] = encode_decode_calldata("foo", ["int", "signature"], ["119", [$# | lists:duplicate(128, $0)]]),
|
||||
%
|
||||
% [16#456] = encode_decode_calldata("foo", ["Remote"], ["ct_1111111111111111111111111111113AFEFpt5"]),
|
||||
%
|
||||
% ok.
|
||||
calldata_test() ->
|
||||
[42, <<"foobar">>] = encode_decode_calldata("foo", ["int", "string"], ["42", "\"foobar\""]),
|
||||
Map = #{ <<"a">> => 4 },
|
||||
[{variant, 1, [Map]}, {{<<"b">>, 5}, {variant, 0, []}}] =
|
||||
encode_decode_calldata("foo", ["variant", "r"], ["Blue({[\"a\"] = 4})", "{x = (\"b\", 5), y = Red}"]),
|
||||
[?DUMMY_HASH_WORD, 16#456] = encode_decode_calldata("foo", ["bytes(32)", "address"],
|
||||
[?DUMMY_HASH_LIT, "ak_1111111111111111111111111111113AFEFpt5"]),
|
||||
[?DUMMY_HASH_WORD, ?DUMMY_HASH_WORD] =
|
||||
encode_decode_calldata("foo", ["bytes(32)", "hash"], [?DUMMY_HASH_LIT, ?DUMMY_HASH_LIT]),
|
||||
|
||||
calldata_init_test() -> ok.
|
||||
%calldata_init_test() ->
|
||||
% encode_decode_calldata("init", ["int"], ["42"], {tuple, [typerep, word]}),
|
||||
%
|
||||
% Code = parameterized_contract("foo", ["int"]),
|
||||
% encode_decode_calldata_(Code, "init", [], {tuple, [typerep, {tuple, []}]}).
|
||||
[119, {0, 0}] = encode_decode_calldata("foo", ["int", "signature"], ["119", [$# | lists:duplicate(128, $0)]]),
|
||||
|
||||
calldata_indent_test() -> ok.
|
||||
%calldata_indent_test() ->
|
||||
% Test = fun(Extra) ->
|
||||
% Code = parameterized_contract(Extra, "foo", ["int"]),
|
||||
% encode_decode_calldata_(Code, "foo", ["42"], word)
|
||||
% end,
|
||||
% Test(" stateful entrypoint bla() = ()"),
|
||||
% Test(" type x = int"),
|
||||
% Test(" stateful entrypoint bla(x : int) =\n"
|
||||
% " x + 1"),
|
||||
% Test(" stateful entrypoint bla(x : int) : int =\n"
|
||||
% " x + 1"),
|
||||
% ok.
|
||||
[16#456] = encode_decode_calldata("foo", ["Remote"], ["ct_1111111111111111111111111111113AFEFpt5"]),
|
||||
|
||||
ok.
|
||||
|
||||
calldata_init_test() ->
|
||||
encode_decode_calldata("init", ["int"], ["42"], {tuple, [typerep, word]}),
|
||||
|
||||
Code = parameterized_contract("foo", ["int"]),
|
||||
encode_decode_calldata_(Code, "init", [], {tuple, [typerep, {tuple, []}]}).
|
||||
|
||||
calldata_indent_test() ->
|
||||
Test = fun(Extra) ->
|
||||
Code = parameterized_contract(Extra, "foo", ["int"]),
|
||||
encode_decode_calldata_(Code, "foo", ["42"], word)
|
||||
end,
|
||||
Test(" stateful entrypoint bla() = ()"),
|
||||
Test(" type x = int"),
|
||||
Test(" stateful entrypoint bla(x : int) =\n"
|
||||
" x + 1"),
|
||||
Test(" stateful entrypoint bla(x : int) : int =\n"
|
||||
" x + 1"),
|
||||
ok.
|
||||
|
||||
parameterized_contract(FunName, Types) ->
|
||||
parameterized_contract([], FunName, Types).
|
||||
@ -202,17 +197,16 @@ parameterized_contract(ExtraCode, FunName, Types) ->
|
||||
" datatype variant = Red | Blue(map(string, int))\n"
|
||||
" entrypoint ", FunName, " : (", string:join(Types, ", "), ") => int\n" ]).
|
||||
|
||||
oracle_test() -> ok.
|
||||
%oracle_test() ->
|
||||
% Contract =
|
||||
% "contract OracleTest =\n"
|
||||
% " entrypoint question(o, q : oracle_query(list(string), option(int))) =\n"
|
||||
% " Oracle.get_question(o, q)\n",
|
||||
% {ok, _, {[word, word], {list, string}}, [16#123, 16#456]} =
|
||||
% aeso_compiler:check_call(Contract, "question", ["ok_111111111111111111111111111111ZrdqRz9",
|
||||
% "oq_1111111111111111111111111111113AFEFpt5"], [no_code]),
|
||||
%
|
||||
% ok.
|
||||
oracle_test() ->
|
||||
Contract =
|
||||
"contract OracleTest =\n"
|
||||
" entrypoint question(o, q : oracle_query(list(string), option(int))) =\n"
|
||||
" Oracle.get_question(o, q)\n",
|
||||
{ok, _, {[word, word], {list, string}}, [16#123, 16#456]} =
|
||||
aeso_compiler:check_call(Contract, "question", ["ok_111111111111111111111111111111ZrdqRz9",
|
||||
"oq_1111111111111111111111111111113AFEFpt5"], [no_code]),
|
||||
|
||||
ok.
|
||||
|
||||
permissive_literals_fail_test() ->
|
||||
Contract =
|
||||
|
@ -19,12 +19,18 @@ calldata_test_() ->
|
||||
[ {"Testing " ++ ContractName ++ " contract calling " ++ Fun,
|
||||
fun() ->
|
||||
ContractString = aeso_test_utils:read_contract(ContractName),
|
||||
AevmExprs =
|
||||
case not lists:member(ContractName, not_yet_compilable(aevm)) of
|
||||
true -> ast_exprs(ContractString, Fun, Args, [{backend, aevm}]);
|
||||
false -> undefined
|
||||
end,
|
||||
FateExprs =
|
||||
case not lists:member(ContractName, not_yet_compilable(fate)) of
|
||||
true -> ast_exprs(ContractString, Fun, Args, [{backend, fate}]);
|
||||
false -> undefined
|
||||
end,
|
||||
ParsedExprs = parse_args(Fun, Args),
|
||||
[ ?assertEqual(ParsedExprs, AevmExprs) || AevmExprs /= undefined ],
|
||||
[ ?assertEqual(ParsedExprs, FateExprs) || FateExprs /= undefined ],
|
||||
ok
|
||||
end} || {ContractName, Fun, Args} <- compilable_contracts()].
|
||||
@ -36,12 +42,18 @@ calldata_aci_test_() ->
|
||||
{ok, ContractACIBin} = aeso_aci:contract_interface(string, ContractString),
|
||||
ContractACI = binary_to_list(ContractACIBin),
|
||||
io:format("ACI:\n~s\n", [ContractACIBin]),
|
||||
AevmExprs =
|
||||
case not lists:member(ContractName, not_yet_compilable(aevm)) of
|
||||
true -> ast_exprs(ContractACI, Fun, Args, [{backend, aevm}]);
|
||||
false -> undefined
|
||||
end,
|
||||
FateExprs =
|
||||
case not lists:member(ContractName, not_yet_compilable(fate)) of
|
||||
true -> ast_exprs(ContractACI, Fun, Args, [{backend, fate}]);
|
||||
false -> undefined
|
||||
end,
|
||||
ParsedExprs = parse_args(Fun, Args),
|
||||
[ ?assertEqual(ParsedExprs, AevmExprs) || AevmExprs /= undefined ],
|
||||
[ ?assertEqual(ParsedExprs, FateExprs) || FateExprs /= undefined ],
|
||||
ok
|
||||
end} || {ContractName, Fun, Args} <- compilable_contracts()].
|
||||
|
@ -65,7 +65,7 @@ simple_compile_test_() ->
|
||||
check_errors(Expect, Errors)
|
||||
end} ||
|
||||
{ContractName, ExpectedError} <- failing_code_gen_contracts(),
|
||||
Backend <- [fate] ] ++
|
||||
Backend <- [aevm, fate] ] ++
|
||||
[ {"Testing include with explicit files",
|
||||
fun() ->
|
||||
FileSystem = maps:from_list(
|
||||
@ -87,7 +87,7 @@ simple_compile_test_() ->
|
||||
Backend == fate -> 20 end,
|
||||
?assertMatch({_, _, true}, {SizeDeadCode, SizeNoDeadCode, SizeDeadCode + Delta < SizeNoDeadCode}),
|
||||
ok
|
||||
end} || Backend <- [fate] ] ++
|
||||
end} || Backend <- [aevm, fate] ] ++
|
||||
[].
|
||||
|
||||
%% Check if all modules in the standard library compile
|
||||
|
Loading…
x
Reference in New Issue
Block a user