2016-06-08 12:56:13 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# Copyright (c) 2015-2016 The Bitcoin Core developers
|
|
|
|
# Distributed under the MIT software license, see the accompanying
|
|
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2019-01-07 10:55:35 +01:00
|
|
|
"""Test p2p mempool message.
|
|
|
|
|
|
|
|
Test that nodes are disconnected if they send mempool messages when bloom
|
|
|
|
filters are not enabled.
|
|
|
|
"""
|
2016-06-08 12:56:13 +02:00
|
|
|
|
|
|
|
from test_framework.mininode import *
|
|
|
|
from test_framework.test_framework import BitcoinTestFramework
|
|
|
|
from test_framework.util import *
|
|
|
|
|
|
|
|
class P2PMempoolTests(BitcoinTestFramework):
|
2016-08-17 12:12:55 +02:00
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__()
|
|
|
|
self.setup_clean_chain = True
|
|
|
|
self.num_nodes = 2
|
2016-06-08 12:56:13 +02:00
|
|
|
|
|
|
|
def setup_network(self):
|
2017-05-02 19:10:23 +02:00
|
|
|
self.nodes = [start_node(0, self.options.tmpdir, ["-peerbloomfilters=0"])]
|
2016-06-08 12:56:13 +02:00
|
|
|
|
|
|
|
def run_test(self):
|
|
|
|
#connect a mininode
|
2017-05-02 19:10:23 +02:00
|
|
|
aTestNode = NodeConnCB()
|
2016-06-08 12:56:13 +02:00
|
|
|
node = NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], aTestNode)
|
|
|
|
aTestNode.add_connection(node)
|
|
|
|
NetworkThread().start()
|
|
|
|
aTestNode.wait_for_verack()
|
|
|
|
|
|
|
|
#request mempool
|
2017-05-02 19:10:23 +02:00
|
|
|
aTestNode.send_message(msg_mempool())
|
2016-06-08 12:56:13 +02:00
|
|
|
aTestNode.wait_for_disconnect()
|
|
|
|
|
|
|
|
#mininode must be disconnected at this point
|
|
|
|
assert_equal(len(self.nodes[0].getpeerinfo()), 0)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
P2PMempoolTests().main()
|