77Test that the DERSIG soft-fork activates at (regtest) height 1251.
88"""
99
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+ )
1114from test_framework .messages import msg_block
1215from test_framework .p2p import P2PInterface
1316from test_framework .script import CScript
1417from test_framework .test_framework import BitcoinTestFramework
1518from test_framework .util import (
1619 assert_equal ,
1720)
21+ from test_framework .wallet import (
22+ MiniWallet ,
23+ MiniWalletMode ,
24+ )
1825
1926DERSIG_HEIGHT = 1251
2027
@@ -46,8 +53,9 @@ def set_test_params(self):
4653 self .setup_clean_chain = True
4754 self .rpc_timeout = 240
4855
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' ]
5159
5260 def test_dersig_info (self , * , is_active ):
5361 assert_equal (self .nodes [0 ].getblockchaininfo ()['softforks' ]['bip66' ],
@@ -60,17 +68,16 @@ def test_dersig_info(self, *, is_active):
6068
6169 def run_test (self ):
6270 peer = self .nodes [0 ].add_p2p_connection (P2PInterface ())
71+ self .miniwallet = MiniWallet (self .nodes [0 ], mode = MiniWalletMode .RAW_P2PK )
6372
6473 self .test_dersig_info (is_active = False )
6574
6675 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 )]
6977
7078 self .log .info ("Test that a transaction with non-DER signature can still appear in a block" )
7179
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 ])
7481 unDERify (spendtx )
7582 spendtx .rehash ()
7683
@@ -104,8 +111,7 @@ def run_test(self):
104111 self .log .info ("Test that transactions with non-DER signatures cannot appear in a block" )
105112 block .nVersion = 3
106113
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 ])
109115 unDERify (spendtx )
110116 spendtx .rehash ()
111117
@@ -133,7 +139,7 @@ def run_test(self):
133139 peer .sync_with_ping ()
134140
135141 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 ])
137143 block .hashMerkleRoot = block .calc_merkle_root ()
138144 block .rehash ()
139145 block .solve ()
0 commit comments