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_BLOCK, | |||||
msg_getdata, | msg_getdata, | ||||
msg_verack, | msg_verack, | ||||
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, | ||||
Show All 18 Lines | def on_addr(self, message): | ||||
self.firstAddrnServices = message.addrs[0].nServices | self.firstAddrnServices = message.addrs[0].nServices | ||||
def wait_for_addr(self, timeout=5): | def wait_for_addr(self, timeout=5): | ||||
def test_function(): return self.last_message.get("addr") | def test_function(): return self.last_message.get("addr") | ||||
wait_until(test_function, timeout=timeout, lock=mininode_lock) | wait_until(test_function, timeout=timeout, lock=mininode_lock) | ||||
def send_getdata_for_block(self, blockhash): | def send_getdata_for_block(self, blockhash): | ||||
getdata_request = msg_getdata() | getdata_request = msg_getdata() | ||||
getdata_request.inv.append(CInv(2, int(blockhash, 16))) | getdata_request.inv.append(CInv(MSG_BLOCK, int(blockhash, 16))) | ||||
self.send_message(getdata_request) | self.send_message(getdata_request) | ||||
class NodeNetworkLimitedTest(BitcoinTestFramework): | class NodeNetworkLimitedTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
self.num_nodes = 3 | self.num_nodes = 3 | ||||
self.extra_args = [['-prune=550', '-addrmantest'], [], []] | self.extra_args = [['-prune=550', '-addrmantest'], [], []] | ||||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |