diff --git a/tests_python/tests_014/test_contract.py b/tests_python/tests_014/test_contract.py index 9f0976f439eac2aaa1373b9f37935074e0d410a2..bcfef5ae53b0437efa545e969b82ca2926c08eb1 100644 --- a/tests_python/tests_014/test_contract.py +++ b/tests_python/tests_014/test_contract.py @@ -621,53 +621,6 @@ class TestContracts: client.transfer(0, 'bootstrap2', nonexistent, []) -FIRST_EXPLOSION = ''' -{ parameter unit; - storage unit; - code{ DROP; PUSH nat 0 ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DROP ; UNIT ; NIL operation ; PAIR} } -''' - - -# FIRST_EXPLOSION costs a large amount of gas just for typechecking. -# FIRST_EXPLOSION_BIGTYPE type size exceeds the protocol set bound. -FIRST_EXPLOSION_BIGTYPE = ''' -{ parameter unit; - storage unit; - code{ DROP; PUSH nat 0 ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DROP ; UNIT ; NIL operation ; PAIR} } -''' - - -SECOND_EXPLOSION = ''' -{ parameter (list int) ; - storage (list (list (list int))) ; - code { CAR ; DIP { NIL (list int) } ; - DUP ; ITER { DROP ; DUP ; DIP { CONS } } ; - DROP ; DIP { NIL (list (list int)) } ; - DUP ; ITER { DROP ; DUP ; DIP { CONS } } ; - DROP ; NIL operation ; PAIR } } -''' - - @pytest.mark.incremental @pytest.mark.contract class TestView: @@ -1046,101 +999,6 @@ class TestView: originate(client, session, path, '4', 0) -@pytest.mark.contract -class TestGasBound: - def test_write_contract(self, tmpdir, session: dict): - items = { - 'first_explosion.tz': FIRST_EXPLOSION, - 'first_explosion_bigtype.tz': FIRST_EXPLOSION_BIGTYPE, - 'second_explosion.tz': SECOND_EXPLOSION, - }.items() - for name, script in items: - contract = f'{tmpdir}/{name}' - with open(contract, 'w') as contract_file: - contract_file.write(script) - session[name] = contract - - def test_originate_first_explosion(self, client: Client, session: dict): - name = 'first_explosion.tz' - contract = session[name] - client.typecheck(contract) - args = ['-G', f'{1461}', '--burn-cap', '10'] - - expected_error = "Gas limit exceeded during typechecking or execution" - with utils.assert_run_failure(expected_error): - client.originate(f'{name}', 0, 'bootstrap1', contract, args) - - def test_originate_big_type(self, client: Client, session: dict): - name = 'first_explosion_bigtype.tz' - contract = session[name] - - expected_error = "type exceeded maximum type size" - with utils.assert_run_failure(expected_error): - client.typecheck(contract) - - def test_originate_second_explosion(self, client: Client, session: dict): - name = 'second_explosion.tz' - contract = session[name] - storage = '{}' - inp = '{1;2;3;4;5;6;7;8;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1}' - client.run_script(contract, storage, inp) - - def test_originate_second_explosion_fail( - self, client: Client, session: dict - ): - name = 'second_explosion.tz' - contract = session[name] - storage = '{}' - inp = ( - '{1;2;3;4;5;6;7;8;9;0;1;2;3;4;5;6;7;1;1;1;1;1;1;1;1;1;1;1' - + ';1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1}' - ) - - expected_error = ( - "Cannot serialize the resulting storage" - + " value within the provided gas bounds." - ) - with utils.assert_run_failure(expected_error): - client.run_script(contract, storage, inp, gas=9290) - - def test_typecheck_map_dup_key(self, client: Client): - - expected_error = ( - 'Map literals cannot contain duplicate' - + ' keys, however a duplicate key was found' - ) - with utils.assert_run_failure(expected_error): - client.typecheck_data('{ Elt 0 1 ; Elt 0 1}', '(map nat nat)') - - def test_typecheck_map_bad_ordering(self, client: Client): - - expected_error = ( - "Keys in a map literal must be in strictly" - + " ascending order, but they were unordered in literal" - ) - with utils.assert_run_failure(expected_error): - client.typecheck_data( - '{ Elt 0 1 ; Elt 10 1 ; Elt 5 1 }', '(map nat nat)' - ) - - def test_typecheck_set_bad_ordering(self, client: Client): - - expected_error = ( - "Values in a set literal must be in strictly" - + " ascending order, but they were unordered in literal" - ) - with utils.assert_run_failure(expected_error): - client.typecheck_data('{ "A" ; "C" ; "B" }', '(set string)') - - def test_typecheck_set_no_duplicates(self, client: Client): - expected_error = ( - "Set literals cannot contain duplicate values," - + " however a duplicate value was found" - ) - with utils.assert_run_failure(expected_error): - client.typecheck_data('{ "A" ; "B" ; "B" }', '(set string)') - - @pytest.mark.incremental @pytest.mark.contract class TestChainId: diff --git a/tests_python/tests_015/test_contract.py b/tests_python/tests_015/test_contract.py index 9f0976f439eac2aaa1373b9f37935074e0d410a2..bcfef5ae53b0437efa545e969b82ca2926c08eb1 100644 --- a/tests_python/tests_015/test_contract.py +++ b/tests_python/tests_015/test_contract.py @@ -621,53 +621,6 @@ class TestContracts: client.transfer(0, 'bootstrap2', nonexistent, []) -FIRST_EXPLOSION = ''' -{ parameter unit; - storage unit; - code{ DROP; PUSH nat 0 ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DROP ; UNIT ; NIL operation ; PAIR} } -''' - - -# FIRST_EXPLOSION costs a large amount of gas just for typechecking. -# FIRST_EXPLOSION_BIGTYPE type size exceeds the protocol set bound. -FIRST_EXPLOSION_BIGTYPE = ''' -{ parameter unit; - storage unit; - code{ DROP; PUSH nat 0 ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DROP ; UNIT ; NIL operation ; PAIR} } -''' - - -SECOND_EXPLOSION = ''' -{ parameter (list int) ; - storage (list (list (list int))) ; - code { CAR ; DIP { NIL (list int) } ; - DUP ; ITER { DROP ; DUP ; DIP { CONS } } ; - DROP ; DIP { NIL (list (list int)) } ; - DUP ; ITER { DROP ; DUP ; DIP { CONS } } ; - DROP ; NIL operation ; PAIR } } -''' - - @pytest.mark.incremental @pytest.mark.contract class TestView: @@ -1046,101 +999,6 @@ class TestView: originate(client, session, path, '4', 0) -@pytest.mark.contract -class TestGasBound: - def test_write_contract(self, tmpdir, session: dict): - items = { - 'first_explosion.tz': FIRST_EXPLOSION, - 'first_explosion_bigtype.tz': FIRST_EXPLOSION_BIGTYPE, - 'second_explosion.tz': SECOND_EXPLOSION, - }.items() - for name, script in items: - contract = f'{tmpdir}/{name}' - with open(contract, 'w') as contract_file: - contract_file.write(script) - session[name] = contract - - def test_originate_first_explosion(self, client: Client, session: dict): - name = 'first_explosion.tz' - contract = session[name] - client.typecheck(contract) - args = ['-G', f'{1461}', '--burn-cap', '10'] - - expected_error = "Gas limit exceeded during typechecking or execution" - with utils.assert_run_failure(expected_error): - client.originate(f'{name}', 0, 'bootstrap1', contract, args) - - def test_originate_big_type(self, client: Client, session: dict): - name = 'first_explosion_bigtype.tz' - contract = session[name] - - expected_error = "type exceeded maximum type size" - with utils.assert_run_failure(expected_error): - client.typecheck(contract) - - def test_originate_second_explosion(self, client: Client, session: dict): - name = 'second_explosion.tz' - contract = session[name] - storage = '{}' - inp = '{1;2;3;4;5;6;7;8;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1}' - client.run_script(contract, storage, inp) - - def test_originate_second_explosion_fail( - self, client: Client, session: dict - ): - name = 'second_explosion.tz' - contract = session[name] - storage = '{}' - inp = ( - '{1;2;3;4;5;6;7;8;9;0;1;2;3;4;5;6;7;1;1;1;1;1;1;1;1;1;1;1' - + ';1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1}' - ) - - expected_error = ( - "Cannot serialize the resulting storage" - + " value within the provided gas bounds." - ) - with utils.assert_run_failure(expected_error): - client.run_script(contract, storage, inp, gas=9290) - - def test_typecheck_map_dup_key(self, client: Client): - - expected_error = ( - 'Map literals cannot contain duplicate' - + ' keys, however a duplicate key was found' - ) - with utils.assert_run_failure(expected_error): - client.typecheck_data('{ Elt 0 1 ; Elt 0 1}', '(map nat nat)') - - def test_typecheck_map_bad_ordering(self, client: Client): - - expected_error = ( - "Keys in a map literal must be in strictly" - + " ascending order, but they were unordered in literal" - ) - with utils.assert_run_failure(expected_error): - client.typecheck_data( - '{ Elt 0 1 ; Elt 10 1 ; Elt 5 1 }', '(map nat nat)' - ) - - def test_typecheck_set_bad_ordering(self, client: Client): - - expected_error = ( - "Values in a set literal must be in strictly" - + " ascending order, but they were unordered in literal" - ) - with utils.assert_run_failure(expected_error): - client.typecheck_data('{ "A" ; "C" ; "B" }', '(set string)') - - def test_typecheck_set_no_duplicates(self, client: Client): - expected_error = ( - "Set literals cannot contain duplicate values," - + " however a duplicate value was found" - ) - with utils.assert_run_failure(expected_error): - client.typecheck_data('{ "A" ; "B" ; "B" }', '(set string)') - - @pytest.mark.incremental @pytest.mark.contract class TestChainId: diff --git a/tests_python/tests_alpha/test_contract.py b/tests_python/tests_alpha/test_contract.py index 9f0976f439eac2aaa1373b9f37935074e0d410a2..bcfef5ae53b0437efa545e969b82ca2926c08eb1 100644 --- a/tests_python/tests_alpha/test_contract.py +++ b/tests_python/tests_alpha/test_contract.py @@ -621,53 +621,6 @@ class TestContracts: client.transfer(0, 'bootstrap2', nonexistent, []) -FIRST_EXPLOSION = ''' -{ parameter unit; - storage unit; - code{ DROP; PUSH nat 0 ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DROP ; UNIT ; NIL operation ; PAIR} } -''' - - -# FIRST_EXPLOSION costs a large amount of gas just for typechecking. -# FIRST_EXPLOSION_BIGTYPE type size exceeds the protocol set bound. -FIRST_EXPLOSION_BIGTYPE = ''' -{ parameter unit; - storage unit; - code{ DROP; PUSH nat 0 ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DUP ; PAIR ; - DROP ; UNIT ; NIL operation ; PAIR} } -''' - - -SECOND_EXPLOSION = ''' -{ parameter (list int) ; - storage (list (list (list int))) ; - code { CAR ; DIP { NIL (list int) } ; - DUP ; ITER { DROP ; DUP ; DIP { CONS } } ; - DROP ; DIP { NIL (list (list int)) } ; - DUP ; ITER { DROP ; DUP ; DIP { CONS } } ; - DROP ; NIL operation ; PAIR } } -''' - - @pytest.mark.incremental @pytest.mark.contract class TestView: @@ -1046,101 +999,6 @@ class TestView: originate(client, session, path, '4', 0) -@pytest.mark.contract -class TestGasBound: - def test_write_contract(self, tmpdir, session: dict): - items = { - 'first_explosion.tz': FIRST_EXPLOSION, - 'first_explosion_bigtype.tz': FIRST_EXPLOSION_BIGTYPE, - 'second_explosion.tz': SECOND_EXPLOSION, - }.items() - for name, script in items: - contract = f'{tmpdir}/{name}' - with open(contract, 'w') as contract_file: - contract_file.write(script) - session[name] = contract - - def test_originate_first_explosion(self, client: Client, session: dict): - name = 'first_explosion.tz' - contract = session[name] - client.typecheck(contract) - args = ['-G', f'{1461}', '--burn-cap', '10'] - - expected_error = "Gas limit exceeded during typechecking or execution" - with utils.assert_run_failure(expected_error): - client.originate(f'{name}', 0, 'bootstrap1', contract, args) - - def test_originate_big_type(self, client: Client, session: dict): - name = 'first_explosion_bigtype.tz' - contract = session[name] - - expected_error = "type exceeded maximum type size" - with utils.assert_run_failure(expected_error): - client.typecheck(contract) - - def test_originate_second_explosion(self, client: Client, session: dict): - name = 'second_explosion.tz' - contract = session[name] - storage = '{}' - inp = '{1;2;3;4;5;6;7;8;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1}' - client.run_script(contract, storage, inp) - - def test_originate_second_explosion_fail( - self, client: Client, session: dict - ): - name = 'second_explosion.tz' - contract = session[name] - storage = '{}' - inp = ( - '{1;2;3;4;5;6;7;8;9;0;1;2;3;4;5;6;7;1;1;1;1;1;1;1;1;1;1;1' - + ';1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1}' - ) - - expected_error = ( - "Cannot serialize the resulting storage" - + " value within the provided gas bounds." - ) - with utils.assert_run_failure(expected_error): - client.run_script(contract, storage, inp, gas=9290) - - def test_typecheck_map_dup_key(self, client: Client): - - expected_error = ( - 'Map literals cannot contain duplicate' - + ' keys, however a duplicate key was found' - ) - with utils.assert_run_failure(expected_error): - client.typecheck_data('{ Elt 0 1 ; Elt 0 1}', '(map nat nat)') - - def test_typecheck_map_bad_ordering(self, client: Client): - - expected_error = ( - "Keys in a map literal must be in strictly" - + " ascending order, but they were unordered in literal" - ) - with utils.assert_run_failure(expected_error): - client.typecheck_data( - '{ Elt 0 1 ; Elt 10 1 ; Elt 5 1 }', '(map nat nat)' - ) - - def test_typecheck_set_bad_ordering(self, client: Client): - - expected_error = ( - "Values in a set literal must be in strictly" - + " ascending order, but they were unordered in literal" - ) - with utils.assert_run_failure(expected_error): - client.typecheck_data('{ "A" ; "C" ; "B" }', '(set string)') - - def test_typecheck_set_no_duplicates(self, client: Client): - expected_error = ( - "Set literals cannot contain duplicate values," - + " however a duplicate value was found" - ) - with utils.assert_run_failure(expected_error): - client.typecheck_data('{ "A" ; "B" ; "B" }', '(set string)') - - @pytest.mark.incremental @pytest.mark.contract class TestChainId: diff --git a/tezt/lib_tezos/client.ml b/tezt/lib_tezos/client.ml index e8e73e0989d74d20bde21a36e795023d26b58856..a26f281000233f9c47a54eada07a5971571cf34d 100644 --- a/tezt/lib_tezos/client.ml +++ b/tezt/lib_tezos/client.ml @@ -1331,8 +1331,8 @@ let stresstest ?endpoint ?source_aliases ?source_pkhs ?source_accounts ?seed client |> Process.check -let spawn_run_script ?hooks ?balance ?self_address ?source ?payer ~prg ~storage - ~input client = +let spawn_run_script ?hooks ?balance ?self_address ?source ?payer ?gas ~prg + ~storage ~input client = spawn_command ?hooks client @@ -1340,7 +1340,8 @@ let spawn_run_script ?hooks ?balance ?self_address ?source ?payer ~prg ~storage @ optional_arg "payer" Fun.id payer @ optional_arg "source" Fun.id source @ optional_arg "balance" Tez.to_string balance - @ optional_arg "self-address" Fun.id self_address) + @ optional_arg "self-address" Fun.id self_address + @ optional_arg "gas" (fun gas -> string_of_int gas) gas) let stresstest_estimate_gas ?endpoint client = let* output = @@ -1377,8 +1378,8 @@ let stresstest_fund_accounts_from_source ?endpoint ~source_key_pkh ?batch_size initial_amount) |> Process.check -let run_script ?hooks ?balance ?self_address ?source ?payer ~prg ~storage ~input - client = +let run_script ?hooks ?balance ?self_address ?source ?payer ?gas ~prg ~storage + ~input client = let* client_output = spawn_run_script ?hooks @@ -1386,6 +1387,7 @@ let run_script ?hooks ?balance ?self_address ?source ?payer ~prg ~storage ~input ?source ?payer ?self_address + ?gas ~prg ~storage ~input diff --git a/tezt/lib_tezos/client.mli b/tezt/lib_tezos/client.mli index f027e19f441c770f9c61929bee3f6be3beea52bf..2c74e0a726650d0a012012a66dd19d42be3e5bf1 100644 --- a/tezt/lib_tezos/client.mli +++ b/tezt/lib_tezos/client.mli @@ -1085,6 +1085,7 @@ val run_script : ?self_address:string -> ?source:string -> ?payer:string -> + ?gas:int -> prg:string -> storage:string -> input:string -> @@ -1098,6 +1099,7 @@ val spawn_run_script : ?self_address:string -> ?source:string -> ?payer:string -> + ?gas:int -> prg:string -> storage:string -> input:string -> diff --git a/tezt/tests/gas_bound.ml b/tezt/tests/gas_bound.ml new file mode 100644 index 0000000000000000000000000000000000000000..cd62eb147f53f08972a43dbb7aad738dfa2aafbf --- /dev/null +++ b/tezt/tests/gas_bound.ml @@ -0,0 +1,216 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2021 Nomadic Labs *) +(* 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: Michelson + Invocation: dune exec tezt/tests/main.exe -- --file gas_bound.ml + Subject: Gas bound +*) + +let first_explosion = + {| +parameter unit; +storage unit; +code{ + DROP; PUSH nat 0 ; + DUP ; PAIR ; DUP ; + PAIR ; DUP ; PAIR ; + DUP ; PAIR ; DUP ; + PAIR ; DUP ; PAIR ; + DUP ; PAIR ; DUP ; + PAIR ; DROP ; UNIT ; + NIL operation ; PAIR}; +|} + +let first_explosion_bigtype = + {| +parameter unit; +storage unit; +code{ + DROP; PUSH nat 0 ; DUP ; + PAIR ; DUP ; PAIR ; DUP ; + PAIR ; DUP ; PAIR ; DUP ; + PAIR ; DUP ; PAIR ; DUP ; + PAIR ; DUP ; PAIR ; DUP ; + PAIR ; DUP ; PAIR ; DROP ; + UNIT ; NIL operation ; PAIR}; +|} + +let second_explosion = + {| +parameter (list int) ; +storage (list (list (list int))) ; +code { CAR ; DIP { NIL (list int) } ; + DUP ; ITER { DROP ; DUP ; DIP { CONS } } ; + DROP ; DIP { NIL (list (list int)) } ; + DUP ; ITER { DROP ; DUP ; DIP { CONS } } ; + DROP ; NIL operation ; PAIR }; +|} + +let test_originate_first_explosion client () = + let expected_msg = + rex "Gas limit exceeded during typechecking or execution" + in + let* _ = Client.typecheck_script ~script:first_explosion client in + let process = + Client.spawn_originate_contract + ~alias:"first_explosion" + ~amount:Tez.zero + ~src:Constant.bootstrap1.alias + ~prg:first_explosion + ~init:"Unit" + ~burn_cap:(Tez.of_int 10) + ~gas_limit:1461 + client + in + let* () = Process.check_error ~exit_code:1 ~msg:expected_msg process in + unit + +let test_typecheck_script_big_type client () = + let expected_msg = rex "type exceeded maximum type size" in + let process = + Client.spawn_typecheck_script ~script:first_explosion_bigtype client + in + let _ = Process.check_error ~exit_code:1 ~msg:expected_msg process in + unit + +let test_run_script_second_explosion client () = + let* _storage = + Client.run_script + ~prg:second_explosion + ~storage:"{}" + ~input:"{1;2;3;4;5;6;7;8;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1}" + client + in + unit + +let test_run_script_second_explosion_fail client () = + let input = + "{1;2;3;4;5;6;7;8;9;0;1;2;3;4;5;6;7;1;1;1;1;1;1;1;1;1;1;1" + ^ ";1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1}" + in + let process = + Client.spawn_run_script + ~prg:second_explosion + ~storage:"{}" + ~gas:9290 + ~input + client + in + let msg = + rex + ("Cannot serialize the resulting storage" + ^ " value within the provided gas bounds.") + in + let _ = Process.check_error ~exit_code:1 ~msg process in + unit + +let assert_typecheck_data_failure client ~data ~typ ~msg = + let process = Client.spawn_typecheck_data ~data ~typ client in + Process.check_error ~msg process + +let test_typecheck_map_dup_key client () = + let msg = + rex + ("Map literals cannot contain duplicate" + ^ " keys, however a duplicate key was found") + in + let* _ = + assert_typecheck_data_failure + client + ~data:"{ Elt 0 1 ; Elt 0 1}" + ~typ:"(map nat nat)" + ~msg + in + unit + +let test_typecheck_map_bad_ordering client () = + let msg = + rex + ("Keys in a map literal must be in strictly" + ^ " ascending order, but they were unordered in literal") + in + let* _ = + assert_typecheck_data_failure + client + ~data:"{ Elt 0 1 ; Elt 10 1 ; Elt 5 1 }" + ~typ:"(map nat nat)" + ~msg + in + unit + +let test_typecheck_set_bad_ordering client () = + let msg = + rex + ("Values in a set literal must be in strictly" + ^ " ascending order, but they were unordered in literal") + in + let* _ = + assert_typecheck_data_failure + client + ~data:"{ \"A\" ; \"C\" ; \"B\" }" + ~typ:"(set string)" + ~msg + in + unit + +let test_typecheck_set_no_duplicates client () = + let msg = + rex + ("Set literals cannot contain duplicate values," + ^ " however a duplicate value was found") + in + let* _ = + assert_typecheck_data_failure + client + ~data:"{ \"A\" ; \"B\" ; \"B\" }" + ~typ:"(set string)" + ~msg + in + unit + +let register ~protocols = + List.iter + (fun (title, test_function) -> + Protocol.register_test + ~__FILE__ + ~title + ~tags:["client"; "michelson"; "gas_bound"] + (fun protocol -> + let* client = Client.init_mockup ~protocol () in + test_function client ()) + protocols) + [ + ("first explosion", test_originate_first_explosion); + ("first explosion big type", test_typecheck_script_big_type); + ("second explosion", test_run_script_second_explosion); + ("second explosion fail", test_run_script_second_explosion_fail); + ("typecheck map dup key", test_typecheck_map_dup_key); + ("typecheck map bad ordering", test_typecheck_map_bad_ordering); + ("typecheck set bad ordering", test_typecheck_set_bad_ordering); + ("typecheck set no duplicates", test_typecheck_set_no_duplicates); + ] diff --git a/tezt/tests/main.ml b/tezt/tests/main.ml index 24afde0a94526c1b629f37307c3efdd99a9d2079..41771483830589fcbd0ca9a18d5e921a79e6d9fd 100644 --- a/tezt/tests/main.ml +++ b/tezt/tests/main.ml @@ -114,6 +114,7 @@ let register_protocol_tests_that_use_supports_correctly () = Encoding.register ~protocols ; Events.register ~protocols ; Forge.register ~protocols ; + Gas_bound.register ~protocols ; Ghostnet_dictator_migration.register ~protocols ; Global_constants.register ~protocols ; Large_metadata.register ~protocols ;