mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
autoclean: use config variables, not commands.
It's more natural: we will eventually support dynamic config variables, so this will be quite nice. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: Plugins: `autoclean` can now delete old forwards, payments, and invoices automatically.
This commit is contained in:
committed by
Christian Decker
parent
a15f1be5f8
commit
399288db3f
@@ -2955,7 +2955,10 @@ def test_autoclean(node_factory):
|
||||
l3.rpc.invoice(amount_msat=12300, label='inv3', description='description3', expiry=20)
|
||||
inv4 = l3.rpc.invoice(amount_msat=12300, label='inv4', description='description4', expiry=2000)
|
||||
inv5 = l3.rpc.invoice(amount_msat=12300, label='inv5', description='description5', expiry=2000)
|
||||
l3.rpc.autoclean(subsystem='expiredinvoices', age=2)
|
||||
|
||||
l3.stop()
|
||||
l3.daemon.opts['autoclean-expiredinvoices-age'] = 2
|
||||
l3.start()
|
||||
assert l3.rpc.autoclean_status()['autoclean']['expiredinvoices']['enabled'] is True
|
||||
assert l3.rpc.autoclean_status()['autoclean']['expiredinvoices']['age'] == 2
|
||||
|
||||
@@ -2979,7 +2982,9 @@ def test_autoclean(node_factory):
|
||||
assert l3.rpc.autoclean_status()['autoclean']['expiredinvoices']['cleaned'] == 1
|
||||
|
||||
# Disabling works
|
||||
l3.rpc.autoclean(subsystem='expiredinvoices', age='never')
|
||||
l3.stop()
|
||||
l3.daemon.opts['autoclean-expiredinvoices-age'] = 0
|
||||
l3.start()
|
||||
assert l3.rpc.autoclean_status()['autoclean']['expiredinvoices']['enabled'] is False
|
||||
assert 'age' not in l3.rpc.autoclean_status()['autoclean']['expiredinvoices']
|
||||
|
||||
@@ -2997,7 +3002,9 @@ def test_autoclean(node_factory):
|
||||
assert 'age' not in l3.rpc.autoclean_status()['autoclean']['expiredinvoices']
|
||||
|
||||
# Now enable: they will get autocleaned
|
||||
l3.rpc.autoclean(subsystem='expiredinvoices', age=2)
|
||||
l3.stop()
|
||||
l3.daemon.opts['autoclean-expiredinvoices-age'] = 2
|
||||
l3.start()
|
||||
wait_for(lambda: len(l3.rpc.listinvoices()['invoices']) == 2)
|
||||
assert l3.rpc.autoclean_status()['autoclean']['expiredinvoices']['cleaned'] == 3
|
||||
|
||||
@@ -3012,7 +3019,9 @@ def test_autoclean(node_factory):
|
||||
|
||||
assert l3.rpc.autoclean_status()['autoclean']['paidinvoices']['enabled'] is False
|
||||
assert l3.rpc.autoclean_status()['autoclean']['paidinvoices']['cleaned'] == 0
|
||||
l3.rpc.autoclean(subsystem='paidinvoices', age=1)
|
||||
l3.stop()
|
||||
l3.daemon.opts['autoclean-paidinvoices-age'] = 1
|
||||
l3.start()
|
||||
assert l3.rpc.autoclean_status()['autoclean']['paidinvoices']['enabled'] is True
|
||||
|
||||
wait_for(lambda: l3.rpc.listinvoices()['invoices'] == [])
|
||||
@@ -3021,13 +3030,17 @@ def test_autoclean(node_factory):
|
||||
|
||||
assert only_one(l1.rpc.listpays(inv5['bolt11'])['pays'])['status'] == 'failed'
|
||||
assert only_one(l1.rpc.listpays(inv4['bolt11'])['pays'])['status'] == 'complete'
|
||||
l1.rpc.autoclean(subsystem='failedpays', age=2)
|
||||
l1.stop()
|
||||
l1.daemon.opts['autoclean-failedpays-age'] = 1
|
||||
l1.start()
|
||||
|
||||
wait_for(lambda: l1.rpc.listpays(inv5['bolt11'])['pays'] == [])
|
||||
assert l1.rpc.autoclean_status()['autoclean']['failedpays']['cleaned'] == 1
|
||||
assert l1.rpc.autoclean_status()['autoclean']['succeededpays']['cleaned'] == 0
|
||||
|
||||
l1.rpc.autoclean(subsystem='succeededpays', age=2)
|
||||
l1.stop()
|
||||
l1.daemon.opts['autoclean-succeededpays-age'] = 2
|
||||
l1.start()
|
||||
wait_for(lambda: l1.rpc.listpays(inv4['bolt11'])['pays'] == [])
|
||||
assert l1.rpc.listsendpays() == {'payments': []}
|
||||
|
||||
@@ -3037,7 +3050,9 @@ def test_autoclean(node_factory):
|
||||
assert len(l2.rpc.listforwards()['forwards']) == 2
|
||||
|
||||
# Clean failed ones.
|
||||
l2.rpc.autoclean(subsystem='failedforwards', age=2)
|
||||
l2.stop()
|
||||
l2.daemon.opts['autoclean-failedforwards-age'] = 2
|
||||
l2.start()
|
||||
wait_for(lambda: l2.rpc.listforwards(status='failed')['forwards'] == [])
|
||||
|
||||
assert len(l2.rpc.listforwards(status='settled')['forwards']) == 1
|
||||
@@ -3045,7 +3060,9 @@ def test_autoclean(node_factory):
|
||||
assert l2.rpc.autoclean_status()['autoclean']['succeededforwards']['cleaned'] == 0
|
||||
|
||||
# Clean succeeded ones
|
||||
l2.rpc.autoclean(subsystem='succeededforwards', age=2)
|
||||
l2.stop()
|
||||
l2.daemon.opts['autoclean-succeededforwards-age'] = 2
|
||||
l2.start()
|
||||
wait_for(lambda: l2.rpc.listforwards(status='settled')['forwards'] == [])
|
||||
assert l2.rpc.listforwards() == {'forwards': []}
|
||||
assert l2.rpc.autoclean_status()['autoclean']['failedforwards']['cleaned'] == 1
|
||||
|
||||
Reference in New Issue
Block a user