Skip to content

Commit

Permalink
Messages to libraries must output "messages" and "events" entry (#1175)
Browse files Browse the repository at this point in the history
* Added empty messages and events entry to output from messages sent to libraries

* Added _accepted=false to output from message sent to library
  • Loading branch information
jjcnn authored Sep 29, 2022
1 parent ca609db commit 10ff036
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
20 changes: 14 additions & 6 deletions src/eval/Runner.ml
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,10 @@ let output_message_json gas_remaining mlist =

let output_event_json elist =
let open JSON.JSONLiteral in
List.map elist ~f:(function
| Msg m -> JSON.Event.event_to_json m
| _ -> `Null)
`List
(List.map elist ~f:(function
| Msg m -> JSON.Event.event_to_json m
| _ -> `Null))

let assert_no_address_type_in_type t gas_remaining =
let open RunnerType in
Expand Down Expand Up @@ -409,8 +410,15 @@ let run_with_args args =
if is_library then
if is_deployment then deploy_library args gas_remaining
else
(* Messages to libraries are ignored, but tolerated *)
`Assoc [ ("gas_remaining", `String (Uint64.to_string gas_remaining)) ]
(* Messages to libraries are ignored, but tolerated. *)
`Assoc
[
("gas_remaining", `String (Uint64.to_string gas_remaining));
( RunnerName.as_string ContractUtil.accepted_label,
`String (Bool.to_string false) );
("messages", output_message_json gas_remaining []);
("events", output_event_json []);
]
else
match FEParser.parse_cmodule args.input with
| Error e ->
Expand Down Expand Up @@ -700,7 +708,7 @@ let run_with_args args =

let osj = output_state_json cstate'.balance field_vals in
let omj = output_message_json gas mlist in
let oej = `List (output_event_json elist) in
let oej = output_event_json elist in
let gas' = Gas.finalize_remaining_gas args.gas_limit gas in

((omj, osj, oej, accepted_b), gas')
Expand Down
7 changes: 6 additions & 1 deletion tests/runner/TestLib2/output_1.json
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
{ "gas_remaining": "62896" }
{
"gas_remaining": "62896",
"_accepted": "false",
"messages": [],
"events": []
}

0 comments on commit 10ff036

Please sign in to comment.