From 6c54a22d63baa2ba297795a4c90231e4f38dcecb Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 24 Sep 2018 11:11:37 +0930 Subject: [PATCH] pytest: make test_node_reannounce check for redundant announce (xfail). Signed-off-by: Rusty Russell --- tests/test_gossip.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/tests/test_gossip.py b/tests/test_gossip.py index 6db3e66bf..77bddaa46 100644 --- a/tests/test_gossip.py +++ b/tests/test_gossip.py @@ -4,6 +4,7 @@ from utils import wait_for, TIMEOUT, only_one import json import logging import os +import pytest import struct import subprocess import time @@ -842,19 +843,34 @@ def test_gossip_store_load(node_factory): assert not l1.daemon.is_in_log('gossip_store.*truncating') +@pytest.mark.xfail(strict=True) +@unittest.skipIf(not DEVELOPER, "Needs fast gossip propagation") def test_node_reannounce(node_factory, bitcoind): "Test that we reannounce a node when parameters change" - l1, l2, l3 = node_factory.line_graph(3, opts={'may_reconnect': True}) - + l1, l2 = node_factory.line_graph(2, opts={'may_reconnect': True, + 'log_all_io': True}) bitcoind.generate_block(5) - wait_for(lambda: l3.rpc.listnodes(l1.info['id'])['nodes'] != []) - assert only_one(l3.rpc.listnodes(l1.info['id'])['nodes'])['alias'].startswith('JUNIORBEAM') + # Wait for node_announcement for l1. + l2.daemon.wait_for_log('\[IN\] 0101.*{}'.format(l1.info['id'])) + # Wait for it to process it. + wait_for(lambda: l2.rpc.listnodes(l1.info['id'])['nodes'] != []) + wait_for(lambda: 'alias' in only_one(l2.rpc.listnodes(l1.info['id'])['nodes'])) + assert only_one(l2.rpc.listnodes(l1.info['id'])['nodes'])['alias'].startswith('JUNIORBEAM') l1.stop() l1.daemon.opts['alias'] = 'SENIORBEAM' l1.start() - wait_for(lambda: only_one(l3.rpc.listnodes(l1.info['id'])['nodes'])['alias'] == 'SENIORBEAM') + + # Wait for l1 to send us its own node_announcement. + nannouncement = l2.daemon.wait_for_log('{}.*\[IN\] 0101.*{}'.format(l1.info['id'], l1.info['id'])).split('[IN] ')[1] + wait_for(lambda: only_one(l2.rpc.listnodes(l1.info['id'])['nodes'])['alias'] == 'SENIORBEAM') + + # Restart should re-xmit exact same update on reconnect. + l1.restart() + + # l1 should retransmit it exactly the same (no timestamp change!) + l2.daemon.wait_for_log('{}.*\[IN\] {}'.format(l1.info['id'], nannouncement)) def test_gossipwith(node_factory):