Changeset View
Changeset View
Standalone View
Standalone View
test/functional/mining_basic.py
Show First 20 Lines • Show All 237 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
bad_block_time = copy.deepcopy(block) | bad_block_time = copy.deepcopy(block) | ||||
bad_block_time.nTime = 1 | bad_block_time.nTime = 1 | ||||
bad_block_time.solve() | bad_block_time.solve() | ||||
assert_raises_rpc_error(-25, 'time-too-old', lambda: node.submitheader( | assert_raises_rpc_error(-25, 'time-too-old', lambda: node.submitheader( | ||||
hexdata=CBlockHeader(bad_block_time).serialize().hex())) | hexdata=CBlockHeader(bad_block_time).serialize().hex())) | ||||
# Should ask for the block from a p2p node, if they announce the header | # Should ask for the block from a p2p node, if they announce the header | ||||
# as well: | # as well: | ||||
node.add_p2p_connection(P2PDataStore()) | peer = node.add_p2p_connection(P2PDataStore()) | ||||
# Drop the first getheaders | # Drop the first getheaders | ||||
node.p2p.wait_for_getheaders(timeout=5) | peer.wait_for_getheaders(timeout=5) | ||||
node.p2p.send_blocks_and_test(blocks=[block], node=node) | peer.send_blocks_and_test(blocks=[block], node=node) | ||||
# Must be active now: | # Must be active now: | ||||
assert chain_tip(block.hash, status='active', | assert chain_tip(block.hash, status='active', | ||||
branchlen=0) in node.getchaintips() | branchlen=0) in node.getchaintips() | ||||
# Building a few blocks should give the same results | # Building a few blocks should give the same results | ||||
node.generatetoaddress(10, node.get_deterministic_priv_key().address) | node.generatetoaddress(10, node.get_deterministic_priv_key().address) | ||||
assert_raises_rpc_error(-25, 'time-too-old', lambda: node.submitheader( | assert_raises_rpc_error(-25, 'time-too-old', lambda: node.submitheader( | ||||
hexdata=CBlockHeader(bad_block_time).serialize().hex())) | hexdata=CBlockHeader(bad_block_time).serialize().hex())) | ||||
Show All 17 Lines |