fix: cli: check_hold_invoice showing settled invoice as unpaid
the cli command `check_hold_invoice` incorrectly assumes that `lnworker.is_accepted_mpp(payment_hash)` is true for settled invoices, however it is not as the received mpp entries will be removed from the `lnworker.received_mpp_htlcs` shortly after adding the preimage to lnworker (after the htlcs got removed from the channel). Also renames `amount_sat` in the `check_hold_invoice` response to `amount_sat_received` to make it more obvious that this is the currently received amount instead of the amount the invoice of `payment_hash` has been created with.
This commit is contained in:
@@ -495,7 +495,7 @@ class TestCommandsTestnet(ElectrumTestCase):
|
||||
mock.patch.object(wallet.lnworker, 'get_payment_mpp_amount_msat', return_value=10_000 * 1000):
|
||||
status: dict = await cmds.check_hold_invoice(payment_hash=payment_hash, wallet=wallet)
|
||||
assert status['status'] == 'paid'
|
||||
assert status['amount_sat'] == 10000
|
||||
assert status['amount_sat_received'] == 10000
|
||||
|
||||
settle_result = await cmds.settle_hold_invoice(
|
||||
preimage=preimage.hex(),
|
||||
@@ -504,6 +504,14 @@ class TestCommandsTestnet(ElectrumTestCase):
|
||||
assert settle_result['settled'] == payment_hash
|
||||
assert wallet.lnworker._preimages[payment_hash] == preimage.hex()
|
||||
assert payment_hash not in wallet.lnworker.dont_settle_htlcs
|
||||
with (mock.patch.object(
|
||||
wallet.lnworker,
|
||||
'get_payment_value',
|
||||
return_value=(None, 10000*1000, None, None),
|
||||
)):
|
||||
settled_status: dict = await cmds.check_hold_invoice(payment_hash=payment_hash, wallet=wallet)
|
||||
assert settled_status['status'] == 'settled'
|
||||
assert settled_status['amount_sat_received'] == 10000
|
||||
|
||||
with self.assertRaises(AssertionError):
|
||||
# cancelling a settled invoice should raise
|
||||
|
||||
Reference in New Issue
Block a user