Update tests
This commit is contained in:
parent
1c346af85e
commit
d3ce5010d0
@ -175,8 +175,10 @@ encode_decode_calldata(FunName, Types, Args, RetType) ->
|
|||||||
encode_decode_calldata_(Code, FunName, Args, RetType).
|
encode_decode_calldata_(Code, FunName, Args, RetType).
|
||||||
|
|
||||||
encode_decode_calldata_(Code, FunName, Args, RetVMType) ->
|
encode_decode_calldata_(Code, FunName, Args, RetVMType) ->
|
||||||
{ok, Calldata, CalldataType, RetVMType1} = aeso_compiler:create_calldata(Code, FunName, Args),
|
{ok, Calldata} = aeso_compiler:create_calldata(Code, FunName, Args),
|
||||||
?assertEqual(RetVMType1, RetVMType),
|
{ok, _, {ArgTypes, RetType}, _} = aeso_compiler:check_call(Code, FunName, Args, [{backend, aevm}]),
|
||||||
|
?assertEqual(RetType, RetVMType),
|
||||||
|
CalldataType = {tuple, [word, {tuple, ArgTypes}]},
|
||||||
{ok, {_Hash, ArgTuple}} = aeb_heap:from_binary(CalldataType, Calldata),
|
{ok, {_Hash, ArgTuple}} = aeb_heap:from_binary(CalldataType, Calldata),
|
||||||
case FunName of
|
case FunName of
|
||||||
"init" ->
|
"init" ->
|
||||||
|
@ -16,18 +16,32 @@
|
|||||||
%% are made on the output, just that it is a binary which indicates
|
%% are made on the output, just that it is a binary which indicates
|
||||||
%% that the compilation worked.
|
%% that the compilation worked.
|
||||||
calldata_test_() ->
|
calldata_test_() ->
|
||||||
[ {"Testing the " ++ ContractName ++ " contract with the " ++ atom_to_list(Backend) ++ " backend",
|
[ {"Testing " ++ ContractName ++ " contract ",
|
||||||
fun() ->
|
fun() ->
|
||||||
ContractString = aeso_test_utils:read_contract(ContractName),
|
ContractString = aeso_test_utils:read_contract(ContractName),
|
||||||
Res = aeso_compiler:create_calldata(ContractString, Fun, Args, [{backend, Backend}]),
|
AevmExprs =
|
||||||
case Backend of
|
case not lists:member(ContractName, not_yet_compilable(aevm)) of
|
||||||
aevm ->
|
true -> ast_exprs(ContractString, Fun, Args, [{backend, aevm}]);
|
||||||
?assertMatch({ok, _, _, _}, Res);
|
false -> undefined
|
||||||
fate ->
|
end,
|
||||||
?assertMatch({ok, _}, Res)
|
FateExprs =
|
||||||
|
case not lists:member(ContractName, not_yet_compilable(fate)) of
|
||||||
|
true -> ast_exprs(ContractString, Fun, Args, [{backend, fate}]);
|
||||||
|
false -> undefined
|
||||||
|
end,
|
||||||
|
case FateExprs == undefined orelse AevmExprs == undefined of
|
||||||
|
true -> ok;
|
||||||
|
false ->
|
||||||
|
?assertEqual(FateExprs, AevmExprs)
|
||||||
end
|
end
|
||||||
end} || {ContractName, Fun, Args} <- compilable_contracts(), Backend <- [aevm, fate],
|
end} || {ContractName, Fun, Args} <- compilable_contracts()].
|
||||||
not lists:member(ContractName, not_yet_compilable(Backend))].
|
|
||||||
|
|
||||||
|
ast_exprs(ContractString, Fun, Args, Opts) ->
|
||||||
|
{ok, Data} = aeso_compiler:create_calldata(ContractString, Fun, Args, Opts),
|
||||||
|
{ok, Types, Exprs} = aeso_compiler:decode_calldata(ContractString, Fun, Data, Opts),
|
||||||
|
?assert(is_list(Exprs)),
|
||||||
|
Exprs.
|
||||||
|
|
||||||
check_errors(Expect, ErrorString) ->
|
check_errors(Expect, ErrorString) ->
|
||||||
%% This removes the final single \n as well.
|
%% This removes the final single \n as well.
|
||||||
@ -62,7 +76,7 @@ compilable_contracts() ->
|
|||||||
{"maps", "get_i", ["1", "{[1] = {x = 3, y = 4}, [2] = {x = 4, y = 5}}"]},
|
{"maps", "get_i", ["1", "{[1] = {x = 3, y = 4}, [2] = {x = 4, y = 5}}"]},
|
||||||
{"maps", "get_i", ["1", "{[1] = {x = 3, y = 4}, [2] = {x = 4, y = 5}, [3] = {x = 5, y = 6}}"]},
|
{"maps", "get_i", ["1", "{[1] = {x = 3, y = 4}, [2] = {x = 4, y = 5}, [3] = {x = 5, y = 6}}"]},
|
||||||
{"strings", "str_concat", ["\"test\"","\"me\""]},
|
{"strings", "str_concat", ["\"test\"","\"me\""]},
|
||||||
{"complex_types", "filter_some", ["[Some(1), Some(2), None]"]},
|
{"complex_types", "filter_some", ["[Some(11), Some(12), None]"]},
|
||||||
{"complex_types", "init", ["ct_Ez6MyeTMm17YnTnDdHTSrzMEBKmy7Uz2sXu347bTDPgVH2ifJ"]},
|
{"complex_types", "init", ["ct_Ez6MyeTMm17YnTnDdHTSrzMEBKmy7Uz2sXu347bTDPgVH2ifJ"]},
|
||||||
{"__call" "init", []},
|
{"__call" "init", []},
|
||||||
{"bitcoin_auth", "authorize", ["1", "#0102030405060708090a0b0c0d0e0f101718192021222324252627282930313233343536373839401a1b1c1d1e1f202122232425262728293031323334353637"]},
|
{"bitcoin_auth", "authorize", ["1", "#0102030405060708090a0b0c0d0e0f101718192021222324252627282930313233343536373839401a1b1c1d1e1f202122232425262728293031323334353637"]},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user