From a30d59121f20d3e43ffbf71a731e538a6a2108b1 Mon Sep 17 00:00:00 2001 From: Lesenechal Remi Date: Fri, 17 Jan 2020 17:02:54 +0100 Subject: [PATCH] review request (more regular output) --- src/bin/expect_tests/contract_tests.ml | 6 +++--- src/main/run/of_michelson.ml | 9 ++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/bin/expect_tests/contract_tests.ml b/src/bin/expect_tests/contract_tests.ml index d3a39f1c9..cc22a7410 100644 --- a/src/bin/expect_tests/contract_tests.ml +++ b/src/bin/expect_tests/contract_tests.ml @@ -966,12 +966,12 @@ let%expect_test _ = let%expect_test _ = run_ligo_good [ "run-function" ; contract "failwith.ligo" ; "failer" ; "1" ] ; [%expect {| - failed with string some_string |}] + failwith("some_string") |}] let%expect_test _ = run_ligo_good [ "run-function" ; contract "failwith.ligo" ; "failer" ; "1" ; "--format=json" ] ; [%expect {| - {"status":"ok","content":"failed with string some_string"} |}] + {"status":"ok","content":"failwith(\"some_string\")"} |}] let%expect_test _ = run_ligo_bad [ "compile-contract" ; contract "bad_address_format.religo" ; "main" ] ; @@ -1022,5 +1022,5 @@ let%expect_test _ = (* TODO should not be bad? *) run_ligo_good [ "dry-run" ; contract "subtle_nontail_fail.mligo" ; "main" ; "()" ; "()" ] ; [%expect {| - failed with string This contract always fails |}] + failwith("This contract always fails") |}] diff --git a/src/main/run/of_michelson.ml b/src/main/run/of_michelson.ml index 5a0d4682a..b8222d44c 100644 --- a/src/main/run/of_michelson.ml +++ b/src/main/run/of_michelson.ml @@ -38,11 +38,10 @@ type dry_run_options = let failwith_to_string (f:run_failwith_res) : string result = let%bind str = match f with | Failwith_int i -> ok @@ string_of_int i - | Failwith_string s -> ok @@ s + | Failwith_string s -> ok @@ Format.asprintf "\"%s\"" (String.escaped s) | Failwith_bytes b -> - generic_try (simple_error "Could not convert failwith bytes to string") @@ - (fun () -> Bytes.to_string b) in - ok @@ Format.asprintf "failed with value '%s'" str + ok @@ Format.asprintf "0X%a" Hex.pp (Hex.of_bytes b) in + ok @@ Format.asprintf "failwith(%s)" str let make_dry_run_options (opts : dry_run_options) : options result = let open Proto_alpha_utils.Trace in @@ -169,4 +168,4 @@ let evaluate_expression ?options exp exp_type = | Success etv' -> ex_value_ty_to_michelson etv' | Fail res -> let%bind str = failwith_to_string res in - fail @@ Errors.failwith str () \ No newline at end of file + fail @@ Errors.failwith str ()