Skip to content

Commit c386995

Browse files
committed
pytest: test for parallel bookkeeper queries.
If both refresh new events, we will get an assertion: ``` ``` Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 07c57b6 commit c386995

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/test_bookkeeper.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,22 @@ def test_listincome_timebox(node_factory, bitcoind):
11941194
incomes = l1.rpc.bkpr_listincome(end_time=first_one)['income_events']
11951195
assert [i for i in incomes if i['timestamp'] > first_one] == []
11961196

1197+
1198+
@pytest.mark.xfail(strict=True)
1199+
@unittest.skipIf(TEST_NETWORK != 'regtest', "Snapshots are bitcoin regtest.")
1200+
@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "uses snapshots")
1201+
def test_bkpr_parallel(node_factory, bitcoind, executor):
1202+
"""Bookkeeper could crash with parallel requests"""
1203+
bitcoind.generate_block(1)
1204+
l1 = node_factory.get_node(dbfile="l1-before-moves-in-db.sqlite3.xz",
1205+
options={'database-upgrade': True})
1206+
1207+
fut1 = executor.submit(l1.rpc.bkpr_listincome)
1208+
fut2 = executor.submit(l1.rpc.bkpr_listincome)
1209+
1210+
fut1.result()
1211+
fut2.result()
1212+
11971213
# We save blockheights in storage, so make sure we restore them on restart!
11981214
acctevents_before = l1.rpc.bkpr_listaccountevents()
11991215
l1.restart()

0 commit comments

Comments
 (0)