Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-p2p-fullblocktest.py
Show First 20 Lines • Show All 429 Lines • ▼ Show 20 Lines | def get_tests(self): | ||||
# Start up network handling in another thread and wait for connection | # Start up network handling in another thread and wait for connection | ||||
# to be etablished | # to be etablished | ||||
NetworkThread().start() | NetworkThread().start() | ||||
peer.wait_for_verack() | peer.wait_for_verack() | ||||
# Wait for SENDCMPCT | # Wait for SENDCMPCT | ||||
def received_sendcmpct(): | def received_sendcmpct(): | ||||
return (peer.last_sendcmpct != None) | return (peer.last_sendcmpct != None) | ||||
got_sendcmpt = wait_until(received_sendcmpct, timeout=30) | wait_until(received_sendcmpct, timeout=30) | ||||
assert(got_sendcmpt) | |||||
sendcmpct = msg_sendcmpct() | sendcmpct = msg_sendcmpct() | ||||
sendcmpct.version = 1 | sendcmpct.version = 1 | ||||
sendcmpct.announce = True | sendcmpct.announce = True | ||||
peer.send_and_ping(sendcmpct) | peer.send_and_ping(sendcmpct) | ||||
# Exchange headers | # Exchange headers | ||||
def received_getheaders(): | def received_getheaders(): | ||||
return (peer.last_getheaders != None) | return (peer.last_getheaders != None) | ||||
got_getheaders = wait_until(received_getheaders, timeout=30) | wait_until(received_getheaders, timeout=30) | ||||
assert(got_getheaders) | |||||
# Return the favor | # Return the favor | ||||
peer.send_message(peer.last_getheaders) | peer.send_message(peer.last_getheaders) | ||||
# Wait for the header list | # Wait for the header list | ||||
def received_headers(): | def received_headers(): | ||||
return (peer.last_headers != None) | return (peer.last_headers != None) | ||||
got_headers = wait_until(received_headers, timeout=30) | wait_until(received_headers, timeout=30) | ||||
assert(got_headers) | |||||
# It's like we know about the same headers ! | # It's like we know about the same headers ! | ||||
peer.send_message(peer.last_headers) | peer.send_message(peer.last_headers) | ||||
# Send a block | # Send a block | ||||
b33 = block(33, spend=out[24], block_size=ONE_MEGABYTE + 1) | b33 = block(33, spend=out[24], block_size=ONE_MEGABYTE + 1) | ||||
yield accepted() | yield accepted() | ||||
# Checks the node to forward it via compact block | # Checks the node to forward it via compact block | ||||
def received_block(): | def received_block(): | ||||
return (peer.last_cmpctblock != None) | return (peer.last_cmpctblock != None) | ||||
got_cmpctblock = wait_until(received_block, timeout=30) | wait_until(received_block, timeout=30) | ||||
assert(got_cmpctblock) | |||||
# Was it our block ? | # Was it our block ? | ||||
cmpctblk_header = peer.last_cmpctblock.header_and_shortids.header | cmpctblk_header = peer.last_cmpctblock.header_and_shortids.header | ||||
cmpctblk_header.calc_sha256() | cmpctblk_header.calc_sha256() | ||||
assert(cmpctblk_header.sha256 == b33.sha256) | assert(cmpctblk_header.sha256 == b33.sha256) | ||||
# Send a bigger block | # Send a bigger block | ||||
peer.clear_block_data() | peer.clear_block_data() | ||||
b34 = block(34, spend=out[25], block_size=8 * ONE_MEGABYTE) | b34 = block(34, spend=out[25], block_size=8 * ONE_MEGABYTE) | ||||
yield accepted() | yield accepted() | ||||
# Checks the node to forward it via compact block | # Checks the node to forward it via compact block | ||||
got_cmpctblock = wait_until(received_block, timeout=30) | wait_until(received_block, timeout=30) | ||||
assert(got_cmpctblock) | |||||
# Was it our block ? | # Was it our block ? | ||||
cmpctblk_header = peer.last_cmpctblock.header_and_shortids.header | cmpctblk_header = peer.last_cmpctblock.header_and_shortids.header | ||||
cmpctblk_header.calc_sha256() | cmpctblk_header.calc_sha256() | ||||
assert(cmpctblk_header.sha256 == b34.sha256) | assert(cmpctblk_header.sha256 == b34.sha256) | ||||
# Let's send a compact block and see if the node accepts it. | # Let's send a compact block and see if the node accepts it. | ||||
# First, we generate the block and send all transaction to the mempool | # First, we generate the block and send all transaction to the mempool | ||||
Show All 15 Lines |