Skip to content

Commit ea1d233

Browse files
committed
bookkeeper: test (failing!) for rebalances on restart.
``` lightningd-1 2025-09-22T02:10:10.978Z **BROKEN** plugin-bookkeeper: Unparsable datastore ["bookkeeper","rebalances","1-2"] ``` And, indeed, rebalance is missing: ``` > outbound_ev = only_one([ev for ev in inc_evs if ev['tag'] == 'rebalance_fee']) tests/test_bookkeeper.py:825: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ arr = [] def only_one(arr): """Many JSON RPC calls return an array; often we only expect a single entry """ > assert len(arr) == 1 E AssertionError ``` Signed-off-by: Rusty Russell <[email protected]>
1 parent 350af1a commit ea1d233

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/test_bookkeeper.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ def test_empty_node(node_factory, bitcoind):
760760
l1.rpc.bkpr_inspect('wallet')
761761

762762

763+
@pytest.mark.xfail(strict=True)
763764
def test_rebalance_tracking(node_factory, bitcoind):
764765
"""
765766
We identify rebalances (invoices paid and received by our node),
@@ -822,6 +823,18 @@ def test_rebalance_tracking(node_factory, bitcoind):
822823
assert outbound_ev['credit_msat'] == Millisatoshi(0)
823824
assert outbound_ev['payment_id'] == pay_hash
824825

826+
# Will reload on restart!
827+
l1.restart()
828+
829+
inc_evs = l1.rpc.bkpr_listincome()['income_events']
830+
outbound_chan_id = only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])['channel_id']
831+
832+
outbound_ev = only_one([ev for ev in inc_evs if ev['tag'] == 'rebalance_fee'])
833+
assert outbound_ev['account'] == outbound_chan_id
834+
assert outbound_ev['debit_msat'] == Millisatoshi(1001)
835+
assert outbound_ev['credit_msat'] == Millisatoshi(0)
836+
assert outbound_ev['payment_id'] == pay_hash
837+
825838

826839
def test_bookkeeper_custom_notifs(node_factory, chainparams):
827840
# FIXME: what happens if we send internal funds to 'external' wallet?

0 commit comments

Comments
 (0)