mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-21 16:14:23 +01:00
pytest: protect against bad gossip messages from mining confirms too fast.
If we fund a channel between two nodes, then mine all the blocks to announce it, any other nodes may see the announcement before the blocks, causing CI to complain about "bad gossip": ``` lightningd-4: 2022-01-25T22:33:25.468Z DEBUG 032cf15d1ad9c4a08d26eab1918f732d8ef8fdc6abb9640bf3db174372c491304e-gossipd: Ignoring future channel_announcment for 113x1x1 (current block 112) lightningd-4: 2022-01-25T22:33:25.468Z DEBUG 032cf15d1ad9c4a08d26eab1918f732d8ef8fdc6abb9640bf3db174372c491304e-gossipd: Bad gossip order: WIRE_CHANNEL_UPDATE before announcement 113x1x1/0 lightningd-4: 2022-01-25T22:33:25.468Z DEBUG 032cf15d1ad9c4a08d26eab1918f732d8ef8fdc6abb9640bf3db174372c491304e-gossipd: Bad gossip order: WIRE_CHANNEL_UPDATE before announcement 113x1x1/1 lightningd-4: 2022-01-25T22:33:25.468Z DEBUG 032cf15d1ad9c4a08d26eab1918f732d8ef8fdc6abb9640bf3db174372c491304e-gossipd: Bad gossip order: WIRE_NODE_ANNOUNCEMENT before announcement 032cf15d1ad9c4a08d26eab1918f732d8ef8fdc6abb9640bf3db174372c491304e ``` Add a new helper for this case, and use it where there are more than 2 nodes. Cleans up test_routing_gossip and a few other places which did this manually. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -8,7 +8,7 @@ from pyln.proto.onion import TlvPayload
|
||||
from pyln.testing.utils import EXPERIMENTAL_DUAL_FUND, FUNDAMOUNT
|
||||
from utils import (
|
||||
DEVELOPER, wait_for, only_one, sync_blockheight, TIMEOUT,
|
||||
EXPERIMENTAL_FEATURES, env, VALGRIND
|
||||
EXPERIMENTAL_FEATURES, env, VALGRIND, mine_funding_to_announce
|
||||
)
|
||||
import copy
|
||||
import os
|
||||
@@ -182,7 +182,7 @@ def test_pay_exclude_node(node_factory, bitcoind):
|
||||
scid14, _ = l1.fundchannel(l4, 10**6, wait_for_active=False)
|
||||
scid45, _ = l4.fundchannel(l5, 10**6, wait_for_active=False)
|
||||
scid53, _ = l5.fundchannel(l3, 10**6, wait_for_active=False)
|
||||
bitcoind.generate_block(5)
|
||||
mine_funding_to_announce(bitcoind, [l1, l2, l3, l4, l5])
|
||||
|
||||
l1.daemon.wait_for_logs([r'update for channel {}/0 now ACTIVE'
|
||||
.format(scid14),
|
||||
@@ -1137,7 +1137,7 @@ def test_forward_different_fees_and_cltv(node_factory, bitcoind):
|
||||
|
||||
c1, _ = l1.fundchannel(l2, 10**6)
|
||||
c2, _ = l2.fundchannel(l3, 10**6)
|
||||
bitcoind.generate_block(5)
|
||||
mine_funding_to_announce(bitcoind, [l1, l2, l3])
|
||||
|
||||
# Make sure l1 has seen announce for all channels.
|
||||
l1.wait_channel_active(c1)
|
||||
@@ -1244,7 +1244,7 @@ def test_forward_pad_fees_and_cltv(node_factory, bitcoind):
|
||||
|
||||
c1, _ = l1.fundchannel(l2, 10**6)
|
||||
c2, _ = l2.fundchannel(l3, 10**6)
|
||||
bitcoind.generate_block(5)
|
||||
mine_funding_to_announce(bitcoind, [l1, l2, l3])
|
||||
|
||||
# Make sure l1 has seen announce for all channels.
|
||||
l1.wait_channel_active(c1)
|
||||
@@ -1290,9 +1290,7 @@ def test_forward_stats(node_factory, bitcoind):
|
||||
l2.openchannel(l4, 10**6, wait_for_announce=False)
|
||||
l2.openchannel(l5, 10**6, wait_for_announce=False)
|
||||
|
||||
bitcoind.generate_block(1)
|
||||
sync_blockheight(bitcoind, [l1, l2, l3, l4, l5])
|
||||
bitcoind.generate_block(5)
|
||||
mine_funding_to_announce(bitcoind, [l1, l2, l3, l4, l5])
|
||||
|
||||
wait_for(lambda: len(l1.rpc.listchannels()['channels']) == 8)
|
||||
|
||||
@@ -1419,7 +1417,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
|
||||
l6.fundchannel(l1, 10**6)
|
||||
|
||||
# Make sure routes finalized.
|
||||
bitcoind.generate_block(5)
|
||||
mine_funding_to_announce(bitcoind, [l1, l2, l3, l4, l5, l6])
|
||||
l1.wait_channel_active(c23)
|
||||
l1.wait_channel_active(c24)
|
||||
l1.wait_channel_active(c25)
|
||||
@@ -1702,7 +1700,7 @@ def test_pay_retry(node_factory, bitcoind, executor, chainparams):
|
||||
scid35, _ = l3.fundchannel(l5, 10**6, wait_for_active=False)
|
||||
|
||||
# Make sure l1 sees all 7 channels
|
||||
bitcoind.generate_block(5)
|
||||
mine_funding_to_announce(bitcoind, [l1, l2, l3, l4, l5])
|
||||
wait_for(lambda: len(l1.rpc.listchannels()['channels']) == 14)
|
||||
|
||||
# Exhaust shortcut channels one at a time, to force retries.
|
||||
@@ -1763,7 +1761,7 @@ def test_pay_routeboost(node_factory, bitcoind, compat):
|
||||
scidl2l3, _ = l2.fundchannel(l3, 10**6)
|
||||
|
||||
# Make sure l1 knows about the 2->3 channel.
|
||||
bitcoind.generate_block(5)
|
||||
mine_funding_to_announce(bitcoind, [l1, l2, l3, l4, l5])
|
||||
l1.daemon.wait_for_logs([r'update for channel {}/0 now ACTIVE'
|
||||
.format(scidl2l3),
|
||||
r'update for channel {}/1 now ACTIVE'
|
||||
@@ -2030,8 +2028,7 @@ def test_setchannelfee_state(node_factory, bitcoind):
|
||||
# cid = result['channels'][0]['channel_id']
|
||||
|
||||
# test routing correct new fees once routing is established
|
||||
bitcoind.generate_block(6)
|
||||
sync_blockheight(bitcoind, [l0, l1, l2])
|
||||
mine_funding_to_announce(bitcoind, [l0, l1, l2])
|
||||
|
||||
l0.wait_for_route(l2)
|
||||
inv = l2.rpc.invoice(100000, 'test_setchannelfee_state', 'desc')['bolt11']
|
||||
@@ -2595,7 +2592,7 @@ def test_tlv_or_legacy(node_factory, bitcoind):
|
||||
l3.daemon.wait_for_log("Got onion.*'type': 'tlv'")
|
||||
|
||||
# We need 5 more blocks to announce l1->l2 channel.
|
||||
bitcoind.generate_block(5)
|
||||
mine_funding_to_announce(bitcoind, [l1, l2, l3])
|
||||
|
||||
# Make sure l1 knows about l2
|
||||
wait_for(lambda: 'alias' in l1.rpc.listnodes(l2.info['id'])['nodes'][0])
|
||||
@@ -2828,7 +2825,7 @@ def test_partial_payment(node_factory, bitcoind, executor):
|
||||
scid24, _ = l2.fundchannel(l4, 100000)
|
||||
l3.rpc.connect(l4.info['id'], 'localhost', l4.port)
|
||||
scid34, _ = l3.fundchannel(l4, 100000)
|
||||
bitcoind.generate_block(5)
|
||||
mine_funding_to_announce(bitcoind, [l1, l2, l3, l4])
|
||||
|
||||
# Wait until l1 knows about all channels.
|
||||
wait_for(lambda: len(l1.rpc.listchannels()['channels']) == 8)
|
||||
@@ -3633,7 +3630,7 @@ def test_mpp_adaptive(node_factory, bitcoind):
|
||||
assert(c12['spendable_msat'].millisatoshis < amt)
|
||||
assert(c34['spendable_msat'].millisatoshis < amt)
|
||||
|
||||
bitcoind.generate_block(5)
|
||||
mine_funding_to_announce(bitcoind, [l1, l2, l3, l4])
|
||||
wait_for(lambda: len(l1.rpc.listchannels()['channels']) == 8)
|
||||
|
||||
inv = l4.rpc.invoice(
|
||||
@@ -3728,8 +3725,7 @@ def test_mpp_presplit_routehint_conflict(node_factory, bitcoind):
|
||||
l2.rpc.connect(l3.info['id'], 'localhost', l3.port)
|
||||
l2.fundchannel(l3, 10**7, announce_channel=False)
|
||||
|
||||
bitcoind.generate_block(6)
|
||||
sync_blockheight(bitcoind, [l1, l2, l3])
|
||||
mine_funding_to_announce(bitcoind, [l1, l2, l3])
|
||||
|
||||
# Wait for l3 to learn about l1->l2, otherwise it will think
|
||||
# l2 is a deadend and not add it to the routehint.
|
||||
@@ -3894,8 +3890,7 @@ def test_mpp_waitblockheight_routehint_conflict(node_factory, bitcoind, executor
|
||||
l2.rpc.connect(l3.info['id'], 'localhost', l3.port)
|
||||
l2.fundchannel(l3, 10**7, announce_channel=False)
|
||||
|
||||
bitcoind.generate_block(6)
|
||||
sync_blockheight(bitcoind, [l1, l2, l3])
|
||||
mine_funding_to_announce(bitcoind, [l1, l2, l3])
|
||||
|
||||
# Wait for l3 to learn about l1->l2, otherwise it will think
|
||||
# l2 is a deadend and not add it to the routehint.
|
||||
@@ -4017,8 +4012,7 @@ def test_mpp_interference_2(node_factory, bitcoind, executor):
|
||||
l3.fundchannel(l6, int((unit * 6).to_satoshi()), announce_channel=False)
|
||||
|
||||
# Now wait for the buyers to learn the entire public network.
|
||||
bitcoind.generate_block(5)
|
||||
sync_blockheight(bitcoind, [l1, l2, l3, l4, l5, l6, l7])
|
||||
mine_funding_to_announce(bitcoind, [l1, l2, l3, l4, l5, l6, l7])
|
||||
for channel in public_network:
|
||||
wait_for(lambda: len(l2.rpc.listchannels(channel)['channels']) == 2)
|
||||
wait_for(lambda: len(l3.rpc.listchannels(channel)['channels']) == 2)
|
||||
@@ -4120,8 +4114,7 @@ def test_mpp_overload_payee(node_factory, bitcoind):
|
||||
l5.fundbalancedchannel(l6, amt)]
|
||||
|
||||
# Ensure l1 knows the entire public network.
|
||||
bitcoind.generate_block(5)
|
||||
sync_blockheight(bitcoind, [l1, l2, l3, l4, l5, l6])
|
||||
mine_funding_to_announce(bitcoind, [l1, l2, l3, l4, l5, l6])
|
||||
for c in public_network:
|
||||
wait_for(lambda: len(l1.rpc.listchannels(c)['channels']) >= 2)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user