Skip to content

Commit afa8875

Browse files
committed
pytest: fix race in test_renepay where we didn't wait for all channels.
get_channel_scid() returns the *first* channel, and we want all the channels. So they may not actually be all visible in gossip. ``` @unittest.skipIf(TEST_NETWORK == 'liquid-regtest', "broken for some reason") def test_hardmpp2(node_factory, bitcoind): """Credits to @daywalker90 for this test case.""" opts = {"disable-mpp": None, "fee-base": 0, "fee-per-satoshi": 10} l1, l2, l3 = node_factory.get_nodes(3, opts=opts) start_channels( [ (l1, l2, 100_000), (l1, l2, 200_000), (l1, l2, 300_000), (l1, l2, 400_000), (l2, l3, 100_000), (l2, l3, 200_000), (l2, l3, 300_000), (l2, l3, 600_000), ] ) # FIXME: changing the last channel from 600k to 400k will fail the test due # to l2 not accepting to forward any amount above 200k with error: # CHANNEL_ERR_CHANNEL_CAPACITY_EXCEEDED, still investigating inv = l3.rpc.invoice("800000sat", "inv", "description") > l1.rpc.call("renepay", {"invstring": inv["bolt11"]}) tests/test_renepay.py:797: ... elif "error" in resp: > raise RpcError(method, payload, resp['error']) E pyln.client.lightning.RpcError: RPC call failed: method: renepay, payload: {'invstring': 'lnbcrt8m1pnl3zfksp54n6vhkrcj0nkn2uqhf232v62539048u2ree4g9ssytm47gasgctspp58twj5xf4h57s4h0rhy55p5q6nry36glummjexsf4lc446je7y27qdqjv3jhxcmjd9c8g6t0dcxqyjw5qcqp9rzjqgkjyd3q5dv6gllh77kygly9c3kfy0d9xwyjyxsq2nq3c83u5vw4jqqqvuqqqzqqqqqqqqqqqqqqqzsqqcrzjqgkjyd3q5dv6gllh77kygly9c3kfy0d9xwyjyxsq2nq3c83u5vw4jqqqvuqqqpcqqqqqqqqqqqqqqzsqqcrzjqgkjyd3q5dv6gllh77kygly9c3kfy0d9xwyjyxsq2nq3c83u5vw4jqqqvuqqqqgqqqqqqqqqqqqqqzsqqcrzjqgkjyd3q5dv6gllh77kygly9c3kfy0d9xwyjyxsq2nq3c83u5vw4jqqqvuqqqpqqqqqqqqqqqqqqqzsqqc9qxpqysgqtgxcneu0u7xvetgh2kqmey86jssweneat5vx3fppuaphl9v9jweqa2ymczg9klau9jmsm6pm7m3cd28pggp7avuukjqxg63wy2vuvtcpggz4vt'}, error: {'code': 205, 'message': "minflow couldn't find a feasible flow: failed to find a feasible flow: find_admissible_path failed"} ``` Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 2811614 commit afa8875

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

tests/test_renepay.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -321,17 +321,19 @@ def start_channels(connections):
321321
bitcoind.generate_block(1)
322322
sync_blockheight(bitcoind, nodes)
323323
txids = []
324+
channel_ids = []
324325
for src, dst, fundamount in connections:
325-
txids.append(
326-
src.rpc.fundchannel(dst.info["id"], fundamount, announce=True)["txid"]
327-
)
326+
fc = src.rpc.fundchannel(dst.info["id"], fundamount, announce=True)
327+
txids.append(fc["txid"])
328+
channel_ids.append(fc['channel_id'])
328329

329-
# Confirm all channels and wait for them to become usable
330+
# Confirm all channels
330331
bitcoind.generate_block(1, wait_for_mempool=txids)
331332
scids = []
332-
for src, dst, fundamount in connections:
333-
wait_for(lambda: src.channel_state(dst) == "CHANNELD_NORMAL")
334-
scid = src.get_channel_scid(dst)
333+
for conn, channel_id in zip(connections, channel_ids):
334+
src = conn[0]
335+
wait_for(lambda: ['short_channel_id' in c for c in src.rpc.listpeerchannels()['channels'] if c['channel_id'] == channel_id] == [True])
336+
scid = only_one([c['short_channel_id'] for c in src.rpc.listpeerchannels()['channels'] if c['channel_id'] == channel_id])
335337
scids.append(scid)
336338

337339
# Make sure they have all seen block so they don't complain about

0 commit comments

Comments
 (0)