Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_maxuploadtarget.py
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# p2p_conns[0] will only request old blocks | # p2p_conns[0] will only request old blocks | ||||
# p2p_conns[1] will only request new blocks | # p2p_conns[1] will only request new blocks | ||||
# p2p_conns[2] will test resetting the counters | # p2p_conns[2] will test resetting the counters | ||||
p2p_conns = [] | p2p_conns = [] | ||||
for _ in range(3): | for _ in range(3): | ||||
p2p_conns.append(self.nodes[0].add_p2p_connection(TestP2PConn())) | p2p_conns.append(self.nodes[0].add_p2p_connection(TestP2PConn())) | ||||
for p2pc in p2p_conns: | |||||
p2pc.wait_for_verack() | |||||
# Test logic begins here | |||||
# Now mine a big block | # Now mine a big block | ||||
mine_big_block(self.nodes[0], self.utxo_cache) | mine_big_block(self.nodes[0], self.utxo_cache) | ||||
# Store the hash; we'll request this later | # Store the hash; we'll request this later | ||||
big_old_block = self.nodes[0].getbestblockhash() | big_old_block = self.nodes[0].getbestblockhash() | ||||
old_block_size = self.nodes[0].getblock(big_old_block, True)['size'] | old_block_size = self.nodes[0].getblock(big_old_block, True)['size'] | ||||
big_old_block = int(big_old_block, 16) | big_old_block = int(big_old_block, 16) | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# stop and start node 0 with 1MB maxuploadtarget, whitelist 127.0.0.1 | # stop and start node 0 with 1MB maxuploadtarget, whitelist 127.0.0.1 | ||||
self.log.info("Restarting nodes with -whitelist=127.0.0.1") | self.log.info("Restarting nodes with -whitelist=127.0.0.1") | ||||
self.stop_node(0) | self.stop_node(0) | ||||
self.start_node(0, ["-whitelist=127.0.0.1", | self.start_node(0, ["-whitelist=127.0.0.1", | ||||
"-maxuploadtarget=1", "-blockmaxsize=999000"]) | "-maxuploadtarget=1", "-blockmaxsize=999000"]) | ||||
# Reconnect to self.nodes[0] | # Reconnect to self.nodes[0] | ||||
self.nodes[0].add_p2p_connection(TestP2PConn()) | self.nodes[0].add_p2p_connection(TestP2PConn()) | ||||
self.nodes[0].p2p.wait_for_verack() | |||||
# retrieve 20 blocks which should be enough to break the 1MB limit | # retrieve 20 blocks which should be enough to break the 1MB limit | ||||
getdata_request.inv = [CInv(2, big_new_block)] | getdata_request.inv = [CInv(2, big_new_block)] | ||||
for i in range(20): | for i in range(20): | ||||
self.nodes[0].p2p.send_message(getdata_request) | self.nodes[0].p2p.send_message(getdata_request) | ||||
self.nodes[0].p2p.sync_with_ping() | self.nodes[0].p2p.sync_with_ping() | ||||
assert_equal( | assert_equal( | ||||
self.nodes[0].p2p.block_receive_map[big_new_block], i + 1) | self.nodes[0].p2p.block_receive_map[big_new_block], i + 1) | ||||
Show All 12 Lines |