lbryio / lbry-sdk

The LBRY SDK for building decentralized, censorship resistant, monetized, digital content apps.
https://lbry.com
MIT License
7.2k stars 483 forks source link

Ensure 2nd pass through transaction create loop will generate change > DUST. #3719

Open moodyjon opened 1 year ago

moodyjon commented 1 year ago

Fixes #3713

Reproduction of something similar to the original problem:

(lbry-venv) swdev1@Jonathans-Mac-mini lbry-sdk % python -m unittest -vv -k test_liquidate_at_loss tests/unit/wallet/test_transaction.py 
test_liquidate_at_loss (tests.unit.wallet.test_transaction.TransactionIOBalancing) ... FAIL
test_liquidate_at_loss_tiny_utxos (tests.unit.wallet.test_transaction.TransactionIOBalancing) ... 2022-12-12 11:19:56,267 - root - ERROR - Failed to create transaction:
Traceback (most recent call last):
  File "/Users/swdev1/lbry-sdk/lbry/wallet/transaction.py", line 822, in create
    raise InsufficientFundsError()
lbry.error.InsufficientFundsError: Not enough funds to cover this transaction.
ok

======================================================================
FAIL: test_liquidate_at_loss (tests.unit.wallet.test_transaction.TransactionIOBalancing)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/swdev1/lbry-sdk/lbry/testcase.py", line 145, in run
    self.loop.run_until_complete(maybe_coroutine)
  File "/usr/local/Cellar/python@3.7/3.7.13/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete
    return future.result()
  File "/Users/swdev1/lbry-sdk/tests/unit/wallet/test_transaction.py", line 549, in test_liquidate_at_loss
    self.assertListEqual([1100], [o.amount for o in tx.outputs])
AssertionError: Lists differ: [1100] != []

First list contains 1 additional elements.
First extra element 0:
1100

- [1100]
+ []

----------------------------------------------------------------------
Ran 2 tests in 1.295s

FAILED (failures=1)
coveralls commented 1 year ago

Coverage Status

Coverage decreased (-0.02%) to 56.623% when pulling bea20892f734aa7937d741907afccffc19842bcf on moodyjon:zero_tx_outputs2 into 6258651650f851190582be69c92cc476289c0bc8 on lbryio:master.