7
7
Test that the DERSIG soft-fork activates at (regtest) height 1251.
8
8
"""
9
9
10
- from test_framework .blocktools import create_coinbase , create_block , create_transaction
10
+ from test_framework .blocktools import (
11
+ create_block ,
12
+ create_coinbase ,
13
+ )
11
14
from test_framework .messages import msg_block
12
15
from test_framework .p2p import P2PInterface
13
16
from test_framework .script import CScript
14
17
from test_framework .test_framework import BitcoinTestFramework
15
18
from test_framework .util import (
16
19
assert_equal ,
17
20
)
21
+ from test_framework .wallet import (
22
+ MiniWallet ,
23
+ MiniWalletMode ,
24
+ )
18
25
19
26
DERSIG_HEIGHT = 1251
20
27
@@ -46,8 +53,9 @@ def set_test_params(self):
46
53
self .setup_clean_chain = True
47
54
self .rpc_timeout = 240
48
55
49
- def skip_test_if_missing_module (self ):
50
- self .skip_if_no_wallet ()
56
+ def create_tx (self , input_txid ):
57
+ utxo_to_spend = self .miniwallet .get_utxo (txid = input_txid , mark_as_spent = False )
58
+ return self .miniwallet .create_self_transfer (from_node = self .nodes [0 ], utxo_to_spend = utxo_to_spend )['tx' ]
51
59
52
60
def test_dersig_info (self , * , is_active ):
53
61
assert_equal (self .nodes [0 ].getblockchaininfo ()['softforks' ]['bip66' ],
@@ -60,17 +68,16 @@ def test_dersig_info(self, *, is_active):
60
68
61
69
def run_test (self ):
62
70
peer = self .nodes [0 ].add_p2p_connection (P2PInterface ())
71
+ self .miniwallet = MiniWallet (self .nodes [0 ], mode = MiniWalletMode .RAW_P2PK )
63
72
64
73
self .test_dersig_info (is_active = False )
65
74
66
75
self .log .info ("Mining %d blocks" , DERSIG_HEIGHT - 2 )
67
- self .coinbase_txids = [self .nodes [0 ].getblock (b )['tx' ][0 ] for b in self .nodes [0 ].generate (DERSIG_HEIGHT - 2 )]
68
- self .nodeaddress = self .nodes [0 ].getnewaddress ()
76
+ self .coinbase_txids = [self .nodes [0 ].getblock (b )['tx' ][0 ] for b in self .miniwallet .generate (DERSIG_HEIGHT - 2 )]
69
77
70
78
self .log .info ("Test that a transaction with non-DER signature can still appear in a block" )
71
79
72
- spendtx = create_transaction (self .nodes [0 ], self .coinbase_txids [0 ],
73
- self .nodeaddress , amount = 1.0 )
80
+ spendtx = self .create_tx (self .coinbase_txids [0 ])
74
81
unDERify (spendtx )
75
82
spendtx .rehash ()
76
83
@@ -104,8 +111,7 @@ def run_test(self):
104
111
self .log .info ("Test that transactions with non-DER signatures cannot appear in a block" )
105
112
block .nVersion = 3
106
113
107
- spendtx = create_transaction (self .nodes [0 ], self .coinbase_txids [1 ],
108
- self .nodeaddress , amount = 1.0 )
114
+ spendtx = self .create_tx (self .coinbase_txids [1 ])
109
115
unDERify (spendtx )
110
116
spendtx .rehash ()
111
117
@@ -133,7 +139,7 @@ def run_test(self):
133
139
peer .sync_with_ping ()
134
140
135
141
self .log .info ("Test that a version 3 block with a DERSIG-compliant transaction is accepted" )
136
- block .vtx [1 ] = create_transaction ( self .nodes [ 0 ], self .coinbase_txids [1 ], self . nodeaddress , amount = 1.0 )
142
+ block .vtx [1 ] = self .create_tx ( self .coinbase_txids [1 ])
137
143
block .hashMerkleRoot = block .calc_merkle_root ()
138
144
block .rehash ()
139
145
block .solve ()
0 commit comments