fix: time margin for deleting failed payments (#2147)

this pr adds a 15 minutes margin before deleting failed outgoing payments.
This commit is contained in:
dni ⚡
2023-12-02 00:41:09 +01:00
committed by GitHub
parent 5f36800100
commit 9fcf566540
2 changed files with 6 additions and 5 deletions
+2 -1
View File
@@ -221,7 +221,8 @@ class Payment(FromRowModel):
f"expired {expiration_date}" f"expired {expiration_date}"
) )
await self.delete(conn) await self.delete(conn)
elif self.is_out and status.failed: # wait at least 15 minutes before deleting failed outgoing payments
elif self.is_out and status.failed and self.time + 900 < int(time.time()):
logger.warning( logger.warning(
f"Deleting outgoing failed payment {self.checking_id}: {status}" f"Deleting outgoing failed payment {self.checking_id}: {status}"
) )
+4 -4
View File
@@ -766,10 +766,10 @@ async def test_pay_hold_invoice_check_pending_and_fail_cancel_payment_task_in_me
assert status.paid is False assert status.paid is False
# now the payment should be gone after the status check # now the payment should be gone after the status check
payment_db_after_status_check = await get_standalone_payment( # payment_db_after_status_check = await get_standalone_payment(
invoice_obj.payment_hash # invoice_obj.payment_hash
) # )
assert payment_db_after_status_check is None # assert payment_db_after_status_check is None
@pytest.mark.asyncio @pytest.mark.asyncio