Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_assumevalid.py
Show All 26 Lines | - node1 has -assumevalid set to the hash of block 102. Try to sync to | ||||
block 2202. node1 will sync all the way to block 2202. | block 2202. node1 will sync all the way to block 2202. | ||||
- node2 has -assumevalid set to the hash of block 102. Try to sync to | - node2 has -assumevalid set to the hash of block 102. Try to sync to | ||||
block 200. node2 will reject block 102 since it's assumed valid, but it | block 200. node2 will reject block 102 since it's assumed valid, but it | ||||
isn't buried by at least two weeks' work. | isn't buried by at least two weeks' work. | ||||
""" | """ | ||||
import time | import time | ||||
from test_framework.blocktools import (create_block, create_coinbase) | from test_framework.blocktools import (create_block, create_coinbase) | ||||
from test_framework.key import CECKey | from test_framework.key import ECKey | ||||
from test_framework.messages import ( | from test_framework.messages import ( | ||||
CBlockHeader, | CBlockHeader, | ||||
COutPoint, | COutPoint, | ||||
CTransaction, | CTransaction, | ||||
CTxIn, | CTxIn, | ||||
CTxOut, | CTxOut, | ||||
msg_block, | msg_block, | ||||
msg_headers, | msg_headers, | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# Build the blockchain | # Build the blockchain | ||||
self.tip = int(self.nodes[0].getbestblockhash(), 16) | self.tip = int(self.nodes[0].getbestblockhash(), 16) | ||||
self.block_time = self.nodes[0].getblock( | self.block_time = self.nodes[0].getblock( | ||||
self.nodes[0].getbestblockhash())['time'] + 1 | self.nodes[0].getbestblockhash())['time'] + 1 | ||||
self.blocks = [] | self.blocks = [] | ||||
# Get a pubkey for the coinbase TXO | # Get a pubkey for the coinbase TXO | ||||
coinbase_key = CECKey() | coinbase_key = ECKey() | ||||
coinbase_key.set_secretbytes(b"horsebattery") | coinbase_key.generate() | ||||
coinbase_pubkey = coinbase_key.get_pubkey() | coinbase_pubkey = coinbase_key.get_pubkey().get_bytes() | ||||
# Create the first block with a coinbase output to our key | # Create the first block with a coinbase output to our key | ||||
height = 1 | height = 1 | ||||
block = create_block(self.tip, create_coinbase( | block = create_block(self.tip, create_coinbase( | ||||
height, coinbase_pubkey), self.block_time) | height, coinbase_pubkey), self.block_time) | ||||
self.blocks.append(block) | self.blocks.append(block) | ||||
self.block_time += 1 | self.block_time += 1 | ||||
block.solve() | block.solve() | ||||
▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines |