class TestBlockchainApi(unittest.TestCase): """ Block Chain Api unit xooa_test stubs. """ def setUp(self): self.api = XooaClient() api_token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcGlLZXkiOiIwOFpKNFhTLTQ2RDRQRVQtRzlSRkZZRy1YMlkySEYzIiwiQXBpU2VjcmV0IjoiMXB5RXdhUHg1SFhLT3hWIiwiUGFzc3BocmFzZSI6IjNiMGM0OGZjZjRjN2M4MDQ4Nzg2ZjkwNmU1ZjE4OTdjIiwiaWF0IjoxNTQ2NTE1ODg3fQ.WtdIW0wVgpb6qR9L7W8ElEu9VQWNg0YlF17ML_HNdbY' self.api.set_api_token(api_token) pass def tearDown(self): pass def test_blockchain_data_sync(self): block_number = 12 get_block_by_number = self.api.get_block_by_number(block_number) self.assertEqual(type(get_block_by_number), dict) pass def test_blockchain_data_async(self): block_number = 12 get_block_by_number_async = self.api.get_block_by_number_async( block_number) self.assertEqual(type(get_block_by_number_async), dict) pass def test_blockchain_height_sync(self): get_current_block = self.api.get_current_block(timeout=3000) self.assertEqual(type(get_current_block), dict) pass def test_blockchain_height_async(self): get_current_block_async = self.api.get_current_block_async( timeout=3000) self.assertEqual(type(get_current_block_async), dict) pass def test_transaction_sync(self): fcn = 'set' args = ["args1", "args2"] invoke = self.api.invoke(fcn, args) time.sleep(2) transaction_data = self.api.get_transaction_by_transaction_id( invoke['txId']) self.assertEqual(type(transaction_data), dict) pass def test_transaction_async(self): fcn = 'set' args = ["args1", "args2"] invoke = self.api.invoke(fcn, args) time.sleep(2) transaction_async = self.api.get_transaction_by_transaction_id_async( invoke['txId']) self.assertEqual(type(transaction_async), dict) pass
print("----- Result for Block By Number Async -----") result_id = app_block_by_number_async['resultId'] app_get_result = xooa_client.get_result(result_id) print(app_get_result) print() # To get blockchain height asynchronously call get_current_block_async method print("----- Current Block Async -----") app_current_block_async = xooa_client.get_current_block_async() print(app_current_block_async) print() # To get blockchain height call get_current_block method # timeout is an optional keyword argument print("----- Current Block -----") app_current_block = xooa_client.get_current_block(timeout=3000) print(app_current_block) print() # To check whether the transaction has been completed or not, call get_result method # result_id is required argument print("----- Result for Current Block Async -----") result_id = app_current_block_async['resultId'] app_get_result = xooa_client.get_result(result_id) print(app_get_result) print() # To get blockchain height asynchronously call get_current_block_async method print("----- Get Transaction Async -----") app_transaction_async = xooa_client.get_transaction_by_transaction_id_async( app_invoke['txId'])