From 689f2afbd08e0bbb462240431a824881c8cca05e Mon Sep 17 00:00:00 2001 From: lin Date: Mon, 17 Oct 2022 17:22:42 +0900 Subject: [PATCH 1/6] Tezt/Client: Add ?hooks arg to normalize functions Preparation for adding regression traces in future commits. --- tezt/lib_tezos/client.ml | 17 +++++++++-------- tezt/lib_tezos/client.mli | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/tezt/lib_tezos/client.ml b/tezt/lib_tezos/client.ml index a26f28100023..942cad1ca84f 100644 --- a/tezt/lib_tezos/client.ml +++ b/tezt/lib_tezos/client.ml @@ -1468,7 +1468,7 @@ let normalize_mode_to_string = function | Optimized -> "Optimized" | Optimized_legacy -> "Optimized_legacy" -let spawn_normalize_data ?mode ?(legacy = false) ~data ~typ client = +let spawn_normalize_data ?hooks ?mode ?(legacy = false) ~data ~typ client = let mode_cmd = Option.map normalize_mode_to_string mode |> Option.map (fun s -> ["--unparsing-mode"; s]) @@ -1478,13 +1478,13 @@ let spawn_normalize_data ?mode ?(legacy = false) ~data ~typ client = @ Option.value ~default:[] mode_cmd @ if legacy then ["--legacy"] else [] in - spawn_command client cmd + spawn_command ?hooks client cmd -let normalize_data ?mode ?legacy ~data ~typ client = - spawn_normalize_data ?mode ?legacy ~data ~typ client +let normalize_data ?hooks ?mode ?legacy ~data ~typ client = + spawn_normalize_data ?hooks ?mode ?legacy ~data ~typ client |> Process.check_and_read_stdout -let spawn_normalize_script ?mode ~script client = +let spawn_normalize_script ?hooks ?mode ~script client = let mode_cmd = Option.map normalize_mode_to_string mode |> Option.map (fun s -> ["--unparsing-mode"; s]) @@ -1492,10 +1492,11 @@ let spawn_normalize_script ?mode ~script client = let cmd = ["normalize"; "script"; script] @ Option.value ~default:[] mode_cmd in - spawn_command client cmd + spawn_command ?hooks client cmd -let normalize_script ?mode ~script client = - spawn_normalize_script ?mode ~script client |> Process.check_and_read_stdout +let normalize_script ?hooks ?mode ~script client = + spawn_normalize_script ?hooks ?mode ~script client + |> Process.check_and_read_stdout let spawn_typecheck_data ~data ~typ ?gas ?(legacy = false) client = let gas_cmd = diff --git a/tezt/lib_tezos/client.mli b/tezt/lib_tezos/client.mli index 2c74e0a72665..6348d52888f8 100644 --- a/tezt/lib_tezos/client.mli +++ b/tezt/lib_tezos/client.mli @@ -1178,6 +1178,7 @@ val spawn_get_contract_hash : (** Run [octez-client normalize data .. of type ...]*) val normalize_data : + ?hooks:Process_hooks.t -> ?mode:normalize_mode -> ?legacy:bool -> data:string -> @@ -1187,6 +1188,7 @@ val normalize_data : (** Same as [normalize_data], but do not wait for the process to exit. *) val spawn_normalize_data : + ?hooks:Process_hooks.t -> ?mode:normalize_mode -> ?legacy:bool -> data:string -> @@ -1196,11 +1198,19 @@ val spawn_normalize_data : (** Run [octez-client normalize script ..]*) val normalize_script : - ?mode:normalize_mode -> script:string -> t -> string Lwt.t + ?hooks:Process_hooks.t -> + ?mode:normalize_mode -> + script:string -> + t -> + string Lwt.t (** Same as [normalize_script], but do not wait for the process to exit. *) val spawn_normalize_script : - ?mode:normalize_mode -> script:string -> t -> Process.t + ?hooks:Process_hooks.t -> + ?mode:normalize_mode -> + script:string -> + t -> + Process.t (** Run [octez-client typecheck data ..]*) val typecheck_data : -- GitLab From ceb8e3caae867aa1310c95919d0349b302bf925c Mon Sep 17 00:00:00 2001 From: lin Date: Mon, 17 Oct 2022 17:24:41 +0900 Subject: [PATCH 2/6] Tezt: Remove normalize.ml This test doesn't test additional value from what we have in test_contract.TestNormalize. This is because: - The cases are covered in test_contract.TestNormalize. - It tests vanilla/mockup/proxy nodes, but normalization result doesn't change based on the node's setup. We will remove it and migrate test_contract.TestNormalize to Tezt. --- tezt/tests/main.ml | 1 - tezt/tests/normalize.ml | 82 ----------------------------------------- 2 files changed, 83 deletions(-) delete mode 100644 tezt/tests/normalize.ml diff --git a/tezt/tests/main.ml b/tezt/tests/main.ml index 417714838305..044033e11dcf 100644 --- a/tezt/tests/main.ml +++ b/tezt/tests/main.ml @@ -126,7 +126,6 @@ let register_protocol_tests_that_use_supports_correctly () = Monitor_operations.register ~protocols ; Multinode_snapshot.register ~protocols ; Node_event_level.register ~protocols ; - Normalize.register ~protocols ; Operation_validation.register ~protocols ; Order_in_top_level.register ~protocols ; P2p.register ~protocols ; diff --git a/tezt/tests/normalize.ml b/tezt/tests/normalize.ml deleted file mode 100644 index 08f5fdf595bd..000000000000 --- a/tezt/tests/normalize.ml +++ /dev/null @@ -1,82 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2020 Nomadic Labs *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -(* Testing - ------- - Component: Client - normalize command - Invocation: dune exec tezt/tests/main.exe -- --file normalize.ml - Subject: Test the client's command 'normalize data .. of type ...' -*) - -let data = "{Pair 0 3 6 9; Pair 1 (Pair 4 (Pair 7 10)); {2; 5; 8; 11}}" - -let typ = "list (pair nat nat nat nat)" - -let normalize_modes = - let open Client in - [Readable; Optimized; Optimized_legacy] - -let execute_all_modes client = - let legacy = true in - Lwt_list.map_s - (fun mode -> Client.normalize_data ~mode ~legacy ~data ~typ client) - normalize_modes - -let test_normalize_vanilla = - Protocol.register_test - ~__FILE__ - ~title:(sf "normalize data") - ~tags:["normalize"; "data"] - @@ fun protocol -> - let* node = Node.init [] in - let* client = Client.init ~endpoint:(Node node) () in - let* () = Client.activate_protocol ~protocol client in - let* _ = execute_all_modes client in - Lwt.return_unit - -let test_normalize_mockup = - Protocol.register_test - ~__FILE__ - ~title:"normalize data (mockup)" - ~tags:["mockup"; "normalize"; "data"] - @@ fun protocol -> - let* client = Client.init_mockup ~protocol () in - let* _ = execute_all_modes client in - Lwt.return_unit - -let test_normalize_proxy = - Protocol.register_test - ~__FILE__ - ~title:"normalize data (proxy)" - ~tags:["proxy"; "normalize"; "data"] - @@ fun protocol -> - let* _, client = Proxy.init ~protocol () in - let* _ = execute_all_modes client in - Lwt.return_unit - -let register ~protocols = - test_normalize_vanilla protocols ; - test_normalize_mockup protocols ; - test_normalize_proxy protocols -- GitLab From 0161417fd9aa3c8c91681d82b41927f8a8bcfd96 Mon Sep 17 00:00:00 2001 From: lin Date: Mon, 17 Oct 2022 18:09:55 +0900 Subject: [PATCH 3/6] Tezt: Migrate normalize command tests from pytest --- .../contracts/proto_alpha/comb-literals.tz | 9 ++ ...lpha- Test normalize in unparsing mode.out | 14 +++ .../Alpha- Test normalize script.out | 42 ++++++++ ...Alpha- Test normalize with legacy flag.out | 10 ++ ...andu- Test normalize in unparsing mode.out | 14 +++ .../Kathmandu- Test normalize script.out | 42 ++++++++ ...mandu- Test normalize with legacy flag.out | 10 ++ ...Lima- Test normalize in unparsing mode.out | 14 +++ .../Lima- Test normalize script.out | 42 ++++++++ .../Lima- Test normalize with legacy flag.out | 10 ++ tezt/tests/main.ml | 1 + tezt/tests/normalize.ml | 98 +++++++++++++++++++ 12 files changed, 306 insertions(+) create mode 100644 tezt/tests/contracts/proto_alpha/comb-literals.tz create mode 100644 tezt/tests/expected/normalize.ml/Alpha- Test normalize in unparsing mode.out create mode 100644 tezt/tests/expected/normalize.ml/Alpha- Test normalize script.out create mode 100644 tezt/tests/expected/normalize.ml/Alpha- Test normalize with legacy flag.out create mode 100644 tezt/tests/expected/normalize.ml/Kathmandu- Test normalize in unparsing mode.out create mode 100644 tezt/tests/expected/normalize.ml/Kathmandu- Test normalize script.out create mode 100644 tezt/tests/expected/normalize.ml/Kathmandu- Test normalize with legacy flag.out create mode 100644 tezt/tests/expected/normalize.ml/Lima- Test normalize in unparsing mode.out create mode 100644 tezt/tests/expected/normalize.ml/Lima- Test normalize script.out create mode 100644 tezt/tests/expected/normalize.ml/Lima- Test normalize with legacy flag.out create mode 100644 tezt/tests/normalize.ml diff --git a/tezt/tests/contracts/proto_alpha/comb-literals.tz b/tezt/tests/contracts/proto_alpha/comb-literals.tz new file mode 100644 index 000000000000..2a2b217d7857 --- /dev/null +++ b/tezt/tests/contracts/proto_alpha/comb-literals.tz @@ -0,0 +1,9 @@ +# This pushes a list of combs to test the effect of the normalize script command +parameter unit; +storage unit; +code { + PUSH + (list (pair nat nat nat nat)) + {Pair 0 3 6 9; Pair 1 (Pair 4 (Pair 7 10)); {2; 5; 8; 11}}; + DROP 2; UNIT; NIL operation; PAIR + } diff --git a/tezt/tests/expected/normalize.ml/Alpha- Test normalize in unparsing mode.out b/tezt/tests/expected/normalize.ml/Alpha- Test normalize in unparsing mode.out new file mode 100644 index 000000000000..80323b4574cb --- /dev/null +++ b/tezt/tests/expected/normalize.ml/Alpha- Test normalize in unparsing mode.out @@ -0,0 +1,14 @@ + +./octez-client --mode mockup normalize data '{Pair 0 3 6 9; Pair 1 (Pair 4 (Pair 7 10)); {2; 5; 8; 11}}' of type 'list (pair nat nat nat nat)' +{ Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } + +./octez-client --mode mockup normalize data '{Pair 0 3 6 9; Pair 1 (Pair 4 (Pair 7 10)); {2; 5; 8; 11}}' of type 'list (pair nat nat nat nat)' --unparsing-mode Readable +{ Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } + +./octez-client --mode mockup normalize data '{Pair 0 3 6 9; Pair 1 (Pair 4 (Pair 7 10)); {2; 5; 8; 11}}' of type 'list (pair nat nat nat nat)' --unparsing-mode Optimized +{ { 0 ; 3 ; 6 ; 9 } ; { 1 ; 4 ; 7 ; 10 } ; { 2 ; 5 ; 8 ; 11 } } + +./octez-client --mode mockup normalize data '{Pair 0 3 6 9; Pair 1 (Pair 4 (Pair 7 10)); {2; 5; 8; 11}}' of type 'list (pair nat nat nat nat)' --unparsing-mode Optimized_legacy +{ Pair 0 (Pair 3 (Pair 6 9)) ; + Pair 1 (Pair 4 (Pair 7 10)) ; + Pair 2 (Pair 5 (Pair 8 11)) } diff --git a/tezt/tests/expected/normalize.ml/Alpha- Test normalize script.out b/tezt/tests/expected/normalize.ml/Alpha- Test normalize script.out new file mode 100644 index 000000000000..772b4afaf68f --- /dev/null +++ b/tezt/tests/expected/normalize.ml/Alpha- Test normalize script.out @@ -0,0 +1,42 @@ + +./octez-client --mode mockup normalize script file:./tezt/tests/contracts/proto_alpha/comb-literals.tz +{ parameter unit ; + storage unit ; + code { PUSH (list (pair nat nat nat nat)) + { Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } ; + DROP 2 ; + UNIT ; + NIL operation ; + PAIR } } + +./octez-client --mode mockup normalize script file:./tezt/tests/contracts/proto_alpha/comb-literals.tz --unparsing-mode Readable +{ parameter unit ; + storage unit ; + code { PUSH (list (pair nat nat nat nat)) + { Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } ; + DROP 2 ; + UNIT ; + NIL operation ; + PAIR } } + +./octez-client --mode mockup normalize script file:./tezt/tests/contracts/proto_alpha/comb-literals.tz --unparsing-mode Optimized +{ parameter unit ; + storage unit ; + code { PUSH (list (pair nat nat nat nat)) + { { 0 ; 3 ; 6 ; 9 } ; { 1 ; 4 ; 7 ; 10 } ; { 2 ; 5 ; 8 ; 11 } } ; + DROP 2 ; + UNIT ; + NIL operation ; + PAIR } } + +./octez-client --mode mockup normalize script file:./tezt/tests/contracts/proto_alpha/comb-literals.tz --unparsing-mode Optimized_legacy +{ parameter unit ; + storage unit ; + code { PUSH (list (pair nat nat nat nat)) + { Pair 0 (Pair 3 (Pair 6 9)) ; + Pair 1 (Pair 4 (Pair 7 10)) ; + Pair 2 (Pair 5 (Pair 8 11)) } ; + DROP 2 ; + UNIT ; + NIL operation ; + PAIR } } diff --git a/tezt/tests/expected/normalize.ml/Alpha- Test normalize with legacy flag.out b/tezt/tests/expected/normalize.ml/Alpha- Test normalize with legacy flag.out new file mode 100644 index 000000000000..8ecc6976ccf6 --- /dev/null +++ b/tezt/tests/expected/normalize.ml/Alpha- Test normalize with legacy flag.out @@ -0,0 +1,10 @@ + +./octez-client --mode mockup normalize data '{Elt %a 0 1}' of type 'map nat nat' --legacy +{ Elt 0 1 } + +./octez-client --mode mockup normalize data '{Elt %a 0 1}' of type 'map nat nat' +At (unshown) location 0, value { Elt %a 0 1 } +is invalid for type map nat nat. +At (unshown) location 1, unexpected annotation. +Fatal error: + ill-typed data expression diff --git a/tezt/tests/expected/normalize.ml/Kathmandu- Test normalize in unparsing mode.out b/tezt/tests/expected/normalize.ml/Kathmandu- Test normalize in unparsing mode.out new file mode 100644 index 000000000000..80323b4574cb --- /dev/null +++ b/tezt/tests/expected/normalize.ml/Kathmandu- Test normalize in unparsing mode.out @@ -0,0 +1,14 @@ + +./octez-client --mode mockup normalize data '{Pair 0 3 6 9; Pair 1 (Pair 4 (Pair 7 10)); {2; 5; 8; 11}}' of type 'list (pair nat nat nat nat)' +{ Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } + +./octez-client --mode mockup normalize data '{Pair 0 3 6 9; Pair 1 (Pair 4 (Pair 7 10)); {2; 5; 8; 11}}' of type 'list (pair nat nat nat nat)' --unparsing-mode Readable +{ Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } + +./octez-client --mode mockup normalize data '{Pair 0 3 6 9; Pair 1 (Pair 4 (Pair 7 10)); {2; 5; 8; 11}}' of type 'list (pair nat nat nat nat)' --unparsing-mode Optimized +{ { 0 ; 3 ; 6 ; 9 } ; { 1 ; 4 ; 7 ; 10 } ; { 2 ; 5 ; 8 ; 11 } } + +./octez-client --mode mockup normalize data '{Pair 0 3 6 9; Pair 1 (Pair 4 (Pair 7 10)); {2; 5; 8; 11}}' of type 'list (pair nat nat nat nat)' --unparsing-mode Optimized_legacy +{ Pair 0 (Pair 3 (Pair 6 9)) ; + Pair 1 (Pair 4 (Pair 7 10)) ; + Pair 2 (Pair 5 (Pair 8 11)) } diff --git a/tezt/tests/expected/normalize.ml/Kathmandu- Test normalize script.out b/tezt/tests/expected/normalize.ml/Kathmandu- Test normalize script.out new file mode 100644 index 000000000000..772b4afaf68f --- /dev/null +++ b/tezt/tests/expected/normalize.ml/Kathmandu- Test normalize script.out @@ -0,0 +1,42 @@ + +./octez-client --mode mockup normalize script file:./tezt/tests/contracts/proto_alpha/comb-literals.tz +{ parameter unit ; + storage unit ; + code { PUSH (list (pair nat nat nat nat)) + { Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } ; + DROP 2 ; + UNIT ; + NIL operation ; + PAIR } } + +./octez-client --mode mockup normalize script file:./tezt/tests/contracts/proto_alpha/comb-literals.tz --unparsing-mode Readable +{ parameter unit ; + storage unit ; + code { PUSH (list (pair nat nat nat nat)) + { Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } ; + DROP 2 ; + UNIT ; + NIL operation ; + PAIR } } + +./octez-client --mode mockup normalize script file:./tezt/tests/contracts/proto_alpha/comb-literals.tz --unparsing-mode Optimized +{ parameter unit ; + storage unit ; + code { PUSH (list (pair nat nat nat nat)) + { { 0 ; 3 ; 6 ; 9 } ; { 1 ; 4 ; 7 ; 10 } ; { 2 ; 5 ; 8 ; 11 } } ; + DROP 2 ; + UNIT ; + NIL operation ; + PAIR } } + +./octez-client --mode mockup normalize script file:./tezt/tests/contracts/proto_alpha/comb-literals.tz --unparsing-mode Optimized_legacy +{ parameter unit ; + storage unit ; + code { PUSH (list (pair nat nat nat nat)) + { Pair 0 (Pair 3 (Pair 6 9)) ; + Pair 1 (Pair 4 (Pair 7 10)) ; + Pair 2 (Pair 5 (Pair 8 11)) } ; + DROP 2 ; + UNIT ; + NIL operation ; + PAIR } } diff --git a/tezt/tests/expected/normalize.ml/Kathmandu- Test normalize with legacy flag.out b/tezt/tests/expected/normalize.ml/Kathmandu- Test normalize with legacy flag.out new file mode 100644 index 000000000000..8ecc6976ccf6 --- /dev/null +++ b/tezt/tests/expected/normalize.ml/Kathmandu- Test normalize with legacy flag.out @@ -0,0 +1,10 @@ + +./octez-client --mode mockup normalize data '{Elt %a 0 1}' of type 'map nat nat' --legacy +{ Elt 0 1 } + +./octez-client --mode mockup normalize data '{Elt %a 0 1}' of type 'map nat nat' +At (unshown) location 0, value { Elt %a 0 1 } +is invalid for type map nat nat. +At (unshown) location 1, unexpected annotation. +Fatal error: + ill-typed data expression diff --git a/tezt/tests/expected/normalize.ml/Lima- Test normalize in unparsing mode.out b/tezt/tests/expected/normalize.ml/Lima- Test normalize in unparsing mode.out new file mode 100644 index 000000000000..80323b4574cb --- /dev/null +++ b/tezt/tests/expected/normalize.ml/Lima- Test normalize in unparsing mode.out @@ -0,0 +1,14 @@ + +./octez-client --mode mockup normalize data '{Pair 0 3 6 9; Pair 1 (Pair 4 (Pair 7 10)); {2; 5; 8; 11}}' of type 'list (pair nat nat nat nat)' +{ Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } + +./octez-client --mode mockup normalize data '{Pair 0 3 6 9; Pair 1 (Pair 4 (Pair 7 10)); {2; 5; 8; 11}}' of type 'list (pair nat nat nat nat)' --unparsing-mode Readable +{ Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } + +./octez-client --mode mockup normalize data '{Pair 0 3 6 9; Pair 1 (Pair 4 (Pair 7 10)); {2; 5; 8; 11}}' of type 'list (pair nat nat nat nat)' --unparsing-mode Optimized +{ { 0 ; 3 ; 6 ; 9 } ; { 1 ; 4 ; 7 ; 10 } ; { 2 ; 5 ; 8 ; 11 } } + +./octez-client --mode mockup normalize data '{Pair 0 3 6 9; Pair 1 (Pair 4 (Pair 7 10)); {2; 5; 8; 11}}' of type 'list (pair nat nat nat nat)' --unparsing-mode Optimized_legacy +{ Pair 0 (Pair 3 (Pair 6 9)) ; + Pair 1 (Pair 4 (Pair 7 10)) ; + Pair 2 (Pair 5 (Pair 8 11)) } diff --git a/tezt/tests/expected/normalize.ml/Lima- Test normalize script.out b/tezt/tests/expected/normalize.ml/Lima- Test normalize script.out new file mode 100644 index 000000000000..772b4afaf68f --- /dev/null +++ b/tezt/tests/expected/normalize.ml/Lima- Test normalize script.out @@ -0,0 +1,42 @@ + +./octez-client --mode mockup normalize script file:./tezt/tests/contracts/proto_alpha/comb-literals.tz +{ parameter unit ; + storage unit ; + code { PUSH (list (pair nat nat nat nat)) + { Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } ; + DROP 2 ; + UNIT ; + NIL operation ; + PAIR } } + +./octez-client --mode mockup normalize script file:./tezt/tests/contracts/proto_alpha/comb-literals.tz --unparsing-mode Readable +{ parameter unit ; + storage unit ; + code { PUSH (list (pair nat nat nat nat)) + { Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } ; + DROP 2 ; + UNIT ; + NIL operation ; + PAIR } } + +./octez-client --mode mockup normalize script file:./tezt/tests/contracts/proto_alpha/comb-literals.tz --unparsing-mode Optimized +{ parameter unit ; + storage unit ; + code { PUSH (list (pair nat nat nat nat)) + { { 0 ; 3 ; 6 ; 9 } ; { 1 ; 4 ; 7 ; 10 } ; { 2 ; 5 ; 8 ; 11 } } ; + DROP 2 ; + UNIT ; + NIL operation ; + PAIR } } + +./octez-client --mode mockup normalize script file:./tezt/tests/contracts/proto_alpha/comb-literals.tz --unparsing-mode Optimized_legacy +{ parameter unit ; + storage unit ; + code { PUSH (list (pair nat nat nat nat)) + { Pair 0 (Pair 3 (Pair 6 9)) ; + Pair 1 (Pair 4 (Pair 7 10)) ; + Pair 2 (Pair 5 (Pair 8 11)) } ; + DROP 2 ; + UNIT ; + NIL operation ; + PAIR } } diff --git a/tezt/tests/expected/normalize.ml/Lima- Test normalize with legacy flag.out b/tezt/tests/expected/normalize.ml/Lima- Test normalize with legacy flag.out new file mode 100644 index 000000000000..8ecc6976ccf6 --- /dev/null +++ b/tezt/tests/expected/normalize.ml/Lima- Test normalize with legacy flag.out @@ -0,0 +1,10 @@ + +./octez-client --mode mockup normalize data '{Elt %a 0 1}' of type 'map nat nat' --legacy +{ Elt 0 1 } + +./octez-client --mode mockup normalize data '{Elt %a 0 1}' of type 'map nat nat' +At (unshown) location 0, value { Elt %a 0 1 } +is invalid for type map nat nat. +At (unshown) location 1, unexpected annotation. +Fatal error: + ill-typed data expression diff --git a/tezt/tests/main.ml b/tezt/tests/main.ml index 044033e11dcf..417714838305 100644 --- a/tezt/tests/main.ml +++ b/tezt/tests/main.ml @@ -126,6 +126,7 @@ let register_protocol_tests_that_use_supports_correctly () = Monitor_operations.register ~protocols ; Multinode_snapshot.register ~protocols ; Node_event_level.register ~protocols ; + Normalize.register ~protocols ; Operation_validation.register ~protocols ; Order_in_top_level.register ~protocols ; P2p.register ~protocols ; diff --git a/tezt/tests/normalize.ml b/tezt/tests/normalize.ml new file mode 100644 index 000000000000..ce4dfc01605c --- /dev/null +++ b/tezt/tests/normalize.ml @@ -0,0 +1,98 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Marigold *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +(* Testing + ------- + Component: Client + Invocation: dune exec tezt/tests/main.exe -- --file normalize.ml + Subject: Regression tests for the "normalize data" command. +*) + +let hooks = Tezos_regression.hooks + +let modes = Client.[None; Some Readable; Some Optimized; Some Optimized_legacy] + +let test_normalize_unparsing_mode = + Protocol.register_regression_test + ~__FILE__ + ~title:"Test normalize in unparsing mode" + ~tags:["client"; "normalize"] + @@ fun protocol -> + let* client = Client.init_mockup ~protocol () in + let data = "{Pair 0 3 6 9; Pair 1 (Pair 4 (Pair 7 10)); {2; 5; 8; 11}}" in + let typ = "list (pair nat nat nat nat)" in + let* () = + modes + |> Lwt_list.iter_s (fun mode -> + let* _ = Client.normalize_data client ~hooks ?mode ~data ~typ in + unit) + in + unit + +let test_normalize_legacy_flag = + Protocol.register_regression_test + ~__FILE__ + ~title:"Test normalize with legacy flag" + ~tags:["client"; "normalize"] + @@ fun protocol -> + let* client = Client.init_mockup ~protocol () in + let data = "{Elt %a 0 1}" in + let typ = "map nat nat" in + let* () = + let* _ = Client.normalize_data client ~legacy:true ~hooks ~data ~typ in + unit + in + let* () = + Client.spawn_normalize_data client ~legacy:false ~hooks ~data ~typ + |> Process.check_error ~msg:(rex "unexpected annotation.") + in + unit + +let test_normalize_script = + Protocol.register_regression_test + ~__FILE__ + ~title:"Test normalize script" + ~tags:["client"; "normalize"] + @@ fun protocol -> + let* client = Client.init_mockup ~protocol () in + let* () = + modes + |> Lwt_list.iter_s (fun mode -> + let* _ = + Client.normalize_script + client + ~hooks + ?mode + ~script: + "file:./tezt/tests/contracts/proto_alpha/comb-literals.tz" + in + unit) + in + unit + +let register ~protocols = + test_normalize_unparsing_mode protocols ; + test_normalize_legacy_flag protocols ; + test_normalize_script protocols -- GitLab From f8809617f36491da04f42a05e9f1a3ede1fb531e Mon Sep 17 00:00:00 2001 From: lin Date: Mon, 17 Oct 2022 18:13:50 +0900 Subject: [PATCH 4/6] Pytest: Remove TestNormalize --- ...tNormalize::test_normalize_legacy_flag.out | 8 ---- ...Normalize::test_normalize_script[None].out | 10 ---- ...lize::test_normalize_script[Optimized].out | 10 ---- ...est_normalize_script[Optimized_legacy].out | 12 ----- ...alize::test_normalize_script[Readable].out | 10 ---- ...e_type[list (pair nat int bool bytes)].out | 3 -- ...rmalize_type[list (pair nat int bool)].out | 3 -- ...st_normalize_type[list (pair nat int)].out | 3 -- ...rmalize::test_normalize_type[list nat].out | 3 -- ...estNormalize::test_normalize_type[nat].out | 3 -- ...ormalize_type[pair nat int bool bytes].out | 3 -- ...test_normalize_type[pair nat int bool].out | 3 -- ...ize::test_normalize_type[pair nat int].out | 3 -- ...e::test_normalize_unparsing_mode[None].out | 3 -- ...st_normalize_unparsing_mode[Optimized].out | 3 -- ...alize_unparsing_mode[Optimized_legacy].out | 5 -- ...est_normalize_unparsing_mode[Readable].out | 3 -- tests_python/tests_014/test_contract.py | 48 ------------------- ...tNormalize::test_normalize_legacy_flag.out | 8 ---- ...Normalize::test_normalize_script[None].out | 10 ---- ...lize::test_normalize_script[Optimized].out | 10 ---- ...est_normalize_script[Optimized_legacy].out | 12 ----- ...alize::test_normalize_script[Readable].out | 10 ---- ...e_type[list (pair nat int bool bytes)].out | 3 -- ...rmalize_type[list (pair nat int bool)].out | 3 -- ...st_normalize_type[list (pair nat int)].out | 3 -- ...rmalize::test_normalize_type[list nat].out | 3 -- ...estNormalize::test_normalize_type[nat].out | 3 -- ...ormalize_type[pair nat int bool bytes].out | 3 -- ...test_normalize_type[pair nat int bool].out | 3 -- ...ize::test_normalize_type[pair nat int].out | 3 -- ...e::test_normalize_unparsing_mode[None].out | 3 -- ...st_normalize_unparsing_mode[Optimized].out | 3 -- ...alize_unparsing_mode[Optimized_legacy].out | 5 -- ...est_normalize_unparsing_mode[Readable].out | 3 -- tests_python/tests_015/test_contract.py | 48 ------------------- ...tNormalize::test_normalize_legacy_flag.out | 8 ---- ...Normalize::test_normalize_script[None].out | 10 ---- ...lize::test_normalize_script[Optimized].out | 10 ---- ...est_normalize_script[Optimized_legacy].out | 12 ----- ...alize::test_normalize_script[Readable].out | 10 ---- ...e_type[list (pair nat int bool bytes)].out | 3 -- ...rmalize_type[list (pair nat int bool)].out | 3 -- ...st_normalize_type[list (pair nat int)].out | 3 -- ...rmalize::test_normalize_type[list nat].out | 3 -- ...estNormalize::test_normalize_type[nat].out | 3 -- ...ormalize_type[pair nat int bool bytes].out | 3 -- ...test_normalize_type[pair nat int bool].out | 3 -- ...ize::test_normalize_type[pair nat int].out | 3 -- ...e::test_normalize_unparsing_mode[None].out | 3 -- ...st_normalize_unparsing_mode[Optimized].out | 3 -- ...alize_unparsing_mode[Optimized_legacy].out | 5 -- ...est_normalize_unparsing_mode[Readable].out | 3 -- tests_python/tests_alpha/test_contract.py | 48 ------------------- 54 files changed, 408 deletions(-) delete mode 100644 tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_legacy_flag.out delete mode 100644 tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[None].out delete mode 100644 tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized].out delete mode 100644 tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized_legacy].out delete mode 100644 tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Readable].out delete mode 100644 tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool bytes)].out delete mode 100644 tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool)].out delete mode 100644 tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int)].out delete mode 100644 tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list nat].out delete mode 100644 tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[nat].out delete mode 100644 tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool bytes].out delete mode 100644 tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool].out delete mode 100644 tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int].out delete mode 100644 tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[None].out delete mode 100644 tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized].out delete mode 100644 tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized_legacy].out delete mode 100644 tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Readable].out delete mode 100644 tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_legacy_flag.out delete mode 100644 tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[None].out delete mode 100644 tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized].out delete mode 100644 tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized_legacy].out delete mode 100644 tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Readable].out delete mode 100644 tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool bytes)].out delete mode 100644 tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool)].out delete mode 100644 tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int)].out delete mode 100644 tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list nat].out delete mode 100644 tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[nat].out delete mode 100644 tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool bytes].out delete mode 100644 tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool].out delete mode 100644 tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int].out delete mode 100644 tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[None].out delete mode 100644 tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized].out delete mode 100644 tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized_legacy].out delete mode 100644 tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Readable].out delete mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_legacy_flag.out delete mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[None].out delete mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized].out delete mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized_legacy].out delete mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Readable].out delete mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool bytes)].out delete mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool)].out delete mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int)].out delete mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list nat].out delete mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[nat].out delete mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool bytes].out delete mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool].out delete mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int].out delete mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[None].out delete mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized].out delete mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized_legacy].out delete mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Readable].out diff --git a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_legacy_flag.out b/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_legacy_flag.out deleted file mode 100644 index b39ccb66d9ee..000000000000 --- a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_legacy_flag.out +++ /dev/null @@ -1,8 +0,0 @@ -tests_014/test_contract.py::TestNormalize::test_normalize_legacy_flag - -{ Elt 0 1 } -At (unshown) location 0, value { Elt %a 0 1 } -is invalid for type map nat nat. -At (unshown) location 1, unexpected annotation. -Fatal error: - ill-typed data expression diff --git a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[None].out b/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[None].out deleted file mode 100644 index ad926ee522a9..000000000000 --- a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[None].out +++ /dev/null @@ -1,10 +0,0 @@ -tests_014/test_contract.py::TestNormalize::test_normalize_script[None] - -{ parameter unit ; - storage unit ; - code { PUSH (list (pair nat nat nat nat)) - { Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } ; - DROP 2 ; - UNIT ; - NIL operation ; - PAIR } } diff --git a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized].out b/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized].out deleted file mode 100644 index ae1ac32f84f1..000000000000 --- a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized].out +++ /dev/null @@ -1,10 +0,0 @@ -tests_014/test_contract.py::TestNormalize::test_normalize_script[Optimized] - -{ parameter unit ; - storage unit ; - code { PUSH (list (pair nat nat nat nat)) - { { 0 ; 3 ; 6 ; 9 } ; { 1 ; 4 ; 7 ; 10 } ; { 2 ; 5 ; 8 ; 11 } } ; - DROP 2 ; - UNIT ; - NIL operation ; - PAIR } } diff --git a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized_legacy].out b/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized_legacy].out deleted file mode 100644 index 863dda9a7e5a..000000000000 --- a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized_legacy].out +++ /dev/null @@ -1,12 +0,0 @@ -tests_014/test_contract.py::TestNormalize::test_normalize_script[Optimized_legacy] - -{ parameter unit ; - storage unit ; - code { PUSH (list (pair nat nat nat nat)) - { Pair 0 (Pair 3 (Pair 6 9)) ; - Pair 1 (Pair 4 (Pair 7 10)) ; - Pair 2 (Pair 5 (Pair 8 11)) } ; - DROP 2 ; - UNIT ; - NIL operation ; - PAIR } } diff --git a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Readable].out b/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Readable].out deleted file mode 100644 index 3e4d75fd3657..000000000000 --- a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Readable].out +++ /dev/null @@ -1,10 +0,0 @@ -tests_014/test_contract.py::TestNormalize::test_normalize_script[Readable] - -{ parameter unit ; - storage unit ; - code { PUSH (list (pair nat nat nat nat)) - { Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } ; - DROP 2 ; - UNIT ; - NIL operation ; - PAIR } } diff --git a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool bytes)].out b/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool bytes)].out deleted file mode 100644 index 285aadf75fca..000000000000 --- a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool bytes)].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_014/test_contract.py::TestNormalize::test_normalize_type[list (pair nat int bool bytes)] - -list (pair nat (pair int (pair bool bytes))) diff --git a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool)].out b/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool)].out deleted file mode 100644 index cc7473bdc8c6..000000000000 --- a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool)].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_014/test_contract.py::TestNormalize::test_normalize_type[list (pair nat int bool)] - -list (pair nat (pair int bool)) diff --git a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int)].out b/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int)].out deleted file mode 100644 index 2b3a3b71bd4e..000000000000 --- a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int)].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_014/test_contract.py::TestNormalize::test_normalize_type[list (pair nat int)] - -list (pair nat int) diff --git a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list nat].out b/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list nat].out deleted file mode 100644 index 27f0a4f77e70..000000000000 --- a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list nat].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_014/test_contract.py::TestNormalize::test_normalize_type[list nat] - -list nat diff --git a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[nat].out b/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[nat].out deleted file mode 100644 index 8b9d37d68012..000000000000 --- a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[nat].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_014/test_contract.py::TestNormalize::test_normalize_type[nat] - -nat diff --git a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool bytes].out b/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool bytes].out deleted file mode 100644 index 5e6379c82d91..000000000000 --- a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool bytes].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_014/test_contract.py::TestNormalize::test_normalize_type[pair nat int bool bytes] - -pair nat (pair int (pair bool bytes)) diff --git a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool].out b/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool].out deleted file mode 100644 index 09e342b1ab6a..000000000000 --- a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_014/test_contract.py::TestNormalize::test_normalize_type[pair nat int bool] - -pair nat (pair int bool) diff --git a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int].out b/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int].out deleted file mode 100644 index c8492352334d..000000000000 --- a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_014/test_contract.py::TestNormalize::test_normalize_type[pair nat int] - -pair nat int diff --git a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[None].out b/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[None].out deleted file mode 100644 index d128e78a5929..000000000000 --- a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[None].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_014/test_contract.py::TestNormalize::test_normalize_unparsing_mode[None] - -{ Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } diff --git a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized].out b/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized].out deleted file mode 100644 index 61d4469b3d25..000000000000 --- a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_014/test_contract.py::TestNormalize::test_normalize_unparsing_mode[Optimized] - -{ { 0 ; 3 ; 6 ; 9 } ; { 1 ; 4 ; 7 ; 10 } ; { 2 ; 5 ; 8 ; 11 } } diff --git a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized_legacy].out b/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized_legacy].out deleted file mode 100644 index 80dc17981c1c..000000000000 --- a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized_legacy].out +++ /dev/null @@ -1,5 +0,0 @@ -tests_014/test_contract.py::TestNormalize::test_normalize_unparsing_mode[Optimized_legacy] - -{ Pair 0 (Pair 3 (Pair 6 9)) ; - Pair 1 (Pair 4 (Pair 7 10)) ; - Pair 2 (Pair 5 (Pair 8 11)) } diff --git a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Readable].out b/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Readable].out deleted file mode 100644 index 2864ffc0534c..000000000000 --- a/tests_python/tests_014/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Readable].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_014/test_contract.py::TestNormalize::test_normalize_unparsing_mode[Readable] - -{ Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } diff --git a/tests_python/tests_014/test_contract.py b/tests_python/tests_014/test_contract.py index bcfef5ae53b0..c9790e30e47e 100644 --- a/tests_python/tests_014/test_contract.py +++ b/tests_python/tests_014/test_contract.py @@ -1594,54 +1594,6 @@ expruat2BS4KCwn9kbopeX1ZwxtrtJbyFhpnpnG6A5KdCBCwHNsdod ) == [results] -@pytest.mark.contract -@pytest.mark.regression -class TestNormalize: - """Regression tests for the "normalize data" command.""" - - modes = [None, 'Readable', 'Optimized', 'Optimized_legacy'] - - @pytest.mark.parametrize('mode', modes) - def test_normalize_unparsing_mode(self, client_regtest_scrubbed, mode): - client = client_regtest_scrubbed - input_data = ( - '{Pair 0 3 6 9; Pair 1 (Pair 4 (Pair 7 10)); {2; 5; 8; 11}}' - ) - input_type = 'list (pair nat nat nat nat)' - client.normalize(input_data, input_type, mode=mode) - - def test_normalize_legacy_flag(self, client_regtest_scrubbed): - client = client_regtest_scrubbed - input_data = '{Elt %a 0 1}' - input_type = 'map nat nat' - client.normalize(input_data, input_type, legacy=True) - error_pattern = 'unexpected annotation.' - with utils.assert_run_failure(error_pattern): - client.normalize(input_data, input_type, legacy=False) - - @pytest.mark.parametrize('mode', modes) - def test_normalize_script(self, client_regtest_scrubbed, mode): - client = client_regtest_scrubbed - path = os.path.join(CONTRACT_PATH, 'opcodes', 'comb-literals.tz') - client.normalize_script(path, mode=mode) - - types = [ - 'nat', - 'list nat', - 'pair nat int', - 'list (pair nat int)', - 'pair nat int bool', - 'list (pair nat int bool)', - 'pair nat int bool bytes', - 'list (pair nat int bool bytes)', - ] - - @pytest.mark.parametrize('typ', types) - def test_normalize_type(self, client_regtest_scrubbed, typ): - client = client_regtest_scrubbed - client.normalize_type(typ) - - @pytest.mark.contract @pytest.mark.incremental class TestContractTypeChecking: diff --git a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_legacy_flag.out b/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_legacy_flag.out deleted file mode 100644 index 76d87f4d7a9f..000000000000 --- a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_legacy_flag.out +++ /dev/null @@ -1,8 +0,0 @@ -tests_015/test_contract.py::TestNormalize::test_normalize_legacy_flag - -{ Elt 0 1 } -At (unshown) location 0, value { Elt %a 0 1 } -is invalid for type map nat nat. -At (unshown) location 1, unexpected annotation. -Fatal error: - ill-typed data expression diff --git a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[None].out b/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[None].out deleted file mode 100644 index 56226aa08d1e..000000000000 --- a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[None].out +++ /dev/null @@ -1,10 +0,0 @@ -tests_015/test_contract.py::TestNormalize::test_normalize_script[None] - -{ parameter unit ; - storage unit ; - code { PUSH (list (pair nat nat nat nat)) - { Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } ; - DROP 2 ; - UNIT ; - NIL operation ; - PAIR } } diff --git a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized].out b/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized].out deleted file mode 100644 index 4e22be849455..000000000000 --- a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized].out +++ /dev/null @@ -1,10 +0,0 @@ -tests_015/test_contract.py::TestNormalize::test_normalize_script[Optimized] - -{ parameter unit ; - storage unit ; - code { PUSH (list (pair nat nat nat nat)) - { { 0 ; 3 ; 6 ; 9 } ; { 1 ; 4 ; 7 ; 10 } ; { 2 ; 5 ; 8 ; 11 } } ; - DROP 2 ; - UNIT ; - NIL operation ; - PAIR } } diff --git a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized_legacy].out b/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized_legacy].out deleted file mode 100644 index 7212dc21238c..000000000000 --- a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized_legacy].out +++ /dev/null @@ -1,12 +0,0 @@ -tests_015/test_contract.py::TestNormalize::test_normalize_script[Optimized_legacy] - -{ parameter unit ; - storage unit ; - code { PUSH (list (pair nat nat nat nat)) - { Pair 0 (Pair 3 (Pair 6 9)) ; - Pair 1 (Pair 4 (Pair 7 10)) ; - Pair 2 (Pair 5 (Pair 8 11)) } ; - DROP 2 ; - UNIT ; - NIL operation ; - PAIR } } diff --git a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Readable].out b/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Readable].out deleted file mode 100644 index 0b357da40223..000000000000 --- a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Readable].out +++ /dev/null @@ -1,10 +0,0 @@ -tests_015/test_contract.py::TestNormalize::test_normalize_script[Readable] - -{ parameter unit ; - storage unit ; - code { PUSH (list (pair nat nat nat nat)) - { Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } ; - DROP 2 ; - UNIT ; - NIL operation ; - PAIR } } diff --git a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool bytes)].out b/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool bytes)].out deleted file mode 100644 index c82cf253935e..000000000000 --- a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool bytes)].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_015/test_contract.py::TestNormalize::test_normalize_type[list (pair nat int bool bytes)] - -list (pair nat (pair int (pair bool bytes))) diff --git a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool)].out b/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool)].out deleted file mode 100644 index dcf59cb9f0bc..000000000000 --- a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool)].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_015/test_contract.py::TestNormalize::test_normalize_type[list (pair nat int bool)] - -list (pair nat (pair int bool)) diff --git a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int)].out b/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int)].out deleted file mode 100644 index f1b2084c72bc..000000000000 --- a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int)].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_015/test_contract.py::TestNormalize::test_normalize_type[list (pair nat int)] - -list (pair nat int) diff --git a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list nat].out b/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list nat].out deleted file mode 100644 index a03b28a8973a..000000000000 --- a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list nat].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_015/test_contract.py::TestNormalize::test_normalize_type[list nat] - -list nat diff --git a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[nat].out b/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[nat].out deleted file mode 100644 index 7ff78aa0ddbb..000000000000 --- a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[nat].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_015/test_contract.py::TestNormalize::test_normalize_type[nat] - -nat diff --git a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool bytes].out b/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool bytes].out deleted file mode 100644 index 02a57da9aa36..000000000000 --- a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool bytes].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_015/test_contract.py::TestNormalize::test_normalize_type[pair nat int bool bytes] - -pair nat (pair int (pair bool bytes)) diff --git a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool].out b/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool].out deleted file mode 100644 index ae4498025128..000000000000 --- a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_015/test_contract.py::TestNormalize::test_normalize_type[pair nat int bool] - -pair nat (pair int bool) diff --git a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int].out b/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int].out deleted file mode 100644 index 97540c223b26..000000000000 --- a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_015/test_contract.py::TestNormalize::test_normalize_type[pair nat int] - -pair nat int diff --git a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[None].out b/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[None].out deleted file mode 100644 index c9c1fa056637..000000000000 --- a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[None].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_015/test_contract.py::TestNormalize::test_normalize_unparsing_mode[None] - -{ Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } diff --git a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized].out b/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized].out deleted file mode 100644 index 4eeabb7280b1..000000000000 --- a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_015/test_contract.py::TestNormalize::test_normalize_unparsing_mode[Optimized] - -{ { 0 ; 3 ; 6 ; 9 } ; { 1 ; 4 ; 7 ; 10 } ; { 2 ; 5 ; 8 ; 11 } } diff --git a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized_legacy].out b/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized_legacy].out deleted file mode 100644 index cc7aee013ea5..000000000000 --- a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized_legacy].out +++ /dev/null @@ -1,5 +0,0 @@ -tests_015/test_contract.py::TestNormalize::test_normalize_unparsing_mode[Optimized_legacy] - -{ Pair 0 (Pair 3 (Pair 6 9)) ; - Pair 1 (Pair 4 (Pair 7 10)) ; - Pair 2 (Pair 5 (Pair 8 11)) } diff --git a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Readable].out b/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Readable].out deleted file mode 100644 index 5b1d45e62784..000000000000 --- a/tests_python/tests_015/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Readable].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_015/test_contract.py::TestNormalize::test_normalize_unparsing_mode[Readable] - -{ Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } diff --git a/tests_python/tests_015/test_contract.py b/tests_python/tests_015/test_contract.py index bcfef5ae53b0..c9790e30e47e 100644 --- a/tests_python/tests_015/test_contract.py +++ b/tests_python/tests_015/test_contract.py @@ -1594,54 +1594,6 @@ expruat2BS4KCwn9kbopeX1ZwxtrtJbyFhpnpnG6A5KdCBCwHNsdod ) == [results] -@pytest.mark.contract -@pytest.mark.regression -class TestNormalize: - """Regression tests for the "normalize data" command.""" - - modes = [None, 'Readable', 'Optimized', 'Optimized_legacy'] - - @pytest.mark.parametrize('mode', modes) - def test_normalize_unparsing_mode(self, client_regtest_scrubbed, mode): - client = client_regtest_scrubbed - input_data = ( - '{Pair 0 3 6 9; Pair 1 (Pair 4 (Pair 7 10)); {2; 5; 8; 11}}' - ) - input_type = 'list (pair nat nat nat nat)' - client.normalize(input_data, input_type, mode=mode) - - def test_normalize_legacy_flag(self, client_regtest_scrubbed): - client = client_regtest_scrubbed - input_data = '{Elt %a 0 1}' - input_type = 'map nat nat' - client.normalize(input_data, input_type, legacy=True) - error_pattern = 'unexpected annotation.' - with utils.assert_run_failure(error_pattern): - client.normalize(input_data, input_type, legacy=False) - - @pytest.mark.parametrize('mode', modes) - def test_normalize_script(self, client_regtest_scrubbed, mode): - client = client_regtest_scrubbed - path = os.path.join(CONTRACT_PATH, 'opcodes', 'comb-literals.tz') - client.normalize_script(path, mode=mode) - - types = [ - 'nat', - 'list nat', - 'pair nat int', - 'list (pair nat int)', - 'pair nat int bool', - 'list (pair nat int bool)', - 'pair nat int bool bytes', - 'list (pair nat int bool bytes)', - ] - - @pytest.mark.parametrize('typ', types) - def test_normalize_type(self, client_regtest_scrubbed, typ): - client = client_regtest_scrubbed - client.normalize_type(typ) - - @pytest.mark.contract @pytest.mark.incremental class TestContractTypeChecking: diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_legacy_flag.out b/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_legacy_flag.out deleted file mode 100644 index f85dafbbe73b..000000000000 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_legacy_flag.out +++ /dev/null @@ -1,8 +0,0 @@ -tests_alpha/test_contract.py::TestNormalize::test_normalize_legacy_flag - -{ Elt 0 1 } -At (unshown) location 0, value { Elt %a 0 1 } -is invalid for type map nat nat. -At (unshown) location 1, unexpected annotation. -Fatal error: - ill-typed data expression diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[None].out b/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[None].out deleted file mode 100644 index 8668e0b796a6..000000000000 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[None].out +++ /dev/null @@ -1,10 +0,0 @@ -tests_alpha/test_contract.py::TestNormalize::test_normalize_script[None] - -{ parameter unit ; - storage unit ; - code { PUSH (list (pair nat nat nat nat)) - { Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } ; - DROP 2 ; - UNIT ; - NIL operation ; - PAIR } } diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized].out b/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized].out deleted file mode 100644 index 2f25d7b36531..000000000000 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized].out +++ /dev/null @@ -1,10 +0,0 @@ -tests_alpha/test_contract.py::TestNormalize::test_normalize_script[Optimized] - -{ parameter unit ; - storage unit ; - code { PUSH (list (pair nat nat nat nat)) - { { 0 ; 3 ; 6 ; 9 } ; { 1 ; 4 ; 7 ; 10 } ; { 2 ; 5 ; 8 ; 11 } } ; - DROP 2 ; - UNIT ; - NIL operation ; - PAIR } } diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized_legacy].out b/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized_legacy].out deleted file mode 100644 index f9cc768df6a5..000000000000 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Optimized_legacy].out +++ /dev/null @@ -1,12 +0,0 @@ -tests_alpha/test_contract.py::TestNormalize::test_normalize_script[Optimized_legacy] - -{ parameter unit ; - storage unit ; - code { PUSH (list (pair nat nat nat nat)) - { Pair 0 (Pair 3 (Pair 6 9)) ; - Pair 1 (Pair 4 (Pair 7 10)) ; - Pair 2 (Pair 5 (Pair 8 11)) } ; - DROP 2 ; - UNIT ; - NIL operation ; - PAIR } } diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Readable].out b/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Readable].out deleted file mode 100644 index 29fd88c59a95..000000000000 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_script[Readable].out +++ /dev/null @@ -1,10 +0,0 @@ -tests_alpha/test_contract.py::TestNormalize::test_normalize_script[Readable] - -{ parameter unit ; - storage unit ; - code { PUSH (list (pair nat nat nat nat)) - { Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } ; - DROP 2 ; - UNIT ; - NIL operation ; - PAIR } } diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool bytes)].out b/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool bytes)].out deleted file mode 100644 index 7e5a3e33ec7a..000000000000 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool bytes)].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_alpha/test_contract.py::TestNormalize::test_normalize_type[list (pair nat int bool bytes)] - -list (pair nat (pair int (pair bool bytes))) diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool)].out b/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool)].out deleted file mode 100644 index ba911c59a770..000000000000 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int bool)].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_alpha/test_contract.py::TestNormalize::test_normalize_type[list (pair nat int bool)] - -list (pair nat (pair int bool)) diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int)].out b/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int)].out deleted file mode 100644 index 4cf8edb045ff..000000000000 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list (pair nat int)].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_alpha/test_contract.py::TestNormalize::test_normalize_type[list (pair nat int)] - -list (pair nat int) diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list nat].out b/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list nat].out deleted file mode 100644 index 71c75f1600a1..000000000000 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[list nat].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_alpha/test_contract.py::TestNormalize::test_normalize_type[list nat] - -list nat diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[nat].out b/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[nat].out deleted file mode 100644 index 82859c3f044b..000000000000 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[nat].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_alpha/test_contract.py::TestNormalize::test_normalize_type[nat] - -nat diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool bytes].out b/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool bytes].out deleted file mode 100644 index caeea900f604..000000000000 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool bytes].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_alpha/test_contract.py::TestNormalize::test_normalize_type[pair nat int bool bytes] - -pair nat (pair int (pair bool bytes)) diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool].out b/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool].out deleted file mode 100644 index dc6a5062ffb6..000000000000 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int bool].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_alpha/test_contract.py::TestNormalize::test_normalize_type[pair nat int bool] - -pair nat (pair int bool) diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int].out b/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int].out deleted file mode 100644 index 04ef11b9f897..000000000000 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_type[pair nat int].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_alpha/test_contract.py::TestNormalize::test_normalize_type[pair nat int] - -pair nat int diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[None].out b/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[None].out deleted file mode 100644 index 978685e04a2c..000000000000 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[None].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_alpha/test_contract.py::TestNormalize::test_normalize_unparsing_mode[None] - -{ Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized].out b/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized].out deleted file mode 100644 index bb3dc76a9359..000000000000 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_alpha/test_contract.py::TestNormalize::test_normalize_unparsing_mode[Optimized] - -{ { 0 ; 3 ; 6 ; 9 } ; { 1 ; 4 ; 7 ; 10 } ; { 2 ; 5 ; 8 ; 11 } } diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized_legacy].out b/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized_legacy].out deleted file mode 100644 index b511c9b56d7a..000000000000 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Optimized_legacy].out +++ /dev/null @@ -1,5 +0,0 @@ -tests_alpha/test_contract.py::TestNormalize::test_normalize_unparsing_mode[Optimized_legacy] - -{ Pair 0 (Pair 3 (Pair 6 9)) ; - Pair 1 (Pair 4 (Pair 7 10)) ; - Pair 2 (Pair 5 (Pair 8 11)) } diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Readable].out b/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Readable].out deleted file mode 100644 index 9d062161eb8c..000000000000 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestNormalize::test_normalize_unparsing_mode[Readable].out +++ /dev/null @@ -1,3 +0,0 @@ -tests_alpha/test_contract.py::TestNormalize::test_normalize_unparsing_mode[Readable] - -{ Pair 0 3 6 9 ; Pair 1 4 7 10 ; Pair 2 5 8 11 } diff --git a/tests_python/tests_alpha/test_contract.py b/tests_python/tests_alpha/test_contract.py index bcfef5ae53b0..c9790e30e47e 100644 --- a/tests_python/tests_alpha/test_contract.py +++ b/tests_python/tests_alpha/test_contract.py @@ -1594,54 +1594,6 @@ expruat2BS4KCwn9kbopeX1ZwxtrtJbyFhpnpnG6A5KdCBCwHNsdod ) == [results] -@pytest.mark.contract -@pytest.mark.regression -class TestNormalize: - """Regression tests for the "normalize data" command.""" - - modes = [None, 'Readable', 'Optimized', 'Optimized_legacy'] - - @pytest.mark.parametrize('mode', modes) - def test_normalize_unparsing_mode(self, client_regtest_scrubbed, mode): - client = client_regtest_scrubbed - input_data = ( - '{Pair 0 3 6 9; Pair 1 (Pair 4 (Pair 7 10)); {2; 5; 8; 11}}' - ) - input_type = 'list (pair nat nat nat nat)' - client.normalize(input_data, input_type, mode=mode) - - def test_normalize_legacy_flag(self, client_regtest_scrubbed): - client = client_regtest_scrubbed - input_data = '{Elt %a 0 1}' - input_type = 'map nat nat' - client.normalize(input_data, input_type, legacy=True) - error_pattern = 'unexpected annotation.' - with utils.assert_run_failure(error_pattern): - client.normalize(input_data, input_type, legacy=False) - - @pytest.mark.parametrize('mode', modes) - def test_normalize_script(self, client_regtest_scrubbed, mode): - client = client_regtest_scrubbed - path = os.path.join(CONTRACT_PATH, 'opcodes', 'comb-literals.tz') - client.normalize_script(path, mode=mode) - - types = [ - 'nat', - 'list nat', - 'pair nat int', - 'list (pair nat int)', - 'pair nat int bool', - 'list (pair nat int bool)', - 'pair nat int bool bytes', - 'list (pair nat int bool bytes)', - ] - - @pytest.mark.parametrize('typ', types) - def test_normalize_type(self, client_regtest_scrubbed, typ): - client = client_regtest_scrubbed - client.normalize_type(typ) - - @pytest.mark.contract @pytest.mark.incremental class TestContractTypeChecking: -- GitLab From 3bba4da4e3bcc234de824b0249c5ab048e88222f Mon Sep 17 00:00:00 2001 From: lin Date: Tue, 18 Oct 2022 02:30:02 +0900 Subject: [PATCH 5/6] Tezt/Client: Add normalize type command --- tezt/lib_tezos/client.ml | 6 ++++++ tezt/lib_tezos/client.mli | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/tezt/lib_tezos/client.ml b/tezt/lib_tezos/client.ml index 942cad1ca84f..4522e69acf8f 100644 --- a/tezt/lib_tezos/client.ml +++ b/tezt/lib_tezos/client.ml @@ -1509,6 +1509,12 @@ let spawn_typecheck_data ~data ~typ ?gas ?(legacy = false) client = in spawn_command client cmd +let spawn_normalize_type ?hooks ~typ client = + spawn_command ?hooks client ["normalize"; "type"; typ] + +let normalize_type ?hooks ~typ client = + spawn_normalize_type ?hooks ~typ client |> Process.check_and_read_stdout + let typecheck_data ~data ~typ ?gas ?(legacy = false) client = spawn_typecheck_data ~data ~typ ?gas ~legacy client |> Process.check diff --git a/tezt/lib_tezos/client.mli b/tezt/lib_tezos/client.mli index 6348d52888f8..3d8743d84caa 100644 --- a/tezt/lib_tezos/client.mli +++ b/tezt/lib_tezos/client.mli @@ -1212,6 +1212,13 @@ val spawn_normalize_script : t -> Process.t +(** Run [octez-client normalize type ..]*) +val normalize_type : ?hooks:Process_hooks.t -> typ:string -> t -> string Lwt.t + +(** Same as [normalize_type], but do not wait for the process to exit. *) +val spawn_normalize_type : + ?hooks:Process_hooks.t -> typ:string -> t -> Process.t + (** Run [octez-client typecheck data ..]*) val typecheck_data : data:string -> typ:string -> ?gas:int -> ?legacy:bool -> t -> unit Lwt.t -- GitLab From 5fa45e3c8344550b4e05fc993e87ec7e174ff83d Mon Sep 17 00:00:00 2001 From: lin Date: Mon, 31 Oct 2022 20:55:16 +0900 Subject: [PATCH 6/6] Tezt: Migrate tests for normalize type --- .../Alpha- Test normalize type.out | 24 +++++++++ .../Kathmandu- Test normalize type.out | 24 +++++++++ .../Lima- Test normalize type.out | 24 +++++++++ tezt/tests/normalize.ml | 53 ++++++++++++++----- 4 files changed, 111 insertions(+), 14 deletions(-) create mode 100644 tezt/tests/expected/normalize.ml/Alpha- Test normalize type.out create mode 100644 tezt/tests/expected/normalize.ml/Kathmandu- Test normalize type.out create mode 100644 tezt/tests/expected/normalize.ml/Lima- Test normalize type.out diff --git a/tezt/tests/expected/normalize.ml/Alpha- Test normalize type.out b/tezt/tests/expected/normalize.ml/Alpha- Test normalize type.out new file mode 100644 index 000000000000..c35ef0e62ff8 --- /dev/null +++ b/tezt/tests/expected/normalize.ml/Alpha- Test normalize type.out @@ -0,0 +1,24 @@ + +./octez-client --mode mockup normalize type nat +nat + +./octez-client --mode mockup normalize type 'list nat' +list nat + +./octez-client --mode mockup normalize type 'pair nat int' +pair nat int + +./octez-client --mode mockup normalize type 'list (pair nat int)' +list (pair nat int) + +./octez-client --mode mockup normalize type 'pair nat int bool' +pair nat (pair int bool) + +./octez-client --mode mockup normalize type 'list (pair nat int bool)' +list (pair nat (pair int bool)) + +./octez-client --mode mockup normalize type 'pair nat int bool bytes' +pair nat (pair int (pair bool bytes)) + +./octez-client --mode mockup normalize type 'list (pair nat int bool bytes)' +list (pair nat (pair int (pair bool bytes))) diff --git a/tezt/tests/expected/normalize.ml/Kathmandu- Test normalize type.out b/tezt/tests/expected/normalize.ml/Kathmandu- Test normalize type.out new file mode 100644 index 000000000000..c35ef0e62ff8 --- /dev/null +++ b/tezt/tests/expected/normalize.ml/Kathmandu- Test normalize type.out @@ -0,0 +1,24 @@ + +./octez-client --mode mockup normalize type nat +nat + +./octez-client --mode mockup normalize type 'list nat' +list nat + +./octez-client --mode mockup normalize type 'pair nat int' +pair nat int + +./octez-client --mode mockup normalize type 'list (pair nat int)' +list (pair nat int) + +./octez-client --mode mockup normalize type 'pair nat int bool' +pair nat (pair int bool) + +./octez-client --mode mockup normalize type 'list (pair nat int bool)' +list (pair nat (pair int bool)) + +./octez-client --mode mockup normalize type 'pair nat int bool bytes' +pair nat (pair int (pair bool bytes)) + +./octez-client --mode mockup normalize type 'list (pair nat int bool bytes)' +list (pair nat (pair int (pair bool bytes))) diff --git a/tezt/tests/expected/normalize.ml/Lima- Test normalize type.out b/tezt/tests/expected/normalize.ml/Lima- Test normalize type.out new file mode 100644 index 000000000000..c35ef0e62ff8 --- /dev/null +++ b/tezt/tests/expected/normalize.ml/Lima- Test normalize type.out @@ -0,0 +1,24 @@ + +./octez-client --mode mockup normalize type nat +nat + +./octez-client --mode mockup normalize type 'list nat' +list nat + +./octez-client --mode mockup normalize type 'pair nat int' +pair nat int + +./octez-client --mode mockup normalize type 'list (pair nat int)' +list (pair nat int) + +./octez-client --mode mockup normalize type 'pair nat int bool' +pair nat (pair int bool) + +./octez-client --mode mockup normalize type 'list (pair nat int bool)' +list (pair nat (pair int bool)) + +./octez-client --mode mockup normalize type 'pair nat int bool bytes' +pair nat (pair int (pair bool bytes)) + +./octez-client --mode mockup normalize type 'list (pair nat int bool bytes)' +list (pair nat (pair int (pair bool bytes))) diff --git a/tezt/tests/normalize.ml b/tezt/tests/normalize.ml index ce4dfc01605c..056a72ef5d5b 100644 --- a/tezt/tests/normalize.ml +++ b/tezt/tests/normalize.ml @@ -1,6 +1,7 @@ (*****************************************************************************) (* *) (* Open Source License *) +(* Copyright (c) 2020 Nomadic Labs *) (* Copyright (c) 2022 Marigold *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) @@ -45,9 +46,9 @@ let test_normalize_unparsing_mode = let typ = "list (pair nat nat nat nat)" in let* () = modes - |> Lwt_list.iter_s (fun mode -> - let* _ = Client.normalize_data client ~hooks ?mode ~data ~typ in - unit) + |> Lwt_list.iter_s @@ fun mode -> + let* _ = Client.normalize_data client ~hooks ?mode ~data ~typ in + unit in unit @@ -79,20 +80,44 @@ let test_normalize_script = let* client = Client.init_mockup ~protocol () in let* () = modes - |> Lwt_list.iter_s (fun mode -> - let* _ = - Client.normalize_script - client - ~hooks - ?mode - ~script: - "file:./tezt/tests/contracts/proto_alpha/comb-literals.tz" - in - unit) + |> Lwt_list.iter_s @@ fun mode -> + let* _ = + Client.normalize_script + client + ~hooks + ?mode + ~script:"file:./tezt/tests/contracts/proto_alpha/comb-literals.tz" + in + unit + in + unit + +let test_normalize_type = + Protocol.register_regression_test + ~__FILE__ + ~title:"Test normalize type" + ~tags:["client"; "normalize"] + @@ fun protocol -> + let* client = Client.init_mockup ~protocol () in + let* () = + [ + "nat"; + "list nat"; + "pair nat int"; + "list (pair nat int)"; + "pair nat int bool"; + "list (pair nat int bool)"; + "pair nat int bool bytes"; + "list (pair nat int bool bytes)"; + ] + |> Lwt_list.iter_s @@ fun typ -> + let* _ = Client.normalize_type client ~hooks ~typ in + unit in unit let register ~protocols = test_normalize_unparsing_mode protocols ; test_normalize_legacy_flag protocols ; - test_normalize_script protocols + test_normalize_script protocols ; + test_normalize_type protocols -- GitLab