Ejemplo n.º 1
0
 def test_get_out_transaction_history(self):
     """
     Checks get_out_transaction_history() works as expected.
     """
     address = ADDRESS
     m_transactions = M_TRANSACTIONS
     with patch_requests_get() as m_get:
         m_get.return_value.status_code = http.HTTPStatus.OK
         m_get.return_value.json.return_value = {
             'status': '1',
             'message': 'OK',
             'result': m_transactions,
         }
         transactions = PyWalib.get_out_transaction_history(address)
     url = mock.ANY
     headers = REQUESTS_HEADERS
     self.assertEqual(m_get.call_args_list,
                      [mock.call(url, headers=headers)])
     self.helper_test_get_history(transactions)
     # 4 transactions including 3 out transactions
     self.assertEquals(len(m_transactions), 4)
     self.assertEquals(len(transactions), 3)
     for i in range(len(transactions)):
         transaction = transactions[i]
         extra_dict = transaction['extra_dict']
         # this is only sent transactions
         self.assertEqual(extra_dict['sent'], True)
         self.assertEqual(extra_dict['received'], False)
         # nonce should be incremented each time
         self.assertEqual(transaction['nonce'], str(i))
Ejemplo n.º 2
0
 def test_get_nonce(self):
     """
     Checks get_nonce() returns the next nonce, i.e. transaction count.
     """
     address = ADDRESS
     nonce = PyWalib.get_nonce(address)
     transactions = PyWalib.get_out_transaction_history(address)
     last_transaction = transactions[-1]
     last_nonce = int(last_transaction['nonce'])
     self.assertEqual(nonce, last_nonce + 1)
Ejemplo n.º 3
0
 def test_get_out_transaction_history(self):
     """
     Checks get_out_transaction_history() works as expected.
     """
     address = ADDRESS
     transactions = PyWalib.get_out_transaction_history(address)
     self.helper_get_history(transactions)
     for i in range(len(transactions)):
         transaction = transactions[i]
         extra_dict = transaction['extra_dict']
         # this is only sent transactions
         self.assertEqual(extra_dict['sent'], True)
         self.assertEqual(extra_dict['received'], False)
         # nonce should be incremented each time
         self.assertEqual(transaction['nonce'], str(i))
Ejemplo n.º 4
0
 def test_get_nonce(self):
     """
     Checks get_nonce() returns the next nonce, i.e. transaction count.
     """
     address = ADDRESS
     m_transactions = M_TRANSACTIONS
     with patch_requests_get() as m_get:
         m_get.return_value.status_code = http.HTTPStatus.OK
         m_get.return_value.json.return_value = {
             'status': '1',
             'message': 'OK',
             'result': m_transactions,
         }
         nonce = PyWalib.get_nonce(address)
         transactions = PyWalib.get_out_transaction_history(address)
     url = mock.ANY
     headers = REQUESTS_HEADERS
     self.assertEqual(m_get.call_args_list,
                      2 * [mock.call(url, headers=headers)])
     last_transaction = transactions[-1]
     last_nonce = int(last_transaction['nonce'])
     self.assertEqual(nonce, last_nonce + 1)