Skip to content

Commit

Permalink
Try to continue reading after initial read
Browse files Browse the repository at this point in the history
- Sometimes the initial read only reads the first couple of lines of
  the output, leaving other available lines in the buffer.
  • Loading branch information
OBorce committed Sep 13, 2023
1 parent 15b5365 commit a816860
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 13 additions & 1 deletion test/functional/test_framework/wallet_cli_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,19 @@ async def _read_available_output(self) -> str:
try:
output = await asyncio.wait_for(self.process.stdout.read(ONE_MB), timeout=READ_TIMEOUT_SEC)
self.wallet_commands_file.write(output)
return output.decode().strip()
result = output.decode().strip()

try:
while True:
output = await asyncio.wait_for(self.process.stdout.read(ONE_MB), timeout=0.01)
if not output:
break
self.wallet_commands_file.write(output)
result += output.decode().strip()
except:
pass

return result
except:
self.wallet_commands_file.write(b"read from stdout timedout\n")
return ''
Expand Down
4 changes: 0 additions & 4 deletions test/functional/wallet_recover_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,6 @@ async def async_test(self):
assert mnemonic is not None
assert "Successfully closed the wallet" in await wallet.close_wallet()
assert "New wallet created successfully" in await wallet.recover_wallet(mnemonic)
# check that balance is 0 and accounts are not present
assert "Coins amount: 0" in await wallet.get_balance()
for idx in range(num_accounts):
assert f"Account not found for index: {idx+1}" in await wallet.select_account(idx+1)

# sync and check that accounts are now present and with correct balances
assert "Success" in await wallet.sync()
Expand Down

0 comments on commit a816860

Please sign in to comment.