diff --git a/tests/fixtures.py b/tests/fixtures.py index bcd88a705..7e41cf27f 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -135,7 +135,7 @@ def node_factory(request, directory, test_name, bitcoind, executor): err_count += checkReconnect(node) 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) check_errors(request, err_count, "{} nodes had bad gossip messages") diff --git a/tests/test_misc.py b/tests/test_misc.py index ed9ba8fd6..0707ce610 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -843,8 +843,9 @@ def test_funding_reorg_private(node_factory, bitcoind): """Change funding tx height after lockin, between node restart. """ # Rescan to detect reorg at restart and may_reconnect so channeld - # will restart - opts = {'funding-confirms': 2, 'rescan': 10, 'may_reconnect': True} + # will restart. Reorg can cause bad gossip msg. + 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.fundwallet(10000000) 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('108x1x0')['channels']] == [True, True]) - l1.rpc.close(l2.info['id']) # to ignore `Bad gossip order` error in killall - wait_for(lambda: len(bitcoind.rpc.getrawmempool()) > 0) - bitcoind.generate_block(1) + l1.rpc.close(l2.info['id']) + bitcoind.generate_block(1, True) l1.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): """Nodes may disagree about short_channel_id before channel announcement """ - # may_reconnect so channeld will restart - opts = {'funding-confirms': 1, 'may_reconnect': True} + # may_reconnect so channeld will restart; bad gossip can happen due to reorg + opts = {'funding-confirms': 1, 'may_reconnect': True, 'allow_bad_gossip': True} l1, l2 = node_factory.line_graph(2, fundchannel=False, opts=opts) l1.fundwallet(10000000) 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: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) l1.daemon.wait_for_log(r'Deleting channel') l2.daemon.wait_for_log(r'Deleting channel') diff --git a/tests/utils.py b/tests/utils.py index 560a8762e..8acff465a 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -454,7 +454,7 @@ class LightningD(TailableProc): 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.daemon = daemon self.bitcoin = btc @@ -462,6 +462,7 @@ class LightningNode(object): self.may_fail = may_fail self.may_reconnect = may_reconnect self.allow_broken_log = allow_broken_log + self.allow_bad_gossip = allow_bad_gossip def connect(self, remote_node): 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', 'feerates', 'wait_for_bitcoind_sync', + 'allow_bad_gossip' ] 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} @@ -830,7 +832,7 @@ class NodeFactory(object): may_reconnect=False, random_hsm=False, feerates=(15000, 7500, 3750), start=True, log_all_io=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: node_id = self.get_node_id() @@ -873,7 +875,8 @@ class NodeFactory(object): rpc = LightningRpc(socket_path, self.executor) 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. node.set_feerates(feerates, False)