def test_add_transaction(self): cache = TxCache(self.store) tx = Transaction.from_hex(tx_hex_1) cache.add_transaction(tx) self.assertTrue(cache.is_cached(tx.txid())) entry = cache.get_entry(tx.txid()) self.assertEqual(TxFlags.HasByteData, entry.flags & TxFlags.HasByteData) self.assertIsNotNone(entry.bytedata)
def test_add_transaction_update(self): cache = TxCache(self.store) tx = Transaction.from_hex(tx_hex_1) data = [ tx.txid(), TxData(height=1295924, timestamp=1555296290, position=4, fee=None), None, TxFlags.StateCleared ] cache.add([data]) entry = cache.get_entry(tx.txid()) self.assertIsNotNone(entry) self.assertEqual(TxFlags.StateCleared, entry.flags & TxFlags.StateCleared) cache.add_transaction(tx, TxFlags.StateSettled) entry = cache.get_entry(tx.txid()) self.assertIsNotNone(entry) self.assertIsNotNone(entry.bytedata) self.assertEqual(TxFlags.StateSettled, entry.flags & TxFlags.StateSettled)