Skip to content

Commit 4ef80f0

Browse files
committed
[test] sending invalid msgs to node with bloomfilters=0 causes disconnect
-A node with bloomfilters disabled should disconnect peers that send msg_mempool, msg_filterload, or msg_filteradd. -Renamed the test because it now has a wider scope and msg_mempool's actual functionality makes more sense for p2p_filter.py.
1 parent 497a619 commit 4ef80f0

File tree

3 files changed

+44
-35
lines changed

3 files changed

+44
-35
lines changed

test/functional/p2p_mempool.py

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) 2015-2018 The Bitcoin Core developers
3+
# Distributed under the MIT software license, see the accompanying
4+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
"""Test invalid p2p messages for nodes with bloom filters disabled.
6+
7+
Test that, when bloom filters are not enabled, nodes are disconnected if:
8+
1. They send a p2p mempool message
9+
2. They send a p2p filterload message
10+
3. They send a p2p filteradd message
11+
"""
12+
13+
from test_framework.messages import msg_mempool, msg_filteradd, msg_filterload
14+
from test_framework.mininode import P2PInterface
15+
from test_framework.test_framework import BitcoinTestFramework
16+
from test_framework.util import assert_equal
17+
18+
19+
class P2PNobloomfilterMessages(BitcoinTestFramework):
20+
def set_test_params(self):
21+
self.setup_clean_chain = True
22+
self.num_nodes = 1
23+
self.extra_args = [["-peerbloomfilters=0"]]
24+
25+
def test_message_causes_disconnect(self, message):
26+
# Add a p2p connection that sends a message and check that it disconnects
27+
peer = self.nodes[0].add_p2p_connection(P2PInterface())
28+
peer.send_message(message)
29+
peer.wait_for_disconnect()
30+
assert_equal(len(self.nodes[0].getpeerinfo()), 0)
31+
32+
def run_test(self):
33+
self.log.info("Test that node is disconnected if it sends mempool message")
34+
self.test_message_causes_disconnect(msg_mempool())
35+
36+
self.log.info("Test that node is disconnected if it sends filterload message")
37+
self.test_message_causes_disconnect(msg_filterload())
38+
39+
self.log.info("Test that node is disconnected if it sends filteradd message")
40+
self.test_message_causes_disconnect(msg_filteradd(data=b'\xcc'))
41+
42+
if __name__ == '__main__':
43+
P2PNobloomfilterMessages().main()

test/functional/test_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
'wallet_keypool.py',
165165
'wallet_keypool.py --descriptors',
166166
'wallet_descriptor.py',
167-
'p2p_mempool.py',
167+
'p2p_nobloomfilter_messages.py',
168168
'p2p_filter.py',
169169
'rpc_setban.py',
170170
'p2p_blocksonly.py',

0 commit comments

Comments
 (0)