Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_node_network_limited.py
Show All 11 Lines | from test_framework.messages import ( | ||||
CInv, | CInv, | ||||
MSG_BLOCK, | 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, | p2p_lock, | ||||
P2PInterface, | P2PInterface, | ||||
) | ) | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import ( | from test_framework.util import ( | ||||
assert_equal, | assert_equal, | ||||
connect_nodes, | connect_nodes, | ||||
disconnect_nodes, | disconnect_nodes, | ||||
wait_until, | wait_until, | ||||
) | ) | ||||
class P2PIgnoreInv(P2PInterface): | class P2PIgnoreInv(P2PInterface): | ||||
firstAddrnServices = 0 | firstAddrnServices = 0 | ||||
def on_inv(self, message): | def on_inv(self, message): | ||||
# The node will send us invs for other blocks. Ignore them. | # The node will send us invs for other blocks. Ignore them. | ||||
pass | pass | ||||
def on_addr(self, message): | 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=p2p_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(MSG_BLOCK, 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): | ||||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |