From 0fba37ea705edc900ffb0e28731896139d9db28a Mon Sep 17 00:00:00 2001 From: YY Date: Fri, 7 Oct 2022 13:36:52 +0800 Subject: [PATCH 1/2] Tezt: add test case - big_map arity --- tezt/tests/big_map_arity.ml | 56 +++++++++++++++++++++++++++++++++++++ tezt/tests/main.ml | 1 + 2 files changed, 57 insertions(+) create mode 100644 tezt/tests/big_map_arity.ml diff --git a/tezt/tests/big_map_arity.ml b/tezt/tests/big_map_arity.ml new file mode 100644 index 000000000000..270adf516817 --- /dev/null +++ b/tezt/tests/big_map_arity.ml @@ -0,0 +1,56 @@ +(*****************************************************************************) +(* *) +(* 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 + ------- + Components: Michelson + Invocation: dune exec tezt/tests/main.exe -- --file big_map_arity.ml + Subject: Tests the error message in case the EMPTY_BIG_MAP instruction has bad arity. +*) + +(* The EMPTY_BIG_MAP instruction has bad arity (1 argument instead of 2). *) +let ill_typed_big_map_arity_script = + {| +parameter unit; +storage unit; +code { DROP; EMPTY_BIG_MAP nat; DROP; UNIT; NIL operation; PAIR; } +|} + +let expected_msg = + rex "primitive EMPTY_BIG_MAP expects 2 arguments but is given 1." + +let test_big_map_arity = + Protocol.register_test + ~__FILE__ + ~title:"Test EMPTY_BIG_MAP arity error" + ~tags:["client"; "michelson"] + @@ fun protocol -> + let* client = Client.init_mockup ~protocol () in + let process = + Client.spawn_typecheck_script ~script:ill_typed_big_map_arity_script client + in + Process.check_error ~exit_code:1 ~msg:expected_msg process + +let register ~protocols = test_big_map_arity protocols diff --git a/tezt/tests/main.ml b/tezt/tests/main.ml index b65cc8481b23..8198ec646e1e 100644 --- a/tezt/tests/main.ml +++ b/tezt/tests/main.ml @@ -89,6 +89,7 @@ let register_protocol_agnostic_tests () = Baking.register_operations_pool ~protocols:[Kathmandu; Lima; Alpha] ; Basic.register ~protocols:[Alpha] ; Big_map_all.register ~protocols:[Alpha] ; + Big_map_arity.register ~protocols:[Alpha] ; Bootstrap.register ~protocols:[Alpha] ; Cache_cache.register protocols ; Client_config.register ~protocols:[Alpha] ; -- GitLab From 1970bc9a438c8437372740d66d5a8ec4820f7f13 Mon Sep 17 00:00:00 2001 From: YY Date: Fri, 7 Oct 2022 14:51:52 +0800 Subject: [PATCH 2/2] Pytest: remove case - big_map_arity_error --- .../contracts_014/ill_typed/big_map_arity.tz | 5 ----- .../contracts_015/ill_typed/big_map_arity.tz | 5 ----- .../contracts_alpha/ill_typed/big_map_arity.tz | 5 ----- tests_python/tests_014/test_contract.py | 12 ------------ tests_python/tests_015/test_contract.py | 12 ------------ tests_python/tests_alpha/test_contract.py | 12 ------------ 6 files changed, 51 deletions(-) delete mode 100644 tests_python/contracts_014/ill_typed/big_map_arity.tz delete mode 100644 tests_python/contracts_015/ill_typed/big_map_arity.tz delete mode 100644 tests_python/contracts_alpha/ill_typed/big_map_arity.tz diff --git a/tests_python/contracts_014/ill_typed/big_map_arity.tz b/tests_python/contracts_014/ill_typed/big_map_arity.tz deleted file mode 100644 index 5e5a7d60d5b7..000000000000 --- a/tests_python/contracts_014/ill_typed/big_map_arity.tz +++ /dev/null @@ -1,5 +0,0 @@ -# This contract tests the error message in case the EMPTY_BIG_MAP instruction has bad arity (1 argument instead of 2). -# The expected type-checking error is "primitive EMPTY_BIG_MAP expects 2 arguments but is given 1." -parameter unit; -storage unit; -code { DROP; EMPTY_BIG_MAP nat; DROP; UNIT; NIL operation; PAIR; } diff --git a/tests_python/contracts_015/ill_typed/big_map_arity.tz b/tests_python/contracts_015/ill_typed/big_map_arity.tz deleted file mode 100644 index 5e5a7d60d5b7..000000000000 --- a/tests_python/contracts_015/ill_typed/big_map_arity.tz +++ /dev/null @@ -1,5 +0,0 @@ -# This contract tests the error message in case the EMPTY_BIG_MAP instruction has bad arity (1 argument instead of 2). -# The expected type-checking error is "primitive EMPTY_BIG_MAP expects 2 arguments but is given 1." -parameter unit; -storage unit; -code { DROP; EMPTY_BIG_MAP nat; DROP; UNIT; NIL operation; PAIR; } diff --git a/tests_python/contracts_alpha/ill_typed/big_map_arity.tz b/tests_python/contracts_alpha/ill_typed/big_map_arity.tz deleted file mode 100644 index 5e5a7d60d5b7..000000000000 --- a/tests_python/contracts_alpha/ill_typed/big_map_arity.tz +++ /dev/null @@ -1,5 +0,0 @@ -# This contract tests the error message in case the EMPTY_BIG_MAP instruction has bad arity (1 argument instead of 2). -# The expected type-checking error is "primitive EMPTY_BIG_MAP expects 2 arguments but is given 1." -parameter unit; -storage unit; -code { DROP; EMPTY_BIG_MAP nat; DROP; UNIT; NIL operation; PAIR; } diff --git a/tests_python/tests_014/test_contract.py b/tests_python/tests_014/test_contract.py index 6fe671bee951..fadefc087f92 100644 --- a/tests_python/tests_014/test_contract.py +++ b/tests_python/tests_014/test_contract.py @@ -1791,18 +1791,6 @@ class TestComparables: ) -@pytest.mark.contract -class TestTypecheckingErrors: - def test_big_map_arity_error(self, client: Client): - error_pattern = ( - 'primitive EMPTY_BIG_MAP expects 2 arguments but is given 1.' - ) - with utils.assert_run_failure(error_pattern): - client.typecheck( - os.path.join(CONTRACT_PATH, 'ill_typed', 'big_map_arity.tz') - ) - - BAD_ANNOT_TEST = ''' parameter bytes; storage (option (lambda unit unit)); diff --git a/tests_python/tests_015/test_contract.py b/tests_python/tests_015/test_contract.py index 6fe671bee951..fadefc087f92 100644 --- a/tests_python/tests_015/test_contract.py +++ b/tests_python/tests_015/test_contract.py @@ -1791,18 +1791,6 @@ class TestComparables: ) -@pytest.mark.contract -class TestTypecheckingErrors: - def test_big_map_arity_error(self, client: Client): - error_pattern = ( - 'primitive EMPTY_BIG_MAP expects 2 arguments but is given 1.' - ) - with utils.assert_run_failure(error_pattern): - client.typecheck( - os.path.join(CONTRACT_PATH, 'ill_typed', 'big_map_arity.tz') - ) - - BAD_ANNOT_TEST = ''' parameter bytes; storage (option (lambda unit unit)); diff --git a/tests_python/tests_alpha/test_contract.py b/tests_python/tests_alpha/test_contract.py index 6fe671bee951..fadefc087f92 100644 --- a/tests_python/tests_alpha/test_contract.py +++ b/tests_python/tests_alpha/test_contract.py @@ -1791,18 +1791,6 @@ class TestComparables: ) -@pytest.mark.contract -class TestTypecheckingErrors: - def test_big_map_arity_error(self, client: Client): - error_pattern = ( - 'primitive EMPTY_BIG_MAP expects 2 arguments but is given 1.' - ) - with utils.assert_run_failure(error_pattern): - client.typecheck( - os.path.join(CONTRACT_PATH, 'ill_typed', 'big_map_arity.tz') - ) - - BAD_ANNOT_TEST = ''' parameter bytes; storage (option (lambda unit unit)); -- GitLab