Skip to content

Commit 0251511

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#26620: test: refactor: eliminate genesis block timestamp magic numbers
dbed289 test: refactor: eliminate genesis block timestamp magic numbers (Sebastian Falbesoner) Pull request description: This tiny PR replaces all occurences of the regtest/testnet genesis block timestamp (found via `git grep 1296688602`) with the constant `TIME_GENESIS_BLOCK` to increase the readability. ACKs for top commit: aureleoules: ACK dbed289 Tree-SHA512: be39d5c2631ad20eb775c2a077b1b1f056a1a4930aa44e6fdec73b974fd4bdf8da0103a3a38e3514b68fcf6a6316e007a371c523da5076a315545c9bf3091aee
2 parents a04121b + dbed289 commit 0251511

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

test/functional/feature_cltv.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"""
99

1010
from test_framework.blocktools import (
11+
TIME_GENESIS_BLOCK,
1112
create_block,
1213
create_coinbase,
1314
)
@@ -61,7 +62,7 @@ def cltv_invalidate(tx, failure_reason):
6162
# +-------------------------------------------------+------------+--------------+
6263
[[OP_CHECKLOCKTIMEVERIFY], None, None],
6364
[[OP_1NEGATE, OP_CHECKLOCKTIMEVERIFY, OP_DROP], None, None],
64-
[[CScriptNum(100), OP_CHECKLOCKTIMEVERIFY, OP_DROP], 0, 1296688602], # timestamp of genesis block
65+
[[CScriptNum(100), OP_CHECKLOCKTIMEVERIFY, OP_DROP], 0, TIME_GENESIS_BLOCK],
6566
[[CScriptNum(100), OP_CHECKLOCKTIMEVERIFY, OP_DROP], 0, 50],
6667
[[CScriptNum(50), OP_CHECKLOCKTIMEVERIFY, OP_DROP], SEQUENCE_FINAL, 50],
6768
][failure_reason]

test/functional/wallet_listdescriptors.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test the listdescriptors RPC."""
66

7+
from test_framework.blocktools import (
8+
TIME_GENESIS_BLOCK,
9+
)
710
from test_framework.descriptors import (
8-
descsum_create
11+
descsum_create,
912
)
1013
from test_framework.test_framework import BitcoinTestFramework
1114
from test_framework.util import (
@@ -66,13 +69,13 @@ def run_test(self):
6669
wallet = node.get_wallet_rpc('w2')
6770
wallet.importdescriptors([{
6871
'desc': descsum_create('wpkh(' + xprv + hardened_path + '/0/*)'),
69-
'timestamp': 1296688602,
72+
'timestamp': TIME_GENESIS_BLOCK,
7073
}])
7174
expected = {
7275
'wallet_name': 'w2',
7376
'descriptors': [
7477
{'desc': descsum_create('wpkh([80002067' + hardened_path + ']' + xpub_acc + '/0/*)'),
75-
'timestamp': 1296688602,
78+
'timestamp': TIME_GENESIS_BLOCK,
7679
'active': False,
7780
'range': [0, 0],
7881
'next': 0},
@@ -86,7 +89,7 @@ def run_test(self):
8689
'wallet_name': 'w2',
8790
'descriptors': [
8891
{'desc': descsum_create('wpkh(' + xprv + hardened_path + '/0/*)'),
89-
'timestamp': 1296688602,
92+
'timestamp': TIME_GENESIS_BLOCK,
9093
'active': False,
9194
'range': [0, 0],
9295
'next': 0},
@@ -108,7 +111,7 @@ def run_test(self):
108111
watch_only_wallet = node.get_wallet_rpc('watch-only')
109112
watch_only_wallet.importdescriptors([{
110113
'desc': descsum_create('wpkh(' + xpub_acc + ')'),
111-
'timestamp': 1296688602,
114+
'timestamp': TIME_GENESIS_BLOCK,
112115
}])
113116
assert_raises_rpc_error(-4, 'Can\'t get descriptor string', watch_only_wallet.listdescriptors, True)
114117

@@ -117,14 +120,14 @@ def run_test(self):
117120
wallet = node.get_wallet_rpc('w4')
118121
wallet.importdescriptors([{
119122
'desc': descsum_create('combo(' + node.get_deterministic_priv_key().key + ')'),
120-
'timestamp': 1296688602,
123+
'timestamp': TIME_GENESIS_BLOCK,
121124
}])
122125
expected = {
123126
'wallet_name': 'w4',
124127
'descriptors': [
125128
{'active': False,
126129
'desc': 'combo(0227d85ba011276cf25b51df6a188b75e604b38770a462b2d0e9fb2fc839ef5d3f)#np574htj',
127-
'timestamp': 1296688602},
130+
'timestamp': TIME_GENESIS_BLOCK},
128131
]
129132
}
130133
assert_equal(expected, wallet.listdescriptors())

0 commit comments

Comments
 (0)