MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_autoclean_batch

Function test_autoclean_batch

tests/test_plugin.py:4664–4693  ·  view source on GitHub ↗
(node_factory)

Source from the content-addressed store, hash-verified

4662
4663
4664def test_autoclean_batch(node_factory):
4665 l1 = node_factory.get_node()
4666
4667 # Many expired invoices
4668 for i in range(100):
4669 l1.rpc.invoice(amount_msat=12300, label=f'inv1{i}', description='description', expiry=1)
4670
4671 time.sleep(3)
4672 l1.rpc.setconfig('dev-autoclean-max-batch', 2)
4673
4674 # Test manual clean
4675 ret = l1.rpc.autoclean_once('expiredinvoices', 1)
4676 assert ret == {'autoclean': {'expiredinvoices': {'cleaned': 100, 'uncleaned': 0}}}
4677
4678 for i in range(100):
4679 l1.rpc.invoice(amount_msat=12300, label=f'inv2{i}', description='description', expiry=1)
4680
4681 time.sleep(3)
4682
4683 # Test cycle clean
4684 assert (l1.rpc.autoclean_status('expiredinvoices')
4685 == {'autoclean': {'expiredinvoices': {'enabled': False, 'cleaned': 100}}})
4686
4687 l1.rpc.setconfig('autoclean-expiredinvoices-age', 2)
4688 assert (l1.rpc.autoclean_status('expiredinvoices')
4689 == {'autoclean': {'expiredinvoices': {'enabled': True, 'cleaned': 100, 'age': 2}}})
4690
4691 l1.rpc.setconfig('autoclean-cycle', 5)
4692 wait_for(lambda: l1.rpc.autoclean_status('expiredinvoices')
4693 == {'autoclean': {'expiredinvoices': {'enabled': True, 'cleaned': 200, 'age': 2}}})
4694
4695
4696def test_sql_crash(node_factory, bitcoind):

Callers

nothing calls this directly

Calls 4

wait_forFunction · 0.90
autoclean_statusMethod · 0.80
get_nodeMethod · 0.45
invoiceMethod · 0.45

Tested by

no test coverage detected