Skip to content

Commit 5ce7b90

Browse files
committed
pytest: test for slow start when closing tx and large number of addresses.
From Whitslack's "startup takes 15 minutes" bug report, we can see that wallet_can_spend is extremely slow. We exacerbate this by setting a large bip32_max_index: ``` 91.29% 0.02% lightningd lightningd [.] wallet_can_spend | --91.27%--wallet_can_spend | |--47.81%--scriptpubkey_p2tr_derkey | | | |--42.80%--scriptpubkey_p2tr ... |--42.16%--bip32_key_from_parent ``` Signed-off-by: Rusty Russell <[email protected]>
1 parent b6c1ffa commit 5ce7b90

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/test_closing.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import re
1919
import subprocess
2020
import threading
21+
import time
2122
import unittest
2223

2324

@@ -4250,3 +4251,41 @@ def censoring_sendrawtx(r):
42504251
bitcoind.generate_block(1)
42514252
height = bitcoind.rpc.getblockchaininfo()['blocks']
42524253
l1.daemon.wait_for_log(r"Low-priority anchorspend aiming for block {} \(feerate 7500\)".format(height + 12))
4254+
4255+
4256+
@pytest.mark.slow_test
4257+
@pytest.mark.xfail(strict=True)
4258+
def test_slow_startup_many_addresses(node_factory, bitcoind):
4259+
l1, l2 = node_factory.get_nodes(2)
4260+
4261+
# Use really high key, to make scanning work hard.
4262+
l1.stop()
4263+
l1.db_manip("INSERT INTO vars (name, intval) VALUES ('bip32_max_index', 10000);")
4264+
l1.start()
4265+
4266+
NUM_CHANS = 20
4267+
FUND = 100000
4268+
4269+
addr = l1.rpc.newaddr()['bech32']
4270+
bitcoind.rpc.sendtoaddress(addr, (FUND * NUM_CHANS + 1000000) / 10**8)
4271+
4272+
bitcoind.generate_block(1)
4273+
sync_blockheight(bitcoind, [l1])
4274+
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
4275+
4276+
channels = []
4277+
for _ in range(NUM_CHANS):
4278+
channels.append(l1.rpc.fundchannel(l2.info['id'], FUND)['channel_id'])
4279+
bitcoind.generate_block(1)
4280+
wait_for(lambda: all([c['state'] == 'CHANNELD_NORMAL' for c in l1.rpc.listpeerchannels()['channels']]))
4281+
4282+
for c in channels:
4283+
l1.rpc.close(c)
4284+
4285+
l1.stop()
4286+
start = time.time()
4287+
l1.start()
4288+
end = time.time()
4289+
4290+
# Normally less than a second: give it 10.
4291+
assert end - start < 10

0 commit comments

Comments
 (0)