Skip to content

Commit

Permalink
pytest: add another connection stress test, using multiple channels (…
Browse files Browse the repository at this point in the history
…bug #5254)

This one actually triggers an assert() on my machine, so though it
wasn't what I was looking for, let's include it:

```
lightning_connectd: connectd/connectd.c:1905: peer_conn_closed: Assertion `tal_count(peer->subds) == 0' failed.
lightning_connectd: FATAL SIGNAL 6 (version v0.11.0.1-15-gc812595)
0x55b3e1e21302 send_backtrace
	common/daemon.c:33
0x55b3e1e213ac crashdump
	common/daemon.c:46
0x7f44292ff08f ???
	/build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x7f44292ff00b __GI_raise
	../sysdeps/unix/sysv/linux/raise.c:51
0x7f44292de858 __GI_abort
	/build/glibc-SzIz7B/glibc-2.31/stdlib/abort.c:79
0x7f44292de728 __assert_fail_base
	/build/glibc-SzIz7B/glibc-2.31/assert/assert.c:92
0x7f44292effd5 __GI___assert_fail
	/build/glibc-SzIz7B/glibc-2.31/assert/assert.c:101
0x55b3e1e125db peer_conn_closed
	connectd/connectd.c:1905
0x55b3e1e17b4f destroy_subd
	connectd/multiplex.c:1112
0x55b3e1e7fdf4 notify
	ccan/ccan/tal/tal.c:240
0x55b3e1e8030b del_tree
	ccan/ccan/tal/tal.c:402
0x55b3e1e8035d del_tree
	ccan/ccan/tal/tal.c:412
0x55b3e1e806a7 tal_free
	ccan/ccan/tal/tal.c:486
0x55b3e1e6ef59 io_close
	ccan/ccan/io/io.c:450
0x55b3e1e17429 write_to_subd
	connectd/multiplex.c:957
0x55b3e1e6e1a3 next_plan
	ccan/ccan/io/io.c:59
0x55b3e1e6eebc io_do_always
	ccan/ccan/io/io.c:435
0x55b3e1e70baa handle_always
	ccan/ccan/io/poll.c:304
0x55b3e1e70ea1 io_loop
	ccan/ccan/io/poll.c:385
0x55b3e1e12dd5 main
	connectd/connectd.c:2159
0x7f44292e0082 __libc_start_main
	../csu/libc-start.c:308
0x55b3e1e0885d ???
	???:0
0xffffffffffffffff ???
	???:0
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed May 25, 2022
1 parent 357604f commit 18f76ba
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3731,6 +3731,46 @@ def test_htlc_failed_noclose(node_factory):
assert l1.rpc.getpeer(l2.info['id'])['connected']


@pytest.mark.openchannel('v2')
@pytest.mark.developer("dev-no-reconnect required")
def test_multichan_stress(node_factory, executor, bitcoind):
"""Test multiple channels between same nodes"""
l1, l2, l3 = node_factory.line_graph(3, opts={'may_reconnect': True,
'dev-no-reconnect': None})

# Now fund *second* channel l2->l3 (slightly larger)
bitcoind.rpc.sendtoaddress(l2.rpc.newaddr()['bech32'], 0.1)
bitcoind.generate_block(1)
sync_blockheight(bitcoind, [l2])
l2.rpc.fundchannel(l3.info['id'], '0.01001btc')
assert(len(only_one(l2.rpc.listpeers(l3.info['id'])['peers'])['channels']) == 2)
assert(len(only_one(l3.rpc.listpeers(l2.info['id'])['peers'])['channels']) == 2)

# Make sure gossip works.
bitcoind.generate_block(6, wait_for_mempool=1)
wait_for(lambda: len(l1.rpc.listchannels(source=l3.info['id'])['channels']) == 2)

def send_many_payments():
for i in range(30):
inv = l3.rpc.invoice(100, "label-" + str(i), "desc")['bolt11']
try:
l1.rpc.pay(inv)
except RpcError:
pass

# Send a heap of payments, while reconnecting...
fut = executor.submit(send_many_payments)

for i in range(10):
l3.rpc.disconnect(l2.info['id'], force=True)
l3.rpc.connect(l2.info['id'], 'localhost', l2.port)
fut.result(TIMEOUT)

wait_for(lambda: only_one(l3.rpc.listpeers(l2.info['id'])['peers'])['connected'])
inv = l3.rpc.invoice(100000000, "invoice4", "invoice4")
l1.rpc.pay(inv['bolt11'])


@pytest.mark.developer("dev-no-reconnect required")
def test_old_feerate(node_factory):
"""Test retransmission of old, now-unacceptable, feerate"""
Expand Down

0 comments on commit 18f76ba

Please sign in to comment.