fix intermittent test_queries failure in torba due to non-unique TX generated

This commit is contained in:
Lex Berezhny 2019-06-25 00:56:33 -04:00
parent 9712ef8abf
commit 894e86d3ee

View file

@ -5,6 +5,7 @@ from torba.client.wallet import Wallet
from torba.client.constants import COIN from torba.client.constants import COIN
from torba.coin.bitcoinsegwit import MainNetLedger as ledger_class from torba.coin.bitcoinsegwit import MainNetLedger as ledger_class
from torba.client.basedatabase import query, constraints_to_sql, AIOSQLite from torba.client.basedatabase import query, constraints_to_sql, AIOSQLite
from torba.client.hash import sha256
from torba.testcase import AsyncioTestCase from torba.testcase import AsyncioTestCase
@ -187,7 +188,7 @@ class TestQueries(AsyncioTestCase):
to_address = await my_account.receiving.get_or_create_usable_address() to_address = await my_account.receiving.get_or_create_usable_address()
to_hash = ledger_class.address_to_hash160(to_address) to_hash = ledger_class.address_to_hash160(to_address)
tx = ledger_class.transaction_class(height=height, is_verified=True) \ tx = ledger_class.transaction_class(height=height, is_verified=True) \
.add_inputs([self.txi(self.txo(1, NULL_HASH))]) \ .add_inputs([self.txi(self.txo(1, sha256(str(height).encode())))]) \
.add_outputs([self.txo(1, to_hash)]) .add_outputs([self.txo(1, to_hash)])
await self.ledger.db.insert_transaction(tx) await self.ledger.db.insert_transaction(tx)
await self.ledger.db.save_transaction_io(tx, to_address, to_hash, '') await self.ledger.db.save_transaction_io(tx, to_address, to_hash, '')