test oracle calldata fixes
This commit is contained in:
parent
9e908369ec
commit
56f70fea6c
@ -117,7 +117,7 @@ join_errors(Prefix, Errors, Pfun) ->
|
||||
%% terms for the arguments.
|
||||
%% NOTE: Special treatment for "init" since it might be implicit and has
|
||||
%% a special return type (typerep, T)
|
||||
-spec check_call(string(), string(), [string()], options()) -> {ok, string(), {[Type], Type | any}, [term()]} | {error, term()}
|
||||
-spec check_call(string(), string(), [string()], options()) -> {ok, string(), {[Type], Type}, [term()]} | {error, term()}
|
||||
when Type :: term().
|
||||
check_call(Source, "init" = FunName, Args, Options) ->
|
||||
PatchFun = fun(T) -> {tuple, [typerep, T]} end,
|
||||
|
@ -107,12 +107,30 @@ calldata_init_test() ->
|
||||
|
||||
parameterized_contract(FunName, Types) ->
|
||||
lists:flatten(
|
||||
["contract Dummy =\n",
|
||||
["contract Dummy =\n"
|
||||
" type an_alias('a) = (string, 'a)\n"
|
||||
" record r = {x : an_alias(int), y : variant}\n"
|
||||
" datatype variant = Red | Blue(map(string, int))\n"
|
||||
" function ", FunName, " : (", string:join(Types, ", "), ") => int\n" ]).
|
||||
|
||||
oracle_test() ->
|
||||
Contract =
|
||||
"contract OracleTest =\n"
|
||||
" function 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", ["#123", "#456"], []),
|
||||
ok.
|
||||
|
||||
permissive_literals_fail_test() ->
|
||||
Contract =
|
||||
"contract OracleTest =\n"
|
||||
" function haxx(o : oracle(list(string), option(int))) =\n"
|
||||
" Chain.spend(o, 1000000)\n",
|
||||
{error, <<"Type errors\nCannot unify address\n and oracle", _/binary>>} =
|
||||
aeso_compiler:check_call(Contract, "haxx", ["#123"], []),
|
||||
ok.
|
||||
|
||||
encode_decode_calldata(FunName, Types, Args) ->
|
||||
encode_decode_calldata(FunName, Types, Args, word).
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user