[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.
This commit is contained in:
parent
497a619386
commit
4ef80f0827
|
@ -1,34 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
# Copyright (c) 2015-2018 The Bitcoin Core developers
|
|
||||||
# Distributed under the MIT software license, see the accompanying
|
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
||||||
"""Test p2p mempool message.
|
|
||||||
|
|
||||||
Test that nodes are disconnected if they send mempool messages when bloom
|
|
||||||
filters are not enabled.
|
|
||||||
"""
|
|
||||||
|
|
||||||
from test_framework.messages import msg_mempool
|
|
||||||
from test_framework.mininode import P2PInterface
|
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
|
||||||
from test_framework.util import assert_equal
|
|
||||||
|
|
||||||
class P2PMempoolTests(BitcoinTestFramework):
|
|
||||||
def set_test_params(self):
|
|
||||||
self.setup_clean_chain = True
|
|
||||||
self.num_nodes = 1
|
|
||||||
self.extra_args = [["-peerbloomfilters=0"]]
|
|
||||||
|
|
||||||
def run_test(self):
|
|
||||||
# Add a p2p connection
|
|
||||||
self.nodes[0].add_p2p_connection(P2PInterface())
|
|
||||||
|
|
||||||
#request mempool
|
|
||||||
self.nodes[0].p2p.send_message(msg_mempool())
|
|
||||||
self.nodes[0].p2p.wait_for_disconnect()
|
|
||||||
|
|
||||||
#mininode must be disconnected at this point
|
|
||||||
assert_equal(len(self.nodes[0].getpeerinfo()), 0)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
P2PMempoolTests().main()
|
|
43
test/functional/p2p_nobloomfilter_messages.py
Executable file
43
test/functional/p2p_nobloomfilter_messages.py
Executable file
|
@ -0,0 +1,43 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# Copyright (c) 2015-2018 The Bitcoin Core developers
|
||||||
|
# Distributed under the MIT software license, see the accompanying
|
||||||
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
"""Test invalid p2p messages for nodes with bloom filters disabled.
|
||||||
|
|
||||||
|
Test that, when bloom filters are not enabled, nodes are disconnected if:
|
||||||
|
1. They send a p2p mempool message
|
||||||
|
2. They send a p2p filterload message
|
||||||
|
3. They send a p2p filteradd message
|
||||||
|
"""
|
||||||
|
|
||||||
|
from test_framework.messages import msg_mempool, msg_filteradd, msg_filterload
|
||||||
|
from test_framework.mininode import P2PInterface
|
||||||
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
|
from test_framework.util import assert_equal
|
||||||
|
|
||||||
|
|
||||||
|
class P2PNobloomfilterMessages(BitcoinTestFramework):
|
||||||
|
def set_test_params(self):
|
||||||
|
self.setup_clean_chain = True
|
||||||
|
self.num_nodes = 1
|
||||||
|
self.extra_args = [["-peerbloomfilters=0"]]
|
||||||
|
|
||||||
|
def test_message_causes_disconnect(self, message):
|
||||||
|
# Add a p2p connection that sends a message and check that it disconnects
|
||||||
|
peer = self.nodes[0].add_p2p_connection(P2PInterface())
|
||||||
|
peer.send_message(message)
|
||||||
|
peer.wait_for_disconnect()
|
||||||
|
assert_equal(len(self.nodes[0].getpeerinfo()), 0)
|
||||||
|
|
||||||
|
def run_test(self):
|
||||||
|
self.log.info("Test that node is disconnected if it sends mempool message")
|
||||||
|
self.test_message_causes_disconnect(msg_mempool())
|
||||||
|
|
||||||
|
self.log.info("Test that node is disconnected if it sends filterload message")
|
||||||
|
self.test_message_causes_disconnect(msg_filterload())
|
||||||
|
|
||||||
|
self.log.info("Test that node is disconnected if it sends filteradd message")
|
||||||
|
self.test_message_causes_disconnect(msg_filteradd(data=b'\xcc'))
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
P2PNobloomfilterMessages().main()
|
|
@ -164,7 +164,7 @@ BASE_SCRIPTS = [
|
||||||
'wallet_keypool.py',
|
'wallet_keypool.py',
|
||||||
'wallet_keypool.py --descriptors',
|
'wallet_keypool.py --descriptors',
|
||||||
'wallet_descriptor.py',
|
'wallet_descriptor.py',
|
||||||
'p2p_mempool.py',
|
'p2p_nobloomfilter_messages.py',
|
||||||
'p2p_filter.py',
|
'p2p_filter.py',
|
||||||
'rpc_setban.py',
|
'rpc_setban.py',
|
||||||
'p2p_blocksonly.py',
|
'p2p_blocksonly.py',
|
||||||
|
|
Loading…
Reference in a new issue