Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_unrequested_blocks.py
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | 9. Test Node1 is able to sync when connected to node0 (which should have sufficient | ||||
work on its chain). | work on its chain). | ||||
""" | """ | ||||
import time | import time | ||||
from test_framework.blocktools import ( | from test_framework.blocktools import ( | ||||
create_block, | create_block, | ||||
create_coinbase, | create_coinbase, | ||||
create_transaction, | create_tx_with_script, | ||||
) | ) | ||||
from test_framework.messages import ( | from test_framework.messages import ( | ||||
CBlockHeader, | CBlockHeader, | ||||
CInv, | CInv, | ||||
msg_block, | msg_block, | ||||
msg_headers, | msg_headers, | ||||
msg_inv, | msg_inv, | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 206 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
all_blocks[284].sha256, create_coinbase(289), all_blocks[284].nTime + 1) | all_blocks[284].sha256, create_coinbase(289), all_blocks[284].nTime + 1) | ||||
block_289f.solve() | block_289f.solve() | ||||
block_290f = create_block( | block_290f = create_block( | ||||
block_289f.sha256, create_coinbase(290), block_289f.nTime + 1) | block_289f.sha256, create_coinbase(290), block_289f.nTime + 1) | ||||
block_290f.solve() | block_290f.solve() | ||||
block_291 = create_block( | block_291 = create_block( | ||||
block_290f.sha256, create_coinbase(291), block_290f.nTime + 1) | block_290f.sha256, create_coinbase(291), block_290f.nTime + 1) | ||||
# block_291 spends a coinbase below maturity! | # block_291 spends a coinbase below maturity! | ||||
block_291.vtx.append(create_transaction( | block_291.vtx.append(create_tx_with_script( | ||||
block_290f.vtx[0], 0, b"42", 1)) | block_290f.vtx[0], 0, script_sig=b"42", amount=1)) | ||||
block_291.hashMerkleRoot = block_291.calc_merkle_root() | block_291.hashMerkleRoot = block_291.calc_merkle_root() | ||||
block_291.solve() | block_291.solve() | ||||
block_292 = create_block( | block_292 = create_block( | ||||
block_291.sha256, create_coinbase(292), block_291.nTime + 1) | block_291.sha256, create_coinbase(292), block_291.nTime + 1) | ||||
block_292.solve() | block_292.solve() | ||||
# Now send all the headers on the chain and enough blocks to trigger reorg | # Now send all the headers on the chain and enough blocks to trigger reorg | ||||
headers_message = msg_headers() | headers_message = msg_headers() | ||||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |