def test_opcode_get_big_map_value_0(self): res = self.i.execute( f'INCLUDE "{abspath("opcodes/contracts/get_big_map_value.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN "hello" (Pair { Elt "hello" "hi" } None)') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('(Pair 0 (Some "hi"))') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val) big_map_diff = [{ 'action': 'alloc', 'big_map': '0', 'key_type': { 'prim': 'string' }, 'value_type': { 'prim': 'string' } }, { 'action': 'update', 'big_map': '0', 'key_hash': 'exprtsjEVVZk3Gm82U9wEs8kvwRiQwUT7zipJwvCeFMNsApe2tQ15s', 'key': { 'string': 'hello' }, 'value': { 'string': 'hi' } }] self.assertCountEqual(big_map_diff, res['result']['big_map_diff'])
def test_opcode_update_big_map_5(self): res = self.i.execute( f'INCLUDE "{abspath("opcodes/contracts/update_big_map.tz")}"') self.assertTrue(res['success']) res = self.i.execute( 'RUN { Elt "3" (Some "three") } (Pair { Elt "1" "one" ; Elt "2" "two" } Unit)' ) self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('(Pair 0 Unit)') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val) big_map_diff = [{ 'action': 'alloc', 'big_map': '0', 'key_type': { 'prim': 'string' }, 'value_type': { 'prim': 'string' } }, { 'action': 'update', 'big_map': '0', 'key_hash': 'exprvHK69NiDmfXXw2Gx5x9meBfRp3CBMZ1QjM3UdqoNfUzK3nSpnL', 'key': { 'string': '1' }, 'value': { 'string': 'one' } }, { 'action': 'update', 'big_map': '0', 'key_hash': 'exprtaPfHX9A3HW7vujsuarwHDXwJYu9hJZvuqUCyoeHLRLPXyDQjW', 'key': { 'string': '2' }, 'value': { 'string': 'two' } }, { 'action': 'update', 'big_map': '0', 'key_hash': 'exprtzN2y9qBiaf7A14AbS1SveJWXpMdJQztXFgiGzG5yu43tem2he', 'key': { 'string': '3' }, 'value': { 'string': 'three' } }] self.assertCountEqual(big_map_diff, res['result']['big_map_diff'])
def test_opcode_big_map_magic_12(self): res = self.i.execute( f'INCLUDE "{abspath("opcodes/contracts/big_map_magic.tz")}"') self.assertTrue(res['success']) res = self.i.execute( 'RUN (Right (Right (Left (Pair { Pair "foo" "bar" } { Pair "gaz" "baz" }) ))) (Right Unit)' ) self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('(Left (Pair 0 1))') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val) big_map_diff = [{ 'action': 'alloc', 'big_map': '1', 'key_type': { 'prim': 'string' }, 'value_type': { 'prim': 'string' } }, { 'action': 'update', 'big_map': '1', 'key_hash': 'exprtft4mfpxnyufwZf17PQxf57VAyrwNM5mNwqCMkVRTfb5pALQpz', 'key': { 'string': 'gaz' }, 'value': { 'string': 'baz' } }, { 'action': 'alloc', 'big_map': '0', 'key_type': { 'prim': 'string' }, 'value_type': { 'prim': 'string' } }, { 'action': 'update', 'big_map': '0', 'key_hash': 'expruTFUPVsqkuD5iwLMJuzoyGSFABnxLo7CZrgnS1czt1WbTwpVrJ', 'key': { 'string': 'foo' }, 'value': { 'string': 'bar' } }] self.assertCountEqual(big_map_diff, res['result']['big_map_diff'])
def test_opcode_big_map_magic_10(self): res = self.i.execute( f'INCLUDE "{abspath("opcodes/contracts/big_map_magic.tz")}"') self.assertTrue(res['success']) res = self.i.execute( 'RUN (Right (Left (Left (Pair { Elt "3" "three" } { Elt "4" "four" })))) (Left (Pair { Elt "1" "one" } { Elt "2" "two" }))' ) self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('(Left (Pair 0 1))') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val) big_map_diff = [{ 'action': 'alloc', 'big_map': '1', 'key_type': { 'prim': 'string' }, 'value_type': { 'prim': 'string' } }, { 'action': 'update', 'big_map': '1', 'key_hash': 'exprttiwE7dpYJ8Xjp28uMZzcC3Bwh4xAEF7GT7FutVwVoskMZYExx', 'key': { 'string': '4' }, 'value': { 'string': 'four' } }, { 'action': 'alloc', 'big_map': '0', 'key_type': { 'prim': 'string' }, 'value_type': { 'prim': 'string' } }, { 'action': 'update', 'big_map': '0', 'key_hash': 'exprtzN2y9qBiaf7A14AbS1SveJWXpMdJQztXFgiGzG5yu43tem2he', 'key': { 'string': '3' }, 'value': { 'string': 'three' } }] self.assertCountEqual(big_map_diff, res['result']['big_map_diff'])
def test_opcode_left_right_177(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/left_right.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN (Left True) (Left "X")') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('(Right True)') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_and_logical_1_46(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/and_logical_1.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN (Pair True False) False') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('False') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_list_map_block_6(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/list_map_block.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN { 1 ; 1 ; 1 ; 1 } {0}') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('{ 1 ; 2 ; 3 ; 4 }') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_xor_69(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/xor.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN (Right (Pair 1 0)) None') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('(Some (Right 1))') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_ret_int_4(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/ret_int.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN Unit None') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('(Some 300)') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_list_size_143(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/list_size.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN { 1 } 111') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('1') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_contract_239(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/contract.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN "tz1cxcwwnzENRdhe2Kb8ZdTrdNy4bFNyScx5" Unit') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('Unit') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_slice_15(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/slice.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN (Pair 10 5) (Some "Foo")') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('None') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_dipn_250(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/dipn.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN (Pair (Pair (Pair (Pair 1 2) 3) 4) 5) 0') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('6') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_str_id_12(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/str_id.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN "Hello" None') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('(Some "Hello")') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_dig_eq_251(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/dig_eq.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN (Pair 17 (Pair 16 (Pair 15 (Pair 14 (Pair 13 (Pair 12 (Pair 11 (Pair 10 (Pair 9 (Pair 8 (Pair 7 (Pair 6 (Pair 5 (Pair 4 (Pair 3 (Pair 2 1)))))))))))))))) Unit') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('Unit') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_macro_compare_271(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/macro_compare.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN (Pair 2370000 2370000) {}') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('{ True ; False ; False ; True ; True }') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_concat_hello_168(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/concat_hello.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN { "test1" ; "test2" } {}') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('{ "Hello test1" ; "Hello test2" }') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_map_mem_nat_100(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/map_mem_nat.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN 1 (Pair { Elt 1 0 } None)') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('(Pair { Elt 1 0 } (Some True))') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_or_binary_52(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/or_binary.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN (Pair 15 4) None') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('(Some 15)') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_add_delta_timestamp_213(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/add_delta_timestamp.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN (Pair -100 100) None') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('(Some "1970-01-01T00:00:00Z")') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_abs_187(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/abs.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN 12039123919239192312931 Unit') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('Unit') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_map_id_96(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/map_id.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN { Elt 0 0 } {}') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('{ Elt 0 0 }') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_assert_cmple_285(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/assert_cmple.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN (Pair -1 0) Unit') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('Unit') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_contains_all_160(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/contains_all.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN (Pair {} {}) None') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('(Some True)') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_big_map_mem_string_120(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/big_map_mem_string.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN "bar" (Pair {} None)') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('(Pair 0 (Some False))') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_self_with_default_entrypoint_257(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/self_with_default_entrypoint.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN Unit Unit') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('Unit') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_max_in_list_268(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/max_in_list.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN { -10 ; -1 ; -20 ; -100 } None') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('(Some -1)') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_set_car_203(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/set_car.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN "" (Pair "hello" 0)') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('(Pair "" 0)') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_list_concat_134(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/list_concat.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN { "d" ; "e" ; "f" } "abc"') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('"abcdef"') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)
def test_opcode_map_caddaadr_291(self): res = self.i.execute(f'INCLUDE "{abspath("opcodes/contracts/map_caddaadr.tz")}"') self.assertTrue(res['success']) res = self.i.execute('RUN Unit (Pair (Pair 1 (Pair 2 (Pair (Pair (Pair 3 0) 4) 5))) 6)') self.assertTrue(res['success']) exp_val_expr = michelson_to_micheline('(Pair (Pair 1 (Pair 2 (Pair (Pair (Pair 3 1000000) 4) 5))) 6)') exp_val = parse_expression(exp_val_expr, res['result']['storage'].type_expr) self.assertEqual(exp_val, res['result']['storage']._val)