pytest: test (failing) for bkpr-listincome filtering times on onchain events.
What changed, and why it matters
This commit only adds a new test case to the project's test suite. The test is marked as expected to fail (xfail) and checks whether a bookkeeping command correctly filters on-chain income events by timestamp. There is no change to production code, no fix, and no disclosed security issue.
No security action needed. Treat as routine test-suite maintenance. If investigating the underlying behavior, review the bkpr-listincome implementation for correct timestamp filtering of on-chain events.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds a single pytest function, test_listincome_timebox, in tests/test_bookkeeper.py. It is decorated with @pytest.mark.xfail(strict=True), meaning it documents a known failing behavior. The test exercises bkpr-listincome with an end_time filter and asserts that no income events with timestamps greater than the filter are returned. No implementation code is modified.
Changed components
tests/test_bookkeeper.pyInspect captured patch +31 / −0
diff --git a/tests/test_bookkeeper.py b/tests/test_bookkeeper.py
index c7ba58b2..c9ddf9e6 100644
--- a/tests/test_bookkeeper.py
+++ b/tests/test_bookkeeper.py
@@ -1162,3 +1162,34 @@ def test_migration_no_bkpr(node_factory, bitcoind):
'is_rebalance': False,
'tag': 'journal_entry',
'type': 'channel'}]
+
+
+@pytest.mark.xfail(strict=True)
+def test_listincome_timebox(node_factory, bitcoind):
+ l1 = node_factory.get_node()
+ addr = l1.rpc.newaddr()['bech32']
+
+ amount = 1111111
+ bitcoind.rpc.sendtoaddress(addr, amount / 10**8)
+
+ bitcoind.generate_block(1, wait_for_mempool=1)
+ wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == 1)
+
+ waddr = bitcoind.rpc.getnewaddress()
+
+ # Ok, now we send some funds to an external address, get change.
+ l1.rpc.withdraw(waddr, amount // 2)
+ bitcoind.generate_block(1, wait_for_mempool=1)
+ wait_for(lambda: len(l1.rpc.listfunds(spent=True)['outputs']) == 2)
+
+ first_one = int(time.time())
+ time.sleep(2)
+
+ # Do another one, make sure we don't see it if we filter by timestamp.
+ bitcoind.rpc.sendtoaddress(addr, amount / 10**8)
+
+ bitcoind.generate_block(1, wait_for_mempool=1)
+ wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == 2)
+
+ incomes = l1.rpc.bkpr_listincome(end_time=first_one)['income_events']
+ assert [i for i in incomes if i['timestamp'] > first_one] == []
Why this scored 11/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.