Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_node_network_limited.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2017 The Bitcoin Core developers | # Copyright (c) 2017 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Tests NODE_NETWORK_LIMITED. | """Tests NODE_NETWORK_LIMITED. | ||||
Tests that a node configured with -prune=550 signals NODE_NETWORK_LIMITED correctly | Tests that a node configured with -prune=550 signals NODE_NETWORK_LIMITED correctly | ||||
and that it responds to getdata requests for blocks correctly: | and that it responds to getdata requests for blocks correctly: | ||||
- send a block within 288 + 2 of the tip | - send a block within 288 + 2 of the tip | ||||
- disconnect peers who request blocks older than that.""" | - disconnect peers who request blocks older than that.""" | ||||
from test_framework.messages import ( | from test_framework.messages import ( | ||||
CInv, | CInv, | ||||
msg_getdata, | msg_getdata, | ||||
msg_verack, | msg_verack, | ||||
NODE_BITCOIN_CASH, | |||||
NODE_BLOOM, | NODE_BLOOM, | ||||
NODE_NETWORK_LIMITED, | NODE_NETWORK_LIMITED, | ||||
) | ) | ||||
from test_framework.mininode import ( | from test_framework.mininode import ( | ||||
mininode_lock, | mininode_lock, | ||||
P2PInterface, | P2PInterface, | ||||
) | ) | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | class NodeNetworkLimitedTest(BitcoinTestFramework): | ||||
def setup_network(self): | def setup_network(self): | ||||
self.add_nodes(self.num_nodes, self.extra_args) | self.add_nodes(self.num_nodes, self.extra_args) | ||||
self.start_nodes() | self.start_nodes() | ||||
def run_test(self): | def run_test(self): | ||||
node = self.nodes[0].add_p2p_connection(P2PIgnoreInv()) | node = self.nodes[0].add_p2p_connection(P2PIgnoreInv()) | ||||
expected_services = NODE_BLOOM | NODE_BITCOIN_CASH | NODE_NETWORK_LIMITED | expected_services = NODE_BLOOM | NODE_NETWORK_LIMITED | ||||
self.log.info("Check that node has signalled expected services.") | self.log.info("Check that node has signalled expected services.") | ||||
assert_equal(node.nServices, expected_services) | assert_equal(node.nServices, expected_services) | ||||
self.log.info("Check that the localservices is as expected.") | self.log.info("Check that the localservices is as expected.") | ||||
assert_equal(int(self.nodes[0].getnetworkinfo()[ | assert_equal(int(self.nodes[0].getnetworkinfo()[ | ||||
'localservices'], 16), expected_services) | 'localservices'], 16), expected_services) | ||||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |