Skip to content

Commit 12f094e

Browse files
committed
test: use constants for CSV/CLTV activation heights in rpc_signrawtransaction
1 parent 746f203 commit 12f094e

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

test/functional/feature_cltv.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"""
1010

1111
from test_framework.blocktools import (
12+
CLTV_HEIGHT,
1213
create_block,
1314
create_coinbase,
1415
)
@@ -31,8 +32,6 @@
3132
MiniWalletMode,
3233
)
3334

34-
CLTV_HEIGHT = 1351
35-
3635

3736
# Helper function to modify a transaction by
3837
# 1) prepending a given script to the scriptSig of vin 0 and

test/functional/feature_csv_activation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import time
4242

4343
from test_framework.blocktools import (
44+
CSV_ACTIVATION_HEIGHT,
4445
create_block,
4546
create_coinbase,
4647
)
@@ -63,7 +64,6 @@
6364
TESTING_TX_COUNT = 83 # Number of testing transactions: 1 BIP113 tx, 16 BIP68 txs, 66 BIP112 txs (see comments above)
6465
COINBASE_BLOCK_COUNT = TESTING_TX_COUNT # Number of coinbase blocks we need to generate as inputs for our txs
6566
BASE_RELATIVE_LOCKTIME = 10
66-
CSV_ACTIVATION_HEIGHT = 432
6767
SEQ_DISABLE_FLAG = 1 << 31
6868
SEQ_RANDOM_HIGH_BIT = 1 << 25
6969
SEQ_TYPE_FLAG = 1 << 22

test/functional/rpc_signrawtransaction.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test transaction signing using the signrawtransaction* RPCs."""
66

7-
from test_framework.blocktools import COINBASE_MATURITY
7+
from test_framework.blocktools import (
8+
CLTV_HEIGHT,
9+
COINBASE_MATURITY,
10+
CSV_ACTIVATION_HEIGHT,
11+
)
812
from test_framework.address import (
913
script_to_p2sh,
1014
script_to_p2wsh,
@@ -271,7 +275,7 @@ def test_signing_with_csv(self):
271275
getcontext().prec = 8
272276

273277
# Make sure CSV is active
274-
generate_to_height(self.nodes[0], 500)
278+
generate_to_height(self.nodes[0], CSV_ACTIVATION_HEIGHT)
275279
assert self.nodes[0].getblockchaininfo()['softforks']['csv']['active']
276280

277281
# Create a P2WSH script with CSV
@@ -307,7 +311,7 @@ def test_signing_with_cltv(self):
307311
getcontext().prec = 8
308312

309313
# Make sure CLTV is active
310-
generate_to_height(self.nodes[0], 1500)
314+
generate_to_height(self.nodes[0], CLTV_HEIGHT)
311315
assert self.nodes[0].getblockchaininfo()['softforks']['bip65']['active']
312316

313317
# Create a P2WSH script with CLTV

test/functional/test_framework/blocktools.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
# Coinbase transaction outputs can only be spent after this number of new blocks (network rule)
5656
COINBASE_MATURITY = 100
5757

58+
# Soft-fork activation heights
59+
CLTV_HEIGHT = 1351
60+
CSV_ACTIVATION_HEIGHT = 432
61+
5862
# From BIP141
5963
WITNESS_COMMITMENT_HEADER = b"\xaa\x21\xa9\xed"
6064

0 commit comments

Comments
 (0)