Skip to content

Commit

Permalink
test_lightningd: Add test for autocleaninvoice.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZmnSCPxj authored and cdecker committed Mar 20, 2018
1 parent 159e736 commit 5557958
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/test_lightningd.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,44 @@ def test_shutdown(self):
.format(l1.daemon.lightning_dir, leaks))
l1.rpc.stop()

def test_autocleaninvoice(self):
l1 = self.node_factory.get_node()

l1.rpc.autocleaninvoice(cycle_seconds=8, expired_by=2)

l1.rpc.invoice(msatoshi=12300, label='inv1', description='1', expiry=4)
l1.rpc.invoice(msatoshi=12300, label='inv2', description='2', expiry=12)

# time 0
# Both should still be there.
assert len(l1.rpc.listinvoices('inv1')['invoices']) == 1
assert len(l1.rpc.listinvoices('inv2')['invoices']) == 1

time.sleep(6) # total 6
# Both should still be there - auto clean cycle not started.
# inv1 should be expired
assert len(l1.rpc.listinvoices('inv1')['invoices']) == 1
assert l1.rpc.listinvoices('inv1')['invoices'][0]['status'] == 'expired'
assert len(l1.rpc.listinvoices('inv2')['invoices']) == 1
assert l1.rpc.listinvoices('inv2')['invoices'][0]['status'] != 'expired'

time.sleep(4) # total 10
# inv1 should have deleted, inv2 still there and unexpired.
assert len(l1.rpc.listinvoices('inv1')['invoices']) == 0
assert len(l1.rpc.listinvoices('inv2')['invoices']) == 1
assert l1.rpc.listinvoices('inv2')['invoices'][0]['status'] != 'expired'

time.sleep(4) # total 14
# inv2 should still be there, but expired
assert len(l1.rpc.listinvoices('inv1')['invoices']) == 0
assert len(l1.rpc.listinvoices('inv2')['invoices']) == 1
assert l1.rpc.listinvoices('inv2')['invoices'][0]['status'] == 'expired'

time.sleep(4) # total 18
# Everything deleted
assert len(l1.rpc.listinvoices('inv1')['invoices']) == 0
assert len(l1.rpc.listinvoices('inv2')['invoices']) == 0

def test_invoice(self):
l1 = self.node_factory.get_node()
l2 = self.node_factory.get_node()
Expand Down

0 comments on commit 5557958

Please sign in to comment.