Ejemplo n.º 1
0
 async def test_query_allowance(self):
     ont = sdk.native_vm.aio_ont()
     if sys.version_info >= (3, 7):
         task_list = [
             asyncio.create_task(
                 ont.allowance(acct1.get_address_base58(),
                               acct2.get_address_base58())),
             asyncio.create_task(
                 ont.allowance(acct2.get_address_base58(),
                               acct3.get_address_base58())),
             asyncio.create_task(
                 ont.allowance(acct3.get_address_base58(),
                               acct4.get_address_base58())),
             asyncio.create_task(
                 ont.allowance(acct4.get_address_base58(),
                               acct1.get_address_base58()))
         ]
     else:
         task_list = [
             ont.allowance(acct1.get_address_base58(),
                           acct2.get_address_base58()),
             ont.allowance(acct2.get_address_base58(),
                           acct3.get_address_base58()),
             ont.allowance(acct3.get_address_base58(),
                           acct4.get_address_base58()),
             ont.allowance(acct4.get_address_base58(),
                           acct1.get_address_base58())
         ]
     for task in task_list:
         self.assertGreaterEqual(await task, 0)
Ejemplo n.º 2
0
 def test_transfer_multi_args_0(self):
     transfer_1 = [
         acct1.get_address().to_bytes(),
         acct2.get_address().to_bytes(), 10
     ]
     transfer_2 = [
         acct2.get_address().to_bytes(),
         acct3.get_address().to_bytes(), 100
     ]
     transfer_list = [transfer_1, transfer_2]
     hex_contract_address = 'ca91a73433c016fbcbcf98051d385785a6a5d9be'
     func = InvokeFunction('transfer_multi')
     func.set_params_value(transfer_list)
     tx_hash = sdk.rpc.send_neo_vm_transaction(hex_contract_address, acct1,
                                               acct2, self.gas_price,
                                               self.gas_limit, func, False)
     self.assertEqual(64, len(tx_hash))
     time.sleep(randint(10, 15))
     event = sdk.rpc.get_contract_event_by_tx_hash(tx_hash)
     states = Event.get_states_by_contract_address(event,
                                                   hex_contract_address)
     states[0] = Data.to_utf8_str(states[0])
     states[1][0][0] = Data.to_b58_address(states[1][0][0])
     self.assertEqual(acct1.get_address_base58(), states[1][0][0])
     states[1][0][1] = Data.to_b58_address(states[1][0][1])
     self.assertEqual(acct2.get_address_base58(), states[1][0][1])
     states[1][0][2] = Data.to_int(states[1][0][2])
     self.assertEqual(10, states[1][0][2])
     states[1][1][0] = Data.to_b58_address(states[1][1][0])
     self.assertEqual(acct2.get_address_base58(), states[1][1][0])
     states[1][1][1] = Data.to_b58_address(states[1][1][1])
     self.assertEqual(acct3.get_address_base58(), states[1][1][1])
     states[1][1][2] = Data.to_int(states[1][1][2])
     self.assertEqual(100, states[1][1][2])
Ejemplo n.º 3
0
    async def test_transfer_multi(self):
        oep4 = sdk.neo_vm.aio_oep4()
        oep4.hex_contract_address = contract_address
        transfer_list = list()

        b58_from_address1 = acct1.get_address_base58()
        b58_from_address2 = acct2.get_address_base58()
        from_address_list = [b58_from_address1, b58_from_address2]

        b58_to_address1 = acct2.get_address_base58()
        b58_to_address2 = acct3.get_address_base58()
        to_address_list = [b58_to_address1, b58_to_address2]

        value_list = [1, 2]

        transfer1 = [b58_from_address1, b58_to_address1, value_list[0]]
        transfer2 = [b58_from_address2, b58_to_address2, value_list[1]]

        signers = [acct1, acct2, acct3]
        transfer_list.append(transfer1)
        transfer_list.append(transfer2)

        tx_hash = await oep4.transfer_multi(transfer_list, signers, acct1, 500, 20000000)
        self.assertEqual(64, len(tx_hash))
        await asyncio.sleep(randint(14, 20))
        notify_list = await oep4.query_multi_transfer_event(tx_hash)
        self.assertEqual(len(transfer_list), len(notify_list))
        for index, notify in enumerate(notify_list):
            self.assertEqual('transfer', notify['States'][0])
            self.assertEqual(from_address_list[index], notify['States'][1])
            self.assertEqual(to_address_list[index], notify['States'][2])
            self.assertEqual(value_list[index], notify['States'][3])
Ejemplo n.º 4
0
 async def test_transfer_from_tx(self):
     acct2_b58_address = acct2.get_address_base58()
     tx_hash = await sdk.native_vm.aio_ont().transfer_from(acct2, acct1.get_address(), acct2_b58_address, 1, acct2,
                                                           self.gas_price, self.gas_limit)
     self.assertEqual(64, len(tx_hash))
     await asyncio.sleep(randint(14, 20))
     event = await sdk.aio_rpc.get_contract_event_by_tx_hash(tx_hash)
     notify = Event.get_notify_by_contract_address(event, sdk.native_vm.aio_ont().contract_address)
     self.assertEqual('transfer', notify['States'][0])
     self.assertEqual(acct1.get_address_base58(), notify['States'][1])
     self.assertEqual(acct2.get_address_base58(), notify['States'][2])
     self.assertEqual(1, notify['States'][3])
Ejemplo n.º 5
0
 def test_send_raw_transaction(self):
     b58_from_address = acct2.get_address_base58()
     b58_to_address = 'AW352JufVwuZReSt7SCQpbYqrWeuERUNJr'
     tx = sdk.native_vm.ong().new_transfer_tx(b58_from_address, b58_to_address, 1, b58_from_address, 500, 20000)
     tx.sign_transaction(acct2)
     tx_hash = sdk.rpc.send_raw_transaction(tx)
     self.assertEqual(tx_hash, tx.hash256_explorer())
Ejemplo n.º 6
0
 async def test_balance_of(self):
     address_list = [acct1.get_address_base58(), acct2.get_address_base58(), acct3.get_address_base58(),
                     acct4.get_address_base58()]
     for address in address_list:
         balance = await sdk.native_vm.aio_ont().balance_of(address)
         self.assertTrue(isinstance(balance, int))
         self.assertGreaterEqual(balance, 0)
Ejemplo n.º 7
0
 async def test_transfer_from(self):
     sdk.rpc.connect_to_test_net()
     b58_from_address = acct1.get_address_base58()
     b58_recv_address = acct2.get_address_base58()
     ont = sdk.native_vm.aio_ont()
     amount = 1
     tx_hash = await ont.transfer_from(acct2, b58_from_address,
                                       b58_recv_address, amount, acct2,
                                       self.gas_price, self.gas_limit)
     self.assertEqual(64, len(tx_hash))
     await asyncio.sleep(randint(10, 15))
     event = await sdk.aio_rpc.get_contract_event_by_tx_hash(tx_hash)
     notify = Event.get_notify_by_contract_address(
         event,
         sdk.native_vm.ong().contract_address)
     self.assertEqual('transfer', notify['States'][0])
     self.assertEqual(b58_recv_address, notify['States'][1])
     self.assertEqual(self.gas_price * self.gas_limit, notify['States'][3])
     notify = Event.get_notify_by_contract_address(
         event,
         sdk.native_vm.ont().contract_address)
     self.assertEqual('transfer', notify['States'][0])
     self.assertEqual(b58_from_address, notify['States'][1])
     self.assertEqual(b58_recv_address, notify['States'][2])
     self.assertEqual(amount, notify['States'][3])
Ejemplo n.º 8
0
 async def test_subscribe(self):
     hex_contract_address = '1ddbb682743e9d9e2b71ff419e97a9358c5c4ee9'
     oep4 = sdk.neo_vm.aio_oep4(hex_contract_address)
     response = await sdk.websocket.subscribe(hex_contract_address, True, False, False, False)
     self.assertEqual([hex_contract_address], response['ContractsFilter'])
     self.assertEqual(True, response['SubscribeEvent'])
     self.assertEqual(False, response['SubscribeJsonBlock'])
     self.assertEqual(False, response['SubscribeRawBlock'])
     b58_to_address = acct2.get_address_base58()
     value = 10
     tx_hash = await oep4.transfer(acct1, b58_to_address, value, acct3, 500, 20000)
     self.assertEqual(64, len(tx_hash))
     try:
         event = await asyncio.wait_for(sdk.websocket.recv_subscribe_info(), timeout=10)
         self.assertEqual(False, response['SubscribeBlockTxHashs'])
         self.assertEqual(64, len(event['TxHash']))
         notify = Event.get_notify_by_contract_address(event, hex_contract_address)
         notify = NeoData.parse_addr_addr_int_notify(notify)
         self.assertEqual(hex_contract_address, notify['ContractAddress'])
         self.assertEqual('transfer', notify['States'][0])
         self.assertEqual(acct1.get_address_base58(), notify['States'][1])
         self.assertEqual(b58_to_address, notify['States'][2])
         self.assertEqual(value, notify['States'][3])
     except asyncio.TimeoutError:
         pass
     finally:
         await sdk.websocket.close_connect()
Ejemplo n.º 9
0
 def setUp(self):
     pub_keys = [acct1.get_public_key_bytes(), acct2.get_public_key_bytes(), acct3.get_public_key_bytes()]
     multi_address = Address.from_multi_pub_keys(2, pub_keys)
     self.address_list = [acct1.get_address_base58(), acct2.get_address_base58(), acct3.get_address_base58(),
                          acct4.get_address_base58(), multi_address.b58encode()]
     self.gas_price = 500
     self.gas_limit = 20000
Ejemplo n.º 10
0
 def test_tx_signature(self):
     b58_from_address = acct1.get_address_base58()
     b58_to_address = acct2.get_address_base58()
     tx = sdk.native_vm.ont().new_transfer_tx(b58_from_address, b58_to_address, 10, b58_from_address, 0, 20000)
     tx.sign_transaction(acct1)
     self.assertTrue(acct1.verify_signature(tx.hash256(), tx.sig_list[0].sig_data[0]))
     self.assertFalse(acct2.verify_signature(tx.hash256(), tx.sig_list[0].sig_data[0]))
     tx.add_sign_transaction(acct2)
     self.assertTrue(acct2.verify_signature(tx.hash256(), tx.sig_list[1].sig_data[0]))
Ejemplo n.º 11
0
 async def test_unbound_ong(self):
     address_list = [
         acct1.get_address_base58(),
         acct2.get_address_base58(),
         acct3.get_address_base58(),
         acct4.get_address_base58()
     ]
     for address in address_list:
         unbound_ong = await sdk.native_vm.aio_ong().unbound(address)
         self.assertGreaterEqual(unbound_ong, 0)
Ejemplo n.º 12
0
 def test_deploy_contract(self):
     for index, file in enumerate(self.wasm_file_list):
         code = self.get_contract_code(file)
         tx = sdk.wasm_vm.make_deploy_transaction(code, self.name, self.code_version, self.author, self.email,
                                                  self.desc, self.gas_price, self.gas_limit,
                                                  acct2.get_address_base58())
         tx.sign_transaction(acct2)
         sdk.rpc.connect_to_localhost()
         result = sdk.rpc.send_raw_transaction_pre_exec(tx)
         self.assertEqual(1, result['State'])
Ejemplo n.º 13
0
 async def test_get_balance(self):
     pub_keys = [acct1.get_public_key_bytes(), acct2.get_public_key_bytes(), acct3.get_public_key_bytes()]
     multi_address = Address.from_multi_pub_keys(2, pub_keys)
     address_list = [acct1.get_address_base58(), acct2.get_address_base58(), acct3.get_address_base58(),
                     acct4.get_address_base58(), multi_address.b58encode()]
     for address in address_list:
         balance = await sdk.websocket.get_balance(address)
         self.assertTrue(isinstance(balance, dict))
         self.assertGreaterEqual(balance['ONT'], 0)
         self.assertGreaterEqual(balance['ONG'], 0)
Ejemplo n.º 14
0
 def test_native_vm_transaction(self):
     amount = 1
     tx = sdk.native_vm.ont().new_transfer_tx(acct2.get_address_base58(),
                                              acct1.get_address_base58(),
                                              amount,
                                              acct1.get_address_base58(),
                                              500, 20000)
     tx.sign_transaction(acct1)
     tx.add_sign_transaction(acct2)
     tx_hash = sdk.rpc.send_raw_transaction(tx)
     self.assertEqual(64, len(tx_hash))
     tx = sdk.native_vm.ont().new_transfer_tx(acct1.get_address_base58(),
                                              acct2.get_address_base58(),
                                              amount,
                                              acct1.get_address_base58(),
                                              500, 20000)
     tx.sign_transaction(acct2)
     tx.add_sign_transaction(acct1)
     tx_hash = sdk.rpc.send_raw_transaction(tx)
     self.assertEqual(64, len(tx_hash))
Ejemplo n.º 15
0
 async def test_send_raw_transaction_pre_exec(self):
     random_pk = get_random_hex_str(64)
     random_acct = Account(random_pk)
     b58_from_address = acct2.get_address_base58()
     rand_to_address = random_acct.get_address_base58()
     tx = sdk.native_vm.ong().new_transfer_tx(b58_from_address, rand_to_address, 2, b58_from_address, 500, 20000)
     tx.sign_transaction(acct2)
     result = await sdk.aio_rpc.send_raw_transaction_pre_exec(tx)
     self.assertEqual(result['Result'], '01')
     self.assertEqual(result['Gas'], 20000)
     self.assertEqual(result['State'], 1)
Ejemplo n.º 16
0
 def test_make_deploy_transaction(self):
     code = '54c56b6c766b00527ac46c766b51527ac4616c766b00c36c766b52527ac46c766b52c30548656c6c6f87630600621a' \
            '006c766b51c300c36165230061516c766b53527ac4620e00006c766b53527ac46203006c766b53c3616c756651c56b' \
            '6c766b00527ac46151c576006c766b00c3c461681553797374656d2e52756e74696d652e4e6f7469667961616c7566'
     tx = sdk.neo_vm.make_deploy_transaction(code, 'name', '1.0.0',
                                             'author', 'email',
                                             'description', 500, 20000000,
                                             acct2.get_address_base58())
     tx.sign_transaction(acct2)
     result = sdk.rpc.send_raw_transaction_pre_exec(tx)
     self.assertEqual(1, result['State'])
Ejemplo n.º 17
0
 async def test_transfer_from_tx(self):
     acct2_b58_address = acct2.get_address_base58()
     tx_hash = await sdk.native_vm.aio_ong().transfer_from(
         acct2, acct1.get_address(), acct2_b58_address, 1, acct2, 500,
         20000)
     self.assertEqual(64, len(tx_hash))
     await asyncio.sleep(randint(14, 20))
     event = await sdk.aio_rpc.get_contract_event_by_tx_hash(tx_hash)
     notify_list = Event.get_notify_by_contract_address(
         event,
         sdk.native_vm.aio_ong().contract_address)
     self.assertEqual(2, len(notify_list))
Ejemplo n.º 18
0
 def test_transfer_from(self):
     sdk.rpc.connect_to_test_net()
     b58_from_address = acct1.get_address_base58()
     b58_recv_address = acct2.get_address_base58()
     ong = sdk.native_vm.ong()
     tx_hash = ong.transfer_from(acct2, b58_from_address, b58_recv_address,
                                 1, acct2, self.gas_price, self.gas_limit)
     self.assertEqual(64, len(tx_hash))
     time.sleep(randint(14, 20))
     event = sdk.default_network.get_contract_event_by_tx_hash(tx_hash)
     notify = Event.get_notify_by_contract_address(event,
                                                   ong.contract_address)
     self.assertEqual(2, len(notify))
Ejemplo n.º 19
0
 def test_transfer_from_tx(self):
     acct2_b58_address = acct2.get_address_base58()
     tx_hash = sdk.native_vm.ong().transfer_from(acct2, acct1.get_address(),
                                                 acct2_b58_address, 1,
                                                 acct2, self.gas_price,
                                                 self.gas_limit)
     self.assertEqual(64, len(tx_hash))
     time.sleep(randint(14, 20))
     event = sdk.default_network.get_contract_event_by_tx_hash(tx_hash)
     notify_list = Event.get_notify_by_contract_address(
         event,
         sdk.native_vm.ong().contract_address)
     self.assertEqual(2, len(notify_list))
Ejemplo n.º 20
0
 async def test_transfer(self):
     oep4 = sdk.neo_vm.aio_oep4()
     oep4.hex_contract_address = contract_address
     from_acct = acct1
     b58_to_address = acct2.get_address_base58()
     value = 10
     tx_hash = await oep4.transfer(from_acct, b58_to_address, value, from_acct, 500, 20000000)
     self.assertEqual(64, len(tx_hash))
     await asyncio.sleep(randint(14, 20))
     notify = await oep4.query_transfer_event(tx_hash)
     self.assertEqual('transfer', notify['States'][0])
     self.assertEqual(from_acct.get_address_base58(), notify['States'][1])
     self.assertEqual(b58_to_address, notify['States'][2])
     self.assertEqual(value, notify['States'][3])
Ejemplo n.º 21
0
 async def test_transfer_from(self):
     sdk.rpc.connect_to_test_net()
     b58_from_address = acct1.get_address_base58()
     b58_recv_address = acct2.get_address_base58()
     ong = sdk.native_vm.aio_ong()
     tx_hash = await ong.transfer_from(acct2, b58_from_address,
                                       b58_recv_address, 1, acct2, 500,
                                       20000)
     self.assertEqual(64, len(tx_hash))
     await asyncio.sleep(randint(14, 20))
     event = await sdk.aio_rpc.get_contract_event_by_tx_hash(tx_hash)
     notify = Event.get_notify_by_contract_address(event,
                                                   ong.contract_address)
     self.assertEqual(2, len(notify))
Ejemplo n.º 22
0
 async def test_approve(self):
     oep4 = sdk.neo_vm.aio_oep4()
     oep4.hex_contract_address = contract_address
     b58_spender_address = acct2.get_address_base58()
     amount = 10
     tx_hash = await oep4.approve(acct1, b58_spender_address, amount, acct1, 500, 20000000)
     self.assertEqual(len(tx_hash), 64)
     await asyncio.sleep(randint(14, 20))
     event = await oep4.query_approve_event(tx_hash)
     self.assertEqual(contract_address, event.get('ContractAddress', ''))
     states = event['States']
     self.assertEqual('approval', states[0])
     self.assertEqual(acct1.get_address_base58(), states[1])
     self.assertEqual(b58_spender_address, states[2])
     self.assertEqual(amount, states[3])
Ejemplo n.º 23
0
 def test_transfer(self):
     oep4 = sdk.neo_vm.oep4()
     oep4.hex_contract_address = self.contract_address
     from_acct = acct1
     b58_to_address = acct2.get_address_base58()
     value = 10
     tx_hash = oep4.transfer(from_acct, b58_to_address, value, from_acct,
                             self.gas_price, self.gas_limit)
     self.assertEqual(64, len(tx_hash))
     time.sleep(randint(10, 15))
     notify = oep4.query_transfer_event(tx_hash)
     self.assertEqual('transfer', notify['States'][0])
     self.assertEqual(from_acct.get_address_base58(), notify['States'][1])
     self.assertEqual(b58_to_address, notify['States'][2])
     self.assertEqual(value, notify['States'][3])
Ejemplo n.º 24
0
 async def test_transfer(self):
     amount = 1
     ont = sdk.native_vm.aio_ont()
     tx_hash = await ont.transfer(acct2, acct1.get_address(), amount, acct4, self.gas_price, self.gas_limit)
     await asyncio.sleep(randint(14, 20))
     event = await sdk.aio_rpc.get_contract_event_by_tx_hash(tx_hash)
     notify = Event.get_notify_by_contract_address(event, ont.contract_address)
     self.assertEqual('transfer', notify['States'][0])
     self.assertEqual(acct2.get_address_base58(), notify['States'][1])
     self.assertEqual(acct1.get_address_base58(), notify['States'][2])
     self.assertEqual(amount, notify['States'][3])
     notify = Event.get_notify_by_contract_address(event, sdk.native_vm.aio_ong().contract_address)
     self.assertEqual('transfer', notify['States'][0])
     self.assertEqual(acct4.get_address_base58(), notify['States'][1])
     self.assertEqual(self.gas_price * self.gas_limit, notify['States'][3])
Ejemplo n.º 25
0
 def test_new_registry_ont_id_transaction(self):
     ont_id = sdk.native_vm.ont_id()
     hex_public_key = acct2.get_public_key_hex()
     b58_address = acct2.get_address_base58()
     acct_did = DID_ONT + b58_address
     tx = ont_id.new_registry_ont_id_tx(acct_did, hex_public_key,
                                        b58_address, self.gas_price,
                                        self.gas_limit)
     tx.sign_transaction(acct2)
     self.assertEqual(64, len(tx.hash256(is_hex=True)))
     self.assertEqual(598, len(tx.serialize(is_hex=True)))
     try:
         sdk.rpc.send_raw_transaction(tx)
     except SDKException as e:
         self.assertEqual(59000, e.args[0])
         self.assertIn('already registered', e.args[1])
Ejemplo n.º 26
0
 def test_transfer_from(self):
     b58_from_address = acct2.get_address_base58()
     b58_recv_address = acct1.get_address_base58()
     ont = sdk.native_vm.ont()
     amount = 1
     tx_hash = ont.transfer_from(acct1, b58_from_address, b58_recv_address, amount, acct2, self.gas_price,
                                 self.gas_limit)
     self.assertEqual(64, len(tx_hash))
     time.sleep(randint(10, 15))
     event = sdk.default_network.get_contract_event_by_tx_hash(tx_hash)
     notify = Event.get_notify_by_contract_address(event, sdk.native_vm.ong().contract_address)
     self.assertEqual('transfer', notify['States'][0])
     self.assertEqual(b58_from_address, notify['States'][1])
     self.assertEqual(self.gas_price * self.gas_limit, notify['States'][3])
     notify = Event.get_notify_by_contract_address(event, sdk.native_vm.ont().contract_address)
     self.assertEqual('transfer', notify['States'][0])
     self.assertEqual(b58_from_address, notify['States'][1])
     self.assertEqual(b58_recv_address, notify['States'][2])
     self.assertEqual(amount, notify['States'][3])
Ejemplo n.º 27
0
 def test_transfer(self):
     amount = 1
     gas = sdk.native_vm.gas()
     tx_hash = gas.transfer(acct1, acct2.get_address(), amount, acct4,
                            self.gas_price, self.gas_limit)
     time.sleep(randint(14, 20))
     event = sdk.default_network.get_contract_event_by_tx_hash(tx_hash)
     notify = Event.get_notify_by_contract_address(event,
                                                   gas.contract_address)
     self.assertEqual('transfer', notify['States'][0])
     self.assertEqual(acct1.get_address_base58(), notify['States'][1])
     self.assertEqual(acct2.get_address_base58(), notify['States'][2])
     self.assertEqual(amount, notify['States'][3])
     notify = Event.get_notify_by_contract_address(
         event,
         sdk.native_vm.aio_ong().contract_address)
     self.assertEqual('transfer', notify['States'][0])
     self.assertEqual(acct4.get_address_base58(), notify['States'][1])
     self.assertEqual(self.gas_price * self.gas_limit, notify['States'][3])
Ejemplo n.º 28
0
 async def test_withdraw_ong(self):
     amount, gas_price, gas_limit = 1, 500, 20000
     tx_hash = await sdk.native_vm.aio_ong().withdraw(
         acct1, acct1.get_address(), amount, acct2, gas_price, gas_limit)
     self.assertEqual(64, len(tx_hash))
     await asyncio.sleep(randint(14, 20))
     event = await sdk.aio_rpc.get_contract_event_by_tx_hash(tx_hash)
     notify = Event.get_notify_by_contract_address(
         event,
         sdk.native_vm.aio_ong().contract_address)
     self.assertEqual('transfer', notify[0]['States'][0])
     self.assertEqual(acct1.get_address_base58(), notify[0]['States'][2])
     self.assertEqual(amount, notify[0]['States'][3])
     notify = Event.get_notify_by_contract_address(
         event,
         sdk.native_vm.aio_ong().contract_address)
     self.assertEqual('transfer', notify[1]['States'][0])
     self.assertEqual(acct2.get_address_base58(), notify[1]['States'][1])
     self.assertEqual(gas_price * gas_limit, notify[1]['States'][3])
Ejemplo n.º 29
0
 def test_new_remove_attribute_transaction(self):
     did = sdk.native_vm.did()
     hex_public_key = acct2.get_public_key_hex()
     b58_address = acct2.get_address_base58()
     acct_did = "did:dna:" + b58_address
     path = 'try'
     tx = did.new_remove_attribute_tx(acct_did, hex_public_key, path, b58_address, self.gas_price, self.gas_limit)
     tx.sign_transaction(acct2)
     try:
         tx_hash = sdk.rpc.send_raw_transaction(tx)
         self.assertEqual(tx.hash256_explorer(), tx_hash)
         time.sleep(randint(10, 15))
         notify = sdk.rpc.get_contract_event_by_tx_hash(tx_hash)['Notify']
         self.assertEqual('Attribute', notify[0]['States'][0])
         self.assertEqual('remove', notify[0]['States'][1])
         self.assertEqual(acct_did, notify[0]['States'][2])
         self.assertEqual('try', bytes.fromhex(notify[0]['States'][3]).decode())
     except SDKException as e:
         self.assertEqual(59000, e.args[0])
         self.assertIn('attribute not exist', e.args[1])
Ejemplo n.º 30
0
 async def test_send_raw_transaction(self):
     b58_from_address = acct1.get_address_base58()
     b58_to_address = acct2.get_address_base58()
     tx = sdk.native_vm.ong().new_transfer_tx(b58_from_address, b58_to_address, 1, b58_from_address, 500, 20000)
     tx.sign_transaction(acct1)
     tx_hash = await sdk.websocket.send_raw_transaction(tx)
     self.assertEqual(64, len(tx_hash))
     await asyncio.sleep(6)
     event = dict()
     for _ in range(0, 10):
         event = await sdk.websocket.get_contract_event_by_tx_hash(tx_hash)
         if isinstance(event, dict) and event.get('TxHash', '') == tx_hash:
             break
         await asyncio.sleep(2)
     await sdk.websocket.close_connect()
     self.assertTrue(isinstance(event, dict))
     self.assertEqual(tx_hash, event['TxHash'])
     self.assertEqual(1, event['State'])
     self.assertEqual('0200000000000000000000000000000000000000', event['Notify'][0]['ContractAddress'])
     self.assertEqual('0200000000000000000000000000000000000000', event['Notify'][1]['ContractAddress'])