invoices: pass through info to delete function, call invoice_index_deleted.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2023-07-22 17:16:17 +09:30
parent 2706f88705
commit cbdfc75bde
5 changed files with 74 additions and 16 deletions

View File

@@ -708,7 +708,8 @@ def test_listinvoices_filter(node_factory):
def test_wait_invoices(node_factory, executor):
l1, l2 = node_factory.line_graph(2)
# We use delexpiredinvoice
l1, l2 = node_factory.line_graph(2, opts={'allow-deprecated-apis': True})
# Asking for 0 gives us current index.
waitres = l2.rpc.call('wait', {'subsystem': 'invoices', 'indexname': 'created', 'nextvalue': 0})
@@ -753,7 +754,7 @@ def test_wait_invoices(node_factory, executor):
'updated': 1}
# Now check expiry works.
l2.rpc.invoice(42, 'invlabel2', 'invdesc2', expiry=2)
inv2 = l2.rpc.invoice(42, 'invlabel2', 'invdesc2', expiry=2)
waitres = l2.rpc.call('wait', {'subsystem': 'invoices', 'indexname': 'updated', 'nextvalue': 2})
assert waitres == {'subsystem': 'invoices',
@@ -762,9 +763,40 @@ def test_wait_invoices(node_factory, executor):
# {'label': 'invlabel2', 'bolt11': inv2['bolt11'], 'status': 'expired'}
'details': {'status': 'expired'}}
# Deleting correctly produces 3, not another 2!
l2.rpc.delinvoice('invlabel2', 'expired')
# Now for deletions
waitres = l2.rpc.call('wait', {'subsystem': 'invoices', 'indexname': 'deleted', 'nextvalue': 0})
assert waitres == {'subsystem': 'invoices',
'deleted': 0}
waitfut = executor.submit(l2.rpc.call, 'wait', {'subsystem': 'invoices', 'indexname': 'deleted', 'nextvalue': 1})
time.sleep(1)
l2.rpc.delinvoice('invlabel', 'paid')
waitres = waitfut.result(TIMEOUT)
assert waitres == {'subsystem': 'invoices',
'deleted': 1,
'details': {'label': 'invlabel',
'bolt11': inv['bolt11'],
'status': 'paid'}}
# Second returns instantly, without any details.
waitres = l2.rpc.call('wait', {'subsystem': 'invoices', 'indexname': 'deleted', 'nextvalue': 1})
assert waitres == {'subsystem': 'invoices',
'deleted': 1}
# Now check delexpiredinvoice works.
waitfut = executor.submit(l2.rpc.call, 'wait', {'subsystem': 'invoices', 'indexname': 'deleted', 'nextvalue': 2})
time.sleep(1)
l2.rpc.delexpiredinvoice()
waitres = waitfut.result(TIMEOUT)
assert waitres == {'subsystem': 'invoices',
'deleted': 2,
'details': {'label': 'invlabel2',
'bolt11': inv2['bolt11'],
'status': 'expired'}}
# Creating a new on gives us 3, not another 2!
waitfut = executor.submit(l2.rpc.call, 'wait', {'subsystem': 'invoices', 'indexname': 'created', 'nextvalue': 3})
time.sleep(1)
inv = l2.rpc.invoice(42, 'invlabel2', 'invdesc2')