From 08a2b3b86cf8b609aaeb8b44b29e92faa66204c1 Mon Sep 17 00:00:00 2001 From: Alex Myers Date: Wed, 4 May 2022 16:35:17 -0500 Subject: [PATCH] pytest: test_gossip_ratelimit checks routing graph and squelch --- tests/test_gossip.py | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/tests/test_gossip.py b/tests/test_gossip.py index 8a5f2994b..45b4da92f 100644 --- a/tests/test_gossip.py +++ b/tests/test_gossip.py @@ -1795,7 +1795,7 @@ def test_gossip_ratelimit(node_factory, bitcoind): """Check that we ratelimit incoming gossip. We create a partitioned network, in which the first partition consisting - of l1 and l2 is used to create an on-chain footprint and twe then feed + of l1 and l2 is used to create an on-chain footprint and we then feed canned gossip to the other partition consisting of l3. l3 should ratelimit the incoming gossip. @@ -1863,13 +1863,32 @@ def test_gossip_ratelimit(node_factory, bitcoind): '0102c479b7684b9db496b844f6925f4ffd8a27c5840a020d1b537623c1545dcd8e195776381bbf51213e541a853a4a49a0faf84316e7ccca5e7074901a96bbabe04e06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f00006700000100015d77400201010006000000000000000000000014000003eb000000003b023380', # timestamp=1568096259, fee_proportional_millionths=1004 '01024b866012d995d3d7aec7b7218a283de2d03492dbfa21e71dd546ec2e36c3d4200453420aa02f476f99c73fe1e223ea192f5fa544b70a8319f2a216f1513d503d06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f00006700000100015d77400301010006000000000000000000000014000003ec000000003b023380', - # update 5 marks you as a nasty spammer! + # update 5 marks you as a nasty spammer, but we listen to you anyway now! fee_proportional_millionths=1005 '01025b5b5a0daed874ab02bd3356d38190ff46bbaf5f10db5067da70f3ca203480ca78059e6621c6143f3da4e454d0adda6d01a9980ed48e71ccd0c613af73570a7106226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f00006700000100015d77400401010006000000000000000000000014000003ed000000003b023380' ], timeout=TIMEOUT ) + # Rate limited channel_update okay to use in routing graph. + wait_for(lambda: channel_fees(l3) == [1005]) + # but should be flagged so we don't propagate to the network. + assert(l3.daemon.is_in_log("Spammy update for 103x1x1/1 flagged")) - wait_for(lambda: channel_fees(l3) == [1004]) + # ask for a gossip sync + raw = subprocess.run(['devtools/gossipwith', + '--initial-sync', + '--timeout-after={}'.format(1), + '--hex', + '{}@localhost:{}'.format(l3.info['id'], l3.port)], + check=True, + timeout=TIMEOUT, stdout=subprocess.PIPE).stdout + # The last message is the most recent channel update. + message = raw.decode('utf-8').split()[-1] + decoded = subprocess.run(['devtools/decodemsg', message], + check=True, + timeout=TIMEOUT, + stdout=subprocess.PIPE).stdout.decode('utf8') + # Used in routing graph, but not passed to gossip peers. + assert("fee_proportional_millionths=1005" not in decoded) # 24 seconds later, it will accept another. l3.rpc.call('dev-gossip-set-time', [1568096251 + 24]) @@ -1882,6 +1901,20 @@ def test_gossip_ratelimit(node_factory, bitcoind): check=True, timeout=TIMEOUT) wait_for(lambda: channel_fees(l3) == [1006]) + raw = subprocess.run(['devtools/gossipwith', + '--initial-sync', + '--timeout-after={}'.format(1), + '--hex', + '{}@localhost:{}'.format(l3.info['id'], l3.port)], + check=True, + timeout=TIMEOUT, stdout=subprocess.PIPE).stdout + message = raw.decode('utf-8').split()[-1] + decoded = subprocess.run(['devtools/decodemsg', message], + check=True, + timeout=TIMEOUT, + stdout=subprocess.PIPE).stdout.decode('utf8') + + assert("fee_proportional_millionths=1006" in decoded) def check_socket(ip_addr, port):