Fix: Update apipayments updated_at field when a payment is updated. (#3699)

Co-authored-by: Vlad Stan <stan.v.vlad@gmail.com>
This commit is contained in:
21M4TW
2026-01-09 09:52:10 +02:00
committed by GitHub
co-authored by Vlad Stan
parent aa1bddcdd5
commit a185197e34
2 changed files with 24 additions and 2 deletions
+12
View File
@@ -1,3 +1,5 @@
import asyncio
import pytest
from lnbits.core.crud import (
@@ -6,6 +8,7 @@ from lnbits.core.crud import (
get_payments_paginated,
update_payment,
)
from lnbits.core.crud.payments import get_standalone_payment
from lnbits.core.models import PaymentFilters, PaymentState
from lnbits.core.services import (
create_invoice,
@@ -39,6 +42,15 @@ async def test_crud_get_payments(app):
filters = Filters(limit=100)
payments = await get_payments(wallet_id=wallet.id, filters=filters)
assert len(payments) == 22, "should return 22 successful payments"
first_payment = payments[0]
first_payment_updated_at = first_payment.updated_at.replace()
await update_payment(first_payment)
await asyncio.sleep(0.1) # ensure updated_at will be different
first_payment_updated = await get_standalone_payment(first_payment.checking_id)
assert first_payment_updated, "Updated payment not found"
assert (
first_payment_updated.updated_at > first_payment_updated_at
), "Updated payment timestamp is not newer"
payments = await get_payments(wallet_id=wallet.id, incoming=True, filters=filters)
assert len(payments) == 11, "should return 11 successful incoming payments"