mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +01:00
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:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user