Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
jackrobison committed Oct 6, 2021
1 parent 439ba96 commit 09af182
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions lbry/wallet/server/leveldb.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,8 +807,8 @@ async def open_dbs(self):
return

self.prefix_db = HubDB(
os.path.join(self.env.db_dir, 'lbry-leveldb'), self.env.reorg_limit, self.env.cache_MB,
max_open_files=512
os.path.join(self.env.db_dir, 'lbry-leveldb'), cache_mb=self.env.cache_MB,
reorg_limit=self.env.reorg_limit, max_open_files=512
)
self.logger.info(f'opened db: lbry-leveldb')

Expand Down
4 changes: 3 additions & 1 deletion lbry/wallet/server/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,12 +636,14 @@ async def _notify_sessions(self, height, touched, new_touched):
None, touched.intersection_update, self.hashx_subscriptions_by_session.keys()
)

if touched or (height_changed and self.mempool_statuses):
if touched or new_touched or (height_changed and self.mempool_statuses):
notified_hashxs = 0
session_hashxes_to_notify = defaultdict(list)
to_notify = touched if height_changed else new_touched

for hashX in to_notify:
if hashX not in self.hashx_subscriptions_by_session:
continue
for session_id in self.hashx_subscriptions_by_session[hashX]:
session_hashxes_to_notify[session_id].append(hashX)
notified_hashxs += 1
Expand Down
22 changes: 10 additions & 12 deletions tests/integration/transactions/test_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ async def test_variety_of_transactions_and_longish_history(self):
# send 10 coins to first 10 receiving addresses and then 10 transactions worth 10 coins each
# to the 10th receiving address for a total of 30 UTXOs on the entire account
for i in range(10):
notification = asyncio.ensure_future(self.on_address_update(addresses[i]))
txid = await self.blockchain.send_to_address(addresses[i], 10)
await self.wait_for_txid(addresses[i])
await notification
notification = asyncio.ensure_future(self.on_address_update(addresses[9]))
txid = await self.blockchain.send_to_address(addresses[9], 10)
await self.wait_for_txid(addresses[9])
await notification

# use batching to reduce issues with send_to_address on cli
await self.assertBalance(self.account, '200.0')
Expand Down Expand Up @@ -174,11 +176,6 @@ def random_summary(*args, **kwargs):
self.assertEqual(21, len((await self.ledger.get_local_status_and_history(address))[1]))
self.assertEqual(0, len(self.ledger._known_addresses_out_of_sync))

def wait_for_txid(self, address):
return asyncio.ensure_future(self.ledger.on_transaction.where(
lambda e: e.address == address
))

async def _test_transaction(self, send_amount, address, inputs, change):
tx = await Transaction.create(
[], [Output.pay_pubkey_hash(send_amount, self.ledger.address_to_hash160(address))], [self.account],
Expand All @@ -203,30 +200,31 @@ async def assertSpendable(self, amounts):
async def test_sqlite_coin_chooser(self):
wallet_manager = WalletManager([self.wallet], {self.ledger.get_id(): self.ledger})
await self.blockchain.generate(300)

await self.assertBalance(self.account, '0.0')
address = await self.account.receiving.get_or_create_usable_address()
other_account = self.wallet.generate_account(self.ledger)
other_address = await other_account.receiving.get_or_create_usable_address()
self.ledger.coin_selection_strategy = 'sqlite'
await self.ledger.subscribe_account(self.account)
accepted = self.wait_for_txid(address)

accepted = asyncio.ensure_future(self.on_address_update(address))
txid = await self.blockchain.send_to_address(address, 1.0)
await accepted

accepted = self.wait_for_txid(address)
accepted = asyncio.ensure_future(self.on_address_update(address))
txid = await self.blockchain.send_to_address(address, 1.0)
await accepted

accepted = self.wait_for_txid(address)
accepted = asyncio.ensure_future(self.on_address_update(address))
txid = await self.blockchain.send_to_address(address, 3.0)
await accepted

accepted = self.wait_for_txid(address)
accepted = asyncio.ensure_future(self.on_address_update(address))
txid = await self.blockchain.send_to_address(address, 5.0)
await accepted

accepted = self.wait_for_txid(address)
accepted = asyncio.ensure_future(self.on_address_update(address))
txid = await self.blockchain.send_to_address(address, 10.0)
await accepted

Expand Down

0 comments on commit 09af182

Please sign in to comment.