Exemple #1
0
    def _status(self, tx_digest):
        url = '{}://{}:{}/api/status/tx/{}'.format(self.protocol, self.host,
                                                   self.port, tx_digest)

        response = self._session.get(url).json()

        return TxStatus(digest=decode_hex_or_b64(response['tx']),
                        status=str(response['status']),
                        exit_code=int(response['exit_code']),
                        charge=int(response['charge']),
                        charge_rate=int(response['charge_rate']),
                        fee=int(response['fee']))
Exemple #2
0
 def test_empty(self):
     self.assertEqual(decode_hex_or_b64(''), b'')
     self.assertEqual(decode_hex_or_b64(b''), b'')
Exemple #3
0
 def test_0x(self):
     self.assertEqual(decode_hex_or_b64('0x'), b'\xd3')
     self.assertEqual(decode_hex_or_b64(b'0x'), b'\xd3')
Exemple #4
0
 def test_unpadded_base64(self):
     self.assertEqual(decode_hex_or_b64('YWJjZDEyMzQ'), b'abcd1234')
     self.assertEqual(decode_hex_or_b64(b'YWJjZDEyMzQ'), b'abcd1234')
Exemple #5
0
 def test_prefixed_hex(self):
     self.assertEqual(decode_hex_or_b64('0xdeadbeef'), b'\xde\xad\xbe\xef')
     self.assertEqual(decode_hex_or_b64(b'0xdeadbeef'), b'\xde\xad\xbe\xef')
Exemple #6
0
 def test_invalid_decode_type(self):
     with self.assertRaises(TypeError):
         decode_hex_or_b64(4)