From 10ff0362df22fd1e6b48d46124cbf4f44de740f6 Mon Sep 17 00:00:00 2001 From: jjcnn <38888011+jjcnn@users.noreply.github.com> Date: Thu, 29 Sep 2022 11:01:18 +0200 Subject: [PATCH] Messages to libraries must output "messages" and "events" entry (#1175) * Added empty messages and events entry to output from messages sent to libraries * Added _accepted=false to output from message sent to library --- src/eval/Runner.ml | 20 ++++++++++++++------ tests/runner/TestLib2/output_1.json | 7 ++++++- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/eval/Runner.ml b/src/eval/Runner.ml index ef64a6727..f7c22ed2f 100644 --- a/src/eval/Runner.ml +++ b/src/eval/Runner.ml @@ -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 @@ -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 -> @@ -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') diff --git a/tests/runner/TestLib2/output_1.json b/tests/runner/TestLib2/output_1.json index 1ddfc8f9f..ea63c2742 100644 --- a/tests/runner/TestLib2/output_1.json +++ b/tests/runner/TestLib2/output_1.json @@ -1 +1,6 @@ -{ "gas_remaining": "62896" } \ No newline at end of file +{ + "gas_remaining": "62896", + "_accepted": "false", + "messages": [], + "events": [] +} \ No newline at end of file