mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 23:54:22 +01:00
pytest: ignore occasional bad gossip in reorg tests.
It can happen, as expected when we reorg and update for a now-invalid channel. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -135,7 +135,7 @@ def node_factory(request, directory, test_name, bitcoind, executor):
|
|||||||
err_count += checkReconnect(node)
|
err_count += checkReconnect(node)
|
||||||
check_errors(request, err_count, "{} nodes had unexpected reconnections")
|
check_errors(request, err_count, "{} nodes had unexpected reconnections")
|
||||||
|
|
||||||
for node in nf.nodes:
|
for node in [n for n in nf.nodes if not n.allow_bad_gossip]:
|
||||||
err_count += checkBadGossip(node)
|
err_count += checkBadGossip(node)
|
||||||
check_errors(request, err_count, "{} nodes had bad gossip messages")
|
check_errors(request, err_count, "{} nodes had bad gossip messages")
|
||||||
|
|
||||||
|
|||||||
@@ -843,8 +843,9 @@ def test_funding_reorg_private(node_factory, bitcoind):
|
|||||||
"""Change funding tx height after lockin, between node restart.
|
"""Change funding tx height after lockin, between node restart.
|
||||||
"""
|
"""
|
||||||
# Rescan to detect reorg at restart and may_reconnect so channeld
|
# Rescan to detect reorg at restart and may_reconnect so channeld
|
||||||
# will restart
|
# will restart. Reorg can cause bad gossip msg.
|
||||||
opts = {'funding-confirms': 2, 'rescan': 10, 'may_reconnect': True}
|
opts = {'funding-confirms': 2, 'rescan': 10, 'may_reconnect': True,
|
||||||
|
'allow_bad_gossip': True}
|
||||||
l1, l2 = node_factory.line_graph(2, fundchannel=False, opts=opts)
|
l1, l2 = node_factory.line_graph(2, fundchannel=False, opts=opts)
|
||||||
l1.fundwallet(10000000)
|
l1.fundwallet(10000000)
|
||||||
sync_blockheight(bitcoind, [l1]) # height 102
|
sync_blockheight(bitcoind, [l1]) # height 102
|
||||||
@@ -870,9 +871,8 @@ def test_funding_reorg_private(node_factory, bitcoind):
|
|||||||
wait_for(lambda: [c['active'] for c in l2.rpc.listchannels('106x1x0')['channels']] == [False, False])
|
wait_for(lambda: [c['active'] for c in l2.rpc.listchannels('106x1x0')['channels']] == [False, False])
|
||||||
wait_for(lambda: [c['active'] for c in l2.rpc.listchannels('108x1x0')['channels']] == [True, True])
|
wait_for(lambda: [c['active'] for c in l2.rpc.listchannels('108x1x0')['channels']] == [True, True])
|
||||||
|
|
||||||
l1.rpc.close(l2.info['id']) # to ignore `Bad gossip order` error in killall
|
l1.rpc.close(l2.info['id'])
|
||||||
wait_for(lambda: len(bitcoind.rpc.getrawmempool()) > 0)
|
bitcoind.generate_block(1, True)
|
||||||
bitcoind.generate_block(1)
|
|
||||||
l1.daemon.wait_for_log(r'Deleting channel')
|
l1.daemon.wait_for_log(r'Deleting channel')
|
||||||
l2.daemon.wait_for_log(r'Deleting channel')
|
l2.daemon.wait_for_log(r'Deleting channel')
|
||||||
|
|
||||||
@@ -881,8 +881,8 @@ def test_funding_reorg_private(node_factory, bitcoind):
|
|||||||
def test_funding_reorg_remote_lags(node_factory, bitcoind):
|
def test_funding_reorg_remote_lags(node_factory, bitcoind):
|
||||||
"""Nodes may disagree about short_channel_id before channel announcement
|
"""Nodes may disagree about short_channel_id before channel announcement
|
||||||
"""
|
"""
|
||||||
# may_reconnect so channeld will restart
|
# may_reconnect so channeld will restart; bad gossip can happen due to reorg
|
||||||
opts = {'funding-confirms': 1, 'may_reconnect': True}
|
opts = {'funding-confirms': 1, 'may_reconnect': True, 'allow_bad_gossip': True}
|
||||||
l1, l2 = node_factory.line_graph(2, fundchannel=False, opts=opts)
|
l1, l2 = node_factory.line_graph(2, fundchannel=False, opts=opts)
|
||||||
l1.fundwallet(10000000)
|
l1.fundwallet(10000000)
|
||||||
sync_blockheight(bitcoind, [l1]) # height 102
|
sync_blockheight(bitcoind, [l1]) # height 102
|
||||||
@@ -916,7 +916,7 @@ def test_funding_reorg_remote_lags(node_factory, bitcoind):
|
|||||||
'CHANNELD_NORMAL:Reconnected, and reestablished.',
|
'CHANNELD_NORMAL:Reconnected, and reestablished.',
|
||||||
'CHANNELD_NORMAL:Funding transaction locked. Channel announced.'])
|
'CHANNELD_NORMAL:Funding transaction locked. Channel announced.'])
|
||||||
|
|
||||||
l1.rpc.close(l2.info['id']) # to ignore `Bad gossip order` error in killall
|
l1.rpc.close(l2.info['id'])
|
||||||
bitcoind.generate_block(1, True)
|
bitcoind.generate_block(1, True)
|
||||||
l1.daemon.wait_for_log(r'Deleting channel')
|
l1.daemon.wait_for_log(r'Deleting channel')
|
||||||
l2.daemon.wait_for_log(r'Deleting channel')
|
l2.daemon.wait_for_log(r'Deleting channel')
|
||||||
|
|||||||
@@ -454,7 +454,7 @@ class LightningD(TailableProc):
|
|||||||
|
|
||||||
|
|
||||||
class LightningNode(object):
|
class LightningNode(object):
|
||||||
def __init__(self, daemon, rpc, btc, executor, may_fail=False, may_reconnect=False, allow_broken_log=False):
|
def __init__(self, daemon, rpc, btc, executor, may_fail=False, may_reconnect=False, allow_broken_log=False, allow_bad_gossip=False):
|
||||||
self.rpc = rpc
|
self.rpc = rpc
|
||||||
self.daemon = daemon
|
self.daemon = daemon
|
||||||
self.bitcoin = btc
|
self.bitcoin = btc
|
||||||
@@ -462,6 +462,7 @@ class LightningNode(object):
|
|||||||
self.may_fail = may_fail
|
self.may_fail = may_fail
|
||||||
self.may_reconnect = may_reconnect
|
self.may_reconnect = may_reconnect
|
||||||
self.allow_broken_log = allow_broken_log
|
self.allow_broken_log = allow_broken_log
|
||||||
|
self.allow_bad_gossip = allow_bad_gossip
|
||||||
|
|
||||||
def connect(self, remote_node):
|
def connect(self, remote_node):
|
||||||
self.rpc.connect(remote_node.info['id'], '127.0.0.1', remote_node.daemon.port)
|
self.rpc.connect(remote_node.info['id'], '127.0.0.1', remote_node.daemon.port)
|
||||||
@@ -787,6 +788,7 @@ class NodeFactory(object):
|
|||||||
'log_all_io',
|
'log_all_io',
|
||||||
'feerates',
|
'feerates',
|
||||||
'wait_for_bitcoind_sync',
|
'wait_for_bitcoind_sync',
|
||||||
|
'allow_bad_gossip'
|
||||||
]
|
]
|
||||||
node_opts = {k: v for k, v in opts.items() if k in node_opt_keys}
|
node_opts = {k: v for k, v in opts.items() if k in node_opt_keys}
|
||||||
cli_opts = {k: v for k, v in opts.items() if k not in node_opt_keys}
|
cli_opts = {k: v for k, v in opts.items() if k not in node_opt_keys}
|
||||||
@@ -830,7 +832,7 @@ class NodeFactory(object):
|
|||||||
may_reconnect=False, random_hsm=False,
|
may_reconnect=False, random_hsm=False,
|
||||||
feerates=(15000, 7500, 3750), start=True, log_all_io=False,
|
feerates=(15000, 7500, 3750), start=True, log_all_io=False,
|
||||||
dbfile=None, node_id=None, allow_broken_log=False,
|
dbfile=None, node_id=None, allow_broken_log=False,
|
||||||
wait_for_bitcoind_sync=True):
|
wait_for_bitcoind_sync=True, allow_bad_gossip=False):
|
||||||
if not node_id:
|
if not node_id:
|
||||||
node_id = self.get_node_id()
|
node_id = self.get_node_id()
|
||||||
|
|
||||||
@@ -873,7 +875,8 @@ class NodeFactory(object):
|
|||||||
rpc = LightningRpc(socket_path, self.executor)
|
rpc = LightningRpc(socket_path, self.executor)
|
||||||
|
|
||||||
node = LightningNode(daemon, rpc, self.bitcoind, self.executor, may_fail=may_fail,
|
node = LightningNode(daemon, rpc, self.bitcoind, self.executor, may_fail=may_fail,
|
||||||
may_reconnect=may_reconnect, allow_broken_log=allow_broken_log)
|
may_reconnect=may_reconnect, allow_broken_log=allow_broken_log,
|
||||||
|
allow_bad_gossip=allow_bad_gossip)
|
||||||
|
|
||||||
# Regtest estimatefee are unusable, so override.
|
# Regtest estimatefee are unusable, so override.
|
||||||
node.set_feerates(feerates, False)
|
node.set_feerates(feerates, False)
|
||||||
|
|||||||
Reference in New Issue
Block a user