mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
test: Activate all regtest softforks at height 1, unless overridden
This commit is contained in:
@@ -41,8 +41,14 @@ class BIP68Test(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 2
|
||||
self.extra_args = [
|
||||
["-acceptnonstdtxn=1"],
|
||||
["-acceptnonstdtxn=0"],
|
||||
[
|
||||
'-testactivationheight=csv@432',
|
||||
"-acceptnonstdtxn=1",
|
||||
],
|
||||
[
|
||||
'-testactivationheight=csv@432',
|
||||
"-acceptnonstdtxn=0",
|
||||
],
|
||||
]
|
||||
|
||||
def skip_test_if_missing_module(self):
|
||||
|
||||
@@ -82,7 +82,10 @@ class FullBlockTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 1
|
||||
self.setup_clean_chain = True
|
||||
self.extra_args = [['-acceptnonstdtxn=1']] # This is a consensus block test, we don't care about tx policy
|
||||
self.extra_args = [[
|
||||
'-acceptnonstdtxn=1', # This is a consensus block test, we don't care about tx policy
|
||||
'-testactivationheight=bip34@2',
|
||||
]]
|
||||
|
||||
def run_test(self):
|
||||
node = self.nodes[0] # convenience reference to the node
|
||||
|
||||
@@ -8,7 +8,6 @@ Test that the CHECKLOCKTIMEVERIFY soft-fork activates.
|
||||
"""
|
||||
|
||||
from test_framework.blocktools import (
|
||||
CLTV_HEIGHT,
|
||||
create_block,
|
||||
create_coinbase,
|
||||
)
|
||||
@@ -76,10 +75,14 @@ def cltv_validate(tx, height):
|
||||
cltv_modify_tx(tx, prepend_scriptsig=scheme[0], nsequence=scheme[1], nlocktime=scheme[2])
|
||||
|
||||
|
||||
CLTV_HEIGHT = 111
|
||||
|
||||
|
||||
class BIP65Test(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 1
|
||||
self.extra_args = [[
|
||||
f'-testactivationheight=cltv@{CLTV_HEIGHT}',
|
||||
'-whitelist=noban@127.0.0.1',
|
||||
'-par=1', # Use only one script thread to get the exact reject reason for testing
|
||||
'-acceptnonstdtxn=1', # cltv_invalidate is nonstandard
|
||||
|
||||
@@ -41,7 +41,6 @@ from itertools import product
|
||||
import time
|
||||
|
||||
from test_framework.blocktools import (
|
||||
CSV_ACTIVATION_HEIGHT,
|
||||
create_block,
|
||||
create_coinbase,
|
||||
)
|
||||
@@ -89,12 +88,16 @@ def all_rlt_txs(txs):
|
||||
return [tx['tx'] for tx in txs]
|
||||
|
||||
|
||||
CSV_ACTIVATION_HEIGHT = 432
|
||||
|
||||
|
||||
class BIP68_112_113Test(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 1
|
||||
self.setup_clean_chain = True
|
||||
self.extra_args = [[
|
||||
'-whitelist=noban@127.0.0.1',
|
||||
f'-testactivationheight=csv@{CSV_ACTIVATION_HEIGHT}',
|
||||
'-par=1', # Use only one script thread to get the exact reject reason for testing
|
||||
]]
|
||||
self.supports_cli = False
|
||||
|
||||
@@ -8,7 +8,6 @@ Test the DERSIG soft-fork activation on regtest.
|
||||
"""
|
||||
|
||||
from test_framework.blocktools import (
|
||||
DERSIG_HEIGHT,
|
||||
create_block,
|
||||
create_coinbase,
|
||||
)
|
||||
@@ -42,10 +41,14 @@ def unDERify(tx):
|
||||
tx.vin[0].scriptSig = CScript(newscript)
|
||||
|
||||
|
||||
DERSIG_HEIGHT = 102
|
||||
|
||||
|
||||
class BIP66Test(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 1
|
||||
self.extra_args = [[
|
||||
f'-testactivationheight=dersig@{DERSIG_HEIGHT}',
|
||||
'-whitelist=noban@127.0.0.1',
|
||||
'-par=1', # Use only one script thread to get the exact log msg for testing
|
||||
]]
|
||||
|
||||
@@ -27,8 +27,6 @@ import subprocess
|
||||
|
||||
from test_framework.address import ADDRESS_BCRT1_P2WSH_OP_TRUE
|
||||
from test_framework.blocktools import (
|
||||
CLTV_HEIGHT,
|
||||
DERSIG_HEIGHT,
|
||||
create_block,
|
||||
create_coinbase,
|
||||
TIME_GENESIS_BLOCK,
|
||||
@@ -142,11 +140,11 @@ class BlockchainTest(BitcoinTestFramework):
|
||||
assert_greater_than(res['size_on_disk'], 0)
|
||||
|
||||
assert_equal(res['softforks'], {
|
||||
'bip34': {'type': 'buried', 'active': True, 'height': 2},
|
||||
'bip66': {'type': 'buried', 'active': True, 'height': DERSIG_HEIGHT},
|
||||
'bip65': {'type': 'buried', 'active': True, 'height': CLTV_HEIGHT},
|
||||
'csv': {'type': 'buried', 'active': False, 'height': 432},
|
||||
'segwit': {'type': 'buried', 'active': True, 'height': 0},
|
||||
'bip34': {'type': 'buried', 'active': True, 'height': 1},
|
||||
'bip66': {'type': 'buried', 'active': True, 'height': 1},
|
||||
'bip65': {'type': 'buried', 'active': True, 'height': 1},
|
||||
'csv': {'type': 'buried', 'active': True, 'height': 1},
|
||||
'segwit': {'type': 'buried', 'active': True, 'height': 1},
|
||||
'testdummy': {
|
||||
'type': 'bip9',
|
||||
'bip9': {
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
from test_framework.blocktools import (
|
||||
COINBASE_MATURITY,
|
||||
CSV_ACTIVATION_HEIGHT,
|
||||
)
|
||||
from test_framework.address import (
|
||||
script_to_p2sh,
|
||||
@@ -18,7 +17,6 @@ from test_framework.util import (
|
||||
assert_equal,
|
||||
assert_raises_rpc_error,
|
||||
find_vout_for_address,
|
||||
generate_to_height,
|
||||
)
|
||||
from test_framework.messages import (
|
||||
CTxInWitness,
|
||||
@@ -273,7 +271,6 @@ class SignRawTransactionsTest(BitcoinTestFramework):
|
||||
getcontext().prec = 8
|
||||
|
||||
# Make sure CSV is active
|
||||
generate_to_height(self, self.nodes[0], CSV_ACTIVATION_HEIGHT)
|
||||
assert self.nodes[0].getblockchaininfo()['softforks']['csv']['active']
|
||||
|
||||
# Create a P2WSH script with CSV
|
||||
|
||||
@@ -53,11 +53,6 @@ TIME_GENESIS_BLOCK = 1296688602
|
||||
# Coinbase transaction outputs can only be spent after this number of new blocks (network rule)
|
||||
COINBASE_MATURITY = 100
|
||||
|
||||
# Soft-fork activation heights
|
||||
DERSIG_HEIGHT = 102 # BIP 66
|
||||
CLTV_HEIGHT = 111 # BIP 65
|
||||
CSV_ACTIVATION_HEIGHT = 432
|
||||
|
||||
# From BIP141
|
||||
WITNESS_COMMITMENT_HEADER = b"\xaa\x21\xa9\xed"
|
||||
|
||||
|
||||
@@ -560,17 +560,6 @@ def mine_large_block(test_framework, node, utxos=None):
|
||||
test_framework.generate(node, 1)
|
||||
|
||||
|
||||
def generate_to_height(test_framework, node, target_height):
|
||||
"""Generates blocks until a given target block height has been reached.
|
||||
To prevent timeouts, only up to 200 blocks are generated per RPC call.
|
||||
Can be used to activate certain soft-forks (e.g. CSV, CLTV)."""
|
||||
current_height = node.getblockcount()
|
||||
while current_height < target_height:
|
||||
nblocks = min(200, target_height - current_height)
|
||||
current_height += len(test_framework.generate(node, nblocks))
|
||||
assert_equal(node.getblockcount(), target_height)
|
||||
|
||||
|
||||
def find_vout_for_address(node, txid, addr):
|
||||
"""
|
||||
Locate the vout index of the given transaction sending to the
|
||||
|
||||
Reference in New Issue
Block a user