mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-12 11:19:08 -05:00
Merge bitcoin/bitcoin#26620: test: refactor: eliminate genesis block timestamp magic numbers
dbed28968a
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: ACKdbed28968a
Tree-SHA512: be39d5c2631ad20eb775c2a077b1b1f056a1a4930aa44e6fdec73b974fd4bdf8da0103a3a38e3514b68fcf6a6316e007a371c523da5076a315545c9bf3091aee
This commit is contained in:
commit
02515117dc
2 changed files with 12 additions and 8 deletions
|
@ -8,6 +8,7 @@ Test that the CHECKLOCKTIMEVERIFY soft-fork activates.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from test_framework.blocktools import (
|
from test_framework.blocktools import (
|
||||||
|
TIME_GENESIS_BLOCK,
|
||||||
create_block,
|
create_block,
|
||||||
create_coinbase,
|
create_coinbase,
|
||||||
)
|
)
|
||||||
|
@ -61,7 +62,7 @@ def cltv_invalidate(tx, failure_reason):
|
||||||
# +-------------------------------------------------+------------+--------------+
|
# +-------------------------------------------------+------------+--------------+
|
||||||
[[OP_CHECKLOCKTIMEVERIFY], None, None],
|
[[OP_CHECKLOCKTIMEVERIFY], None, None],
|
||||||
[[OP_1NEGATE, OP_CHECKLOCKTIMEVERIFY, OP_DROP], None, None],
|
[[OP_1NEGATE, OP_CHECKLOCKTIMEVERIFY, OP_DROP], None, None],
|
||||||
[[CScriptNum(100), OP_CHECKLOCKTIMEVERIFY, OP_DROP], 0, 1296688602], # timestamp of genesis block
|
[[CScriptNum(100), OP_CHECKLOCKTIMEVERIFY, OP_DROP], 0, TIME_GENESIS_BLOCK],
|
||||||
[[CScriptNum(100), OP_CHECKLOCKTIMEVERIFY, OP_DROP], 0, 50],
|
[[CScriptNum(100), OP_CHECKLOCKTIMEVERIFY, OP_DROP], 0, 50],
|
||||||
[[CScriptNum(50), OP_CHECKLOCKTIMEVERIFY, OP_DROP], SEQUENCE_FINAL, 50],
|
[[CScriptNum(50), OP_CHECKLOCKTIMEVERIFY, OP_DROP], SEQUENCE_FINAL, 50],
|
||||||
][failure_reason]
|
][failure_reason]
|
||||||
|
|
|
@ -4,8 +4,11 @@
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
"""Test the listdescriptors RPC."""
|
"""Test the listdescriptors RPC."""
|
||||||
|
|
||||||
|
from test_framework.blocktools import (
|
||||||
|
TIME_GENESIS_BLOCK,
|
||||||
|
)
|
||||||
from test_framework.descriptors import (
|
from test_framework.descriptors import (
|
||||||
descsum_create
|
descsum_create,
|
||||||
)
|
)
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import (
|
from test_framework.util import (
|
||||||
|
@ -66,13 +69,13 @@ class ListDescriptorsTest(BitcoinTestFramework):
|
||||||
wallet = node.get_wallet_rpc('w2')
|
wallet = node.get_wallet_rpc('w2')
|
||||||
wallet.importdescriptors([{
|
wallet.importdescriptors([{
|
||||||
'desc': descsum_create('wpkh(' + xprv + hardened_path + '/0/*)'),
|
'desc': descsum_create('wpkh(' + xprv + hardened_path + '/0/*)'),
|
||||||
'timestamp': 1296688602,
|
'timestamp': TIME_GENESIS_BLOCK,
|
||||||
}])
|
}])
|
||||||
expected = {
|
expected = {
|
||||||
'wallet_name': 'w2',
|
'wallet_name': 'w2',
|
||||||
'descriptors': [
|
'descriptors': [
|
||||||
{'desc': descsum_create('wpkh([80002067' + hardened_path + ']' + xpub_acc + '/0/*)'),
|
{'desc': descsum_create('wpkh([80002067' + hardened_path + ']' + xpub_acc + '/0/*)'),
|
||||||
'timestamp': 1296688602,
|
'timestamp': TIME_GENESIS_BLOCK,
|
||||||
'active': False,
|
'active': False,
|
||||||
'range': [0, 0],
|
'range': [0, 0],
|
||||||
'next': 0},
|
'next': 0},
|
||||||
|
@ -86,7 +89,7 @@ class ListDescriptorsTest(BitcoinTestFramework):
|
||||||
'wallet_name': 'w2',
|
'wallet_name': 'w2',
|
||||||
'descriptors': [
|
'descriptors': [
|
||||||
{'desc': descsum_create('wpkh(' + xprv + hardened_path + '/0/*)'),
|
{'desc': descsum_create('wpkh(' + xprv + hardened_path + '/0/*)'),
|
||||||
'timestamp': 1296688602,
|
'timestamp': TIME_GENESIS_BLOCK,
|
||||||
'active': False,
|
'active': False,
|
||||||
'range': [0, 0],
|
'range': [0, 0],
|
||||||
'next': 0},
|
'next': 0},
|
||||||
|
@ -108,7 +111,7 @@ class ListDescriptorsTest(BitcoinTestFramework):
|
||||||
watch_only_wallet = node.get_wallet_rpc('watch-only')
|
watch_only_wallet = node.get_wallet_rpc('watch-only')
|
||||||
watch_only_wallet.importdescriptors([{
|
watch_only_wallet.importdescriptors([{
|
||||||
'desc': descsum_create('wpkh(' + xpub_acc + ')'),
|
'desc': descsum_create('wpkh(' + xpub_acc + ')'),
|
||||||
'timestamp': 1296688602,
|
'timestamp': TIME_GENESIS_BLOCK,
|
||||||
}])
|
}])
|
||||||
assert_raises_rpc_error(-4, 'Can\'t get descriptor string', watch_only_wallet.listdescriptors, True)
|
assert_raises_rpc_error(-4, 'Can\'t get descriptor string', watch_only_wallet.listdescriptors, True)
|
||||||
|
|
||||||
|
@ -117,14 +120,14 @@ class ListDescriptorsTest(BitcoinTestFramework):
|
||||||
wallet = node.get_wallet_rpc('w4')
|
wallet = node.get_wallet_rpc('w4')
|
||||||
wallet.importdescriptors([{
|
wallet.importdescriptors([{
|
||||||
'desc': descsum_create('combo(' + node.get_deterministic_priv_key().key + ')'),
|
'desc': descsum_create('combo(' + node.get_deterministic_priv_key().key + ')'),
|
||||||
'timestamp': 1296688602,
|
'timestamp': TIME_GENESIS_BLOCK,
|
||||||
}])
|
}])
|
||||||
expected = {
|
expected = {
|
||||||
'wallet_name': 'w4',
|
'wallet_name': 'w4',
|
||||||
'descriptors': [
|
'descriptors': [
|
||||||
{'active': False,
|
{'active': False,
|
||||||
'desc': 'combo(0227d85ba011276cf25b51df6a188b75e604b38770a462b2d0e9fb2fc839ef5d3f)#np574htj',
|
'desc': 'combo(0227d85ba011276cf25b51df6a188b75e604b38770a462b2d0e9fb2fc839ef5d3f)#np574htj',
|
||||||
'timestamp': 1296688602},
|
'timestamp': TIME_GENESIS_BLOCK},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
assert_equal(expected, wallet.listdescriptors())
|
assert_equal(expected, wallet.listdescriptors())
|
||||||
|
|
Loading…
Add table
Reference in a new issue