txbatcher: if we raise NotEnoughFunds, remove
the largest output from the current tx and retry In the unit test, this results in waiting until the current tx is mined.
This commit is contained in:
@@ -153,13 +153,21 @@ class TestTxBatcher(ElectrumTestCase):
|
||||
# to_self_payment tx1
|
||||
output1 = PartialTxOutput.from_address_and_value("tb1qyfnv3y866ufedugxxxfksyratv4pz3h78g9dad", 20_000)
|
||||
wallet.txbatcher.add_payment_output('default', output1, self.fee_policy_descriptor)
|
||||
toself_tx = await self.network.next_tx()
|
||||
assert len(toself_tx.outputs()) == 2
|
||||
assert output1 in toself_tx.outputs()
|
||||
tx1 = await self.network.next_tx()
|
||||
assert len(tx1.outputs()) == 2
|
||||
assert output1 in tx1.outputs()
|
||||
|
||||
# outgoing payment tx2
|
||||
output2 = PartialTxOutput.from_address_and_value("tb1qkfn0fude7z789uys2u7sf80kd4805zpvs3na0h", 90_000)
|
||||
wallet.txbatcher.add_payment_output('default', output2, self.fee_policy_descriptor)
|
||||
# before tx1 gets confirmed, txbatch.create_transaction will raise notenoughfunds
|
||||
await asyncio.sleep(wallet.txbatcher.SLEEP_INTERVAL)
|
||||
|
||||
# tx1 gets confirmed
|
||||
wallet.adb.receive_tx_callback(tx1, tx_height=1)
|
||||
tx_mined_status = wallet.adb.get_tx_height(tx1.txid())
|
||||
wallet.adb.add_verified_tx(tx1.txid(), tx_mined_status._replace(conf=1))
|
||||
|
||||
tx2 = await self.network.next_tx()
|
||||
assert len(tx2.outputs()) == 2
|
||||
assert output2 in tx2.outputs()
|
||||
|
||||
Reference in New Issue
Block a user