(node_factory)
| 3484 | |
| 3485 | |
| 3486 | def test_autoclean_once(node_factory): |
| 3487 | l1, l2, l3 = node_factory.line_graph(3, opts={'may_reconnect': True}, |
| 3488 | wait_for_announce=True) |
| 3489 | |
| 3490 | l3.rpc.invoice(amount_msat=12300, label='inv1', description='description1', expiry=1) |
| 3491 | inv2 = l3.rpc.invoice(amount_msat=12300, label='inv2', description='description4') |
| 3492 | inv3 = l3.rpc.invoice(amount_msat=12300, label='inv3', description='description5') |
| 3493 | |
| 3494 | l1.rpc.xpay(inv2['bolt11']) |
| 3495 | l3.rpc.delinvoice('inv3', 'unpaid') |
| 3496 | with pytest.raises(RpcError, match="Destination said it doesn't know invoice: incorrect_or_unknown_payment_details"): |
| 3497 | l1.rpc.xpay(inv3['bolt11']) |
| 3498 | |
| 3499 | # Default status |
| 3500 | default_status = {'autoclean': {'failedpays': {'enabled': False, |
| 3501 | 'cleaned': 0}, |
| 3502 | 'succeededpays': {'enabled': False, |
| 3503 | 'cleaned': 0}, |
| 3504 | 'failedforwards': {'enabled': False, |
| 3505 | 'cleaned': 0}, |
| 3506 | 'succeededforwards': {'enabled': False, |
| 3507 | 'cleaned': 0}, |
| 3508 | 'expiredinvoices': {'enabled': False, |
| 3509 | 'cleaned': 0}, |
| 3510 | 'paidinvoices': {'enabled': False, |
| 3511 | 'cleaned': 0}, |
| 3512 | 'networkevents': {'enabled': True, |
| 3513 | 'age': 2592000, |
| 3514 | 'cleaned': 0}}} |
| 3515 | expected = [copy.deepcopy(default_status) for _ in (l1, l2, l3)] |
| 3516 | for i, node in enumerate([l1, l2, l3]): |
| 3517 | assert node.rpc.autoclean_status() == expected[i] |
| 3518 | |
| 3519 | # Make sure > 1 second old! |
| 3520 | time.sleep(2) |
| 3521 | assert (l1.rpc.autoclean_once('failedpays', 1) |
| 3522 | == {'autoclean': {'failedpays': {'cleaned': 1, 'uncleaned': 0}}}) |
| 3523 | |
| 3524 | assert (l1.rpc.autoclean_once('succeededpays', 1) |
| 3525 | == {'autoclean': {'succeededpays': {'cleaned': 1, 'uncleaned': 0}}}) |
| 3526 | expected[0]['autoclean']['failedpays']['cleaned'] = 1 |
| 3527 | expected[0]['autoclean']['succeededpays']['cleaned'] = 1 |
| 3528 | assert l1.rpc.autoclean_status() == expected[0] |
| 3529 | |
| 3530 | assert (l2.rpc.autoclean_once('failedforwards', 1) |
| 3531 | == {'autoclean': {'failedforwards': {'cleaned': 1, 'uncleaned': 0}}}) |
| 3532 | expected[1]['autoclean']['failedforwards']['cleaned'] = 1 |
| 3533 | assert l2.rpc.autoclean_status() == expected[1] |
| 3534 | |
| 3535 | assert (l2.rpc.autoclean_once('succeededforwards', 1) |
| 3536 | == {'autoclean': {'succeededforwards': {'cleaned': 1, 'uncleaned': 0}}}) |
| 3537 | expected[1]['autoclean']['succeededforwards']['cleaned'] = 1 |
| 3538 | assert l2.rpc.autoclean_status() == expected[1] |
| 3539 | |
| 3540 | assert (l3.rpc.autoclean_once('expiredinvoices', 1) |
| 3541 | == {'autoclean': {'expiredinvoices': {'cleaned': 1, 'uncleaned': 0}}}) |
| 3542 | expected[2]['autoclean']['expiredinvoices']['cleaned'] = 1 |
| 3543 | assert l3.rpc.autoclean_status() == expected[2] |
nothing calls this directly
no test coverage detected