def test_transfer_tx(self): amount = 100 func = WasmInvokeFunction('transfer') func.set_params_value( acct1.get_address(), Address.b58decode('AazEvfQPcQ2GEFFPLF1ZLwQ7K5jDn81hve'), amount) tx = sdk.wasm_vm.make_invoke_transaction(self.oep4_contract_address, func, acct2.get_address(), self.gas_price, self.gas_limit) target_payload = '0faeff23255536928b308e5caa38bc2dc14f30c341087472616e7366657246b1a18af6b7c9f8a4602f9f73' \ 'eeb3030f0c29b7d2c124dd088190f709b684e0bc676d70c41b377664000000000000000000000000000000' self.assertEqual(target_payload, tx.payload.hex()) tx.sign_transaction(acct1, acct2) result = sdk.rpc.send_raw_transaction_pre_exec(tx) self.assertEqual('01', result.get('Result')) self.assertEqual(1, result.get('State')) notify_list = Event.get_event_from_event_list_by_contract_address( result.get('Notify'), self.oep4_contract_address) self.assertEqual(self.oep4_contract_address, notify_list[0].get('ContractAddress')) states = notify_list[1].get('States') self.assertEqual('transfer', WasmData.to_utf8(states[0])) self.assertEqual(acct1.get_address().b58encode(), WasmData.to_b58_address(states[1])) self.assertEqual('AazEvfQPcQ2GEFFPLF1ZLwQ7K5jDn81hve', WasmData.to_b58_address(states[2])) self.assertEqual(amount, WasmData.to_int(states[3]))
def test_put_one_item(self): ipfs_address = 'QmVwRs3tMPwi8vHqZXfxdgbcJXdmrgViGiy77o9ohef6ss' ext = '.jpg' aes_iv, encode_g_tilde, encrypted_ipfs_address = ECIES.encrypt_with_cbc_mode(ipfs_address.encode('ascii'), self.ont_id_ctrl_acct.get_public_key_bytes()) put_one_item_func = WasmInvokeFunction('put_one_item') put_one_item_func.set_params_value(self.ont_id_ctrl_acct.get_address(), ipfs_address, ext, aes_iv.hex(), encode_g_tilde.hex()) tx = self.sdk.wasm_vm.make_invoke_transaction(self.contract_address, put_one_item_func, self.ont_id_ctrl_acct.get_address(), self.gas_price, self.gas_limit) tx.sign_transaction(self.ont_id_ctrl_acct) tx_hash = self.sdk.rpc.send_raw_transaction(tx) self.assertEqual(64, len(tx_hash)) time.sleep(12) event = self.sdk.rpc.get_contract_event_by_tx_hash(tx_hash) states = Event.get_event_from_event_list_by_contract_address(event['Notify'], self.contract_address) self.assertEqual(1, len(states))