Changeset View
Changeset View
Standalone View
Standalone View
test/functional/bip68-112-113-p2p.py
Show All 37 Lines | |||||
bip112txs_vary_OP_CSV - 16 txs with nSequence = 10 evaluated against varying {relative_locktimes of 10} OP_CSV OP_DROP | bip112txs_vary_OP_CSV - 16 txs with nSequence = 10 evaluated against varying {relative_locktimes of 10} OP_CSV OP_DROP | ||||
bip112txs_vary_OP_CSV_9 - 16 txs with nSequence = 9 evaluated against varying {relative_locktimes of 10} OP_CSV OP_DROP | bip112txs_vary_OP_CSV_9 - 16 txs with nSequence = 9 evaluated against varying {relative_locktimes of 10} OP_CSV OP_DROP | ||||
bip112tx_special - test negative argument to OP_CSV | bip112tx_special - test negative argument to OP_CSV | ||||
""" | """ | ||||
from test_framework.test_framework import ComparisonTestFramework | from test_framework.test_framework import ComparisonTestFramework | ||||
from test_framework.util import * | from test_framework.util import * | ||||
from test_framework.mininode import ToHex, FromHex, CTransaction, NetworkThread, COIN | from test_framework.mininode import ToHex, FromHex, CTransaction, NetworkThread, COIN | ||||
from test_framework.blocktools import create_coinbase, create_block | from test_framework.blocktools import create_coinbase, create_block, make_conform_to_ctor | ||||
from test_framework.comptool import TestInstance, TestManager | from test_framework.comptool import TestInstance, TestManager | ||||
from test_framework.script import * | from test_framework.script import * | ||||
import time | import time | ||||
# far in the future | |||||
MAGNETIC_ANOMALY_START_TIME = 2000000000 | |||||
base_relative_locktime = 10 | base_relative_locktime = 10 | ||||
seq_disable_flag = 1 << 31 | seq_disable_flag = 1 << 31 | ||||
seq_random_high_bit = 1 << 25 | seq_random_high_bit = 1 << 25 | ||||
seq_type_flag = 1 << 22 | seq_type_flag = 1 << 22 | ||||
seq_random_low_bit = 1 << 18 | seq_random_low_bit = 1 << 18 | ||||
# b31,b25,b22,b18 represent the 31st, 25th, 22nd and 18th bits respectively in the nSequence field | # b31,b25,b22,b18 represent the 31st, 25th, 22nd and 18th bits respectively in the nSequence field | ||||
# relative_locktimes[b31][b25][b22][b18] is a base_relative_locktime with the indicated bits set if their indices are 1 | # relative_locktimes[b31][b25][b22][b18] is a base_relative_locktime with the indicated bits set if their indices are 1 | ||||
Show All 37 Lines | for sf in softforks: | ||||
return sf['reject']['status'] | return sf['reject']['status'] | ||||
raise AssertionError('Cannot find CSV fork activation informations') | raise AssertionError('Cannot find CSV fork activation informations') | ||||
class BIP68_112_113Test(ComparisonTestFramework): | class BIP68_112_113Test(ComparisonTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
self.extra_args = [['-whitelist=127.0.0.1', '-blockversion=4', | self.extra_args = [['-whitelist=127.0.0.1', '-blockversion=4']] | ||||
'-magneticanomalyactivationtime=%d' % MAGNETIC_ANOMALY_START_TIME]] | |||||
def run_test(self): | def run_test(self): | ||||
test = TestManager(self, self.options.tmpdir) | test = TestManager(self, self.options.tmpdir) | ||||
test.add_all_connections(self.nodes) | test.add_all_connections(self.nodes) | ||||
# Start up network handling in another thread | # Start up network handling in another thread | ||||
NetworkThread().start() | NetworkThread().start() | ||||
test.run() | test.run() | ||||
Show All 31 Lines | def generate_blocks(self, number): | ||||
self.tipheight += 1 | self.tipheight += 1 | ||||
return test_blocks | return test_blocks | ||||
def create_test_block(self, txs, version=536870912): | def create_test_block(self, txs, version=536870912): | ||||
block = create_block(self.tip, create_coinbase( | block = create_block(self.tip, create_coinbase( | ||||
self.tipheight + 1), self.last_block_time + 600) | self.tipheight + 1), self.last_block_time + 600) | ||||
block.nVersion = version | block.nVersion = version | ||||
block.vtx.extend(txs) | block.vtx.extend(txs) | ||||
make_conform_to_ctor(block) | |||||
block.hashMerkleRoot = block.calc_merkle_root() | block.hashMerkleRoot = block.calc_merkle_root() | ||||
block.rehash() | block.rehash() | ||||
block.solve() | block.solve() | ||||
return block | return block | ||||
# Create a block with given txs, and spend these txs in the same block. | # Create a block with given txs, and spend these txs in the same block. | ||||
# Spending utxos in the same block is OK as long as nSequence is not enforced. | # Spending utxos in the same block is OK as long as nSequence is not enforced. | ||||
# Otherwise a number of intermediate blocks should be generated, and this | # Otherwise a number of intermediate blocks should be generated, and this | ||||
# method should not be used. | # method should not be used. | ||||
def create_test_block_spend_utxos(self, node, txs, version=536870912): | def create_test_block_spend_utxos(self, node, txs, version=536870912): | ||||
block = create_block(self.tip, create_coinbase( | block = create_block(self.tip, create_coinbase( | ||||
self.tipheight + 1), self.last_block_time + 600) | self.tipheight + 1), self.last_block_time + 600) | ||||
block.nVersion = version | block.nVersion = version | ||||
block.vtx.extend(txs) | block.vtx.extend(txs) | ||||
block.vtx.extend([self.spend_tx(node, tx) for tx in txs]) | block.vtx.extend([self.spend_tx(node, tx) for tx in txs]) | ||||
make_conform_to_ctor(block) | |||||
block.hashMerkleRoot = block.calc_merkle_root() | block.hashMerkleRoot = block.calc_merkle_root() | ||||
block.rehash() | block.rehash() | ||||
block.solve() | block.solve() | ||||
return block | return block | ||||
def create_bip68txs(self, bip68inputs, txversion, locktime_delta=0): | def create_bip68txs(self, bip68inputs, txversion, locktime_delta=0): | ||||
txs = [] | txs = [] | ||||
assert(len(bip68inputs) >= 16) | assert(len(bip68inputs) >= 16) | ||||
▲ Show 20 Lines • Show All 520 Lines • Show Last 20 Lines |