Test case for calling init function from inside the contract

This commit is contained in:
Ulf Norell 2019-09-03 14:47:13 +02:00
parent 0b56691533
commit 69a4c1365b
3 changed files with 15 additions and 0 deletions

View File

@ -2297,6 +2297,10 @@ mk_error({map_in_map_key, KeyType}) ->
Msg = io_lib:format("Invalid key type\n~s\n", [pp_type(" ", KeyType)]),
Cxt = "Map keys cannot contain other maps.\n",
mk_t_err(pos(KeyType), Msg, Cxt);
mk_error({cannot_call_init_function, Ann}) ->
Msg = "The 'init' function is called exclusively by the create contract transaction\n"
"and cannot be called from the contract code.\n",
mk_t_err(pos(Ann), Msg);
mk_error(Err) ->
Msg = io_lib:format("Unknown error: ~p\n", [Err]),
mk_t_err(pos(0, 0), Msg).

View File

@ -477,6 +477,10 @@ failing_contracts() ->
"Invalid key type\n"
" lm\n"
"Map keys cannot contain other maps.">>]}
, {"calling_init_function",
[<<?Pos(7, 28)
"The 'init' function is called exclusively by the create contract transaction\n"
"and cannot be called from the contract code.">>]}
].
-define(Path(File), "code_errors/" ??File).

View File

@ -0,0 +1,7 @@
contract CallingInitFunction =
type state = int * int
entrypoint init() = (1, 2)
entrypoint call_init() = init()