Changeset View
Changeset View
Standalone View
Standalone View
test/functional/maxuploadtarget.py
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# Generate some old blocks | # Generate some old blocks | ||||
self.nodes[0].generate(130) | self.nodes[0].generate(130) | ||||
# 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 i in range(3): | for _ in range(3): | ||||
p2p_conns.append(self.nodes[0].add_p2p_connection(TestNode())) | p2p_conns.append(self.nodes[0].add_p2p_connection(TestNode())) | ||||
# Start up network handling in another thread | # Start up network handling in another thread | ||||
NetworkThread().start() | NetworkThread().start() | ||||
for p2pc in p2p_conns: | for p2pc in p2p_conns: | ||||
p2pc.wait_for_verack() | p2pc.wait_for_verack() | ||||
# Test logic begins here | # Test logic begins here | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
self.nodes[0].setmocktime(int(time.time())) | self.nodes[0].setmocktime(int(time.time())) | ||||
p2p_conns[2].sync_with_ping() | p2p_conns[2].sync_with_ping() | ||||
p2p_conns[2].send_message(getdata_request) | p2p_conns[2].send_message(getdata_request) | ||||
p2p_conns[2].sync_with_ping() | p2p_conns[2].sync_with_ping() | ||||
assert_equal(p2p_conns[2].block_receive_map[big_old_block], 1) | assert_equal(p2p_conns[2].block_receive_map[big_old_block], 1) | ||||
self.log.info("Peer 2 able to download old block") | self.log.info("Peer 2 able to download old block") | ||||
for i in range(3): | self.nodes[0].disconnect_p2ps() | ||||
self.nodes[0].disconnect_p2p() | |||||
# 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] | ||||
Show All 25 Lines |