Skip to content

Commit 8600934

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#22057: test: use MiniWallet (P2PK mode) for feature_dersig.py
3e05a57 test: use MiniWallet (P2PK mode) for feature_dersig.py (Sebastian Falbesoner) Pull request description: This PR enables one more of the non-wallet functional tests (feature_dersig.py) to be run even with the Bitcoin Core wallet disabled. A valid DER-signature is created by using the recently introduced P2PK-Mode of the MiniWallet (#21945). ACKs for top commit: MarcoFalke: cr ACK 3e05a57 Tree-SHA512: 0fb8da8ed8b47f68bcb57301eb4f0171a6c9e44539b7554626969347e5d6f80b3b9085f2cc160cd038a990f0d81b8b614846260fbed43b5f950d77f1b7aa81cf
2 parents 6b25481 + 3e05a57 commit 8600934

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

test/functional/feature_dersig.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,21 @@
77
Test 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+
)
1114
from test_framework.messages import msg_block
1215
from test_framework.p2p import P2PInterface
1316
from test_framework.script import CScript
1417
from test_framework.test_framework import BitcoinTestFramework
1518
from test_framework.util import (
1619
assert_equal,
1720
)
21+
from test_framework.wallet import (
22+
MiniWallet,
23+
MiniWalletMode,
24+
)
1825

1926
DERSIG_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

Comments
 (0)