Skip to content

Commit bf33bf3

Browse files
MarcoFalkeknst
authored andcommitted
Merge 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 (bitcoin#21945). ACKs for top commit: MarcoFalke: cr ACK 3e05a57 Tree-SHA512: 0fb8da8ed8b47f68bcb57301eb4f0171a6c9e44539b7554626969347e5d6f80b3b9085f2cc160cd038a990f0d81b8b614846260fbed43b5f950d77f1b7aa81cf
1 parent 7a74805 commit bf33bf3

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

test/functional/feature_dersig.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
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
@@ -16,6 +19,10 @@
1619
assert_equal,
1720
assert_raises_rpc_error,
1821
)
22+
from test_framework.wallet import (
23+
MiniWallet,
24+
MiniWalletMode,
25+
)
1926

2027
DERSIG_HEIGHT = 1251
2128

@@ -44,6 +51,10 @@ def set_test_params(self):
4451
self.setup_clean_chain = True
4552
self.rpc_timeout = 240
4653

54+
def create_tx(self, input_txid):
55+
utxo_to_spend = self.miniwallet.get_utxo(txid=input_txid, mark_as_spent=False)
56+
return self.miniwallet.create_self_transfer(from_node=self.nodes[0], utxo_to_spend=utxo_to_spend)['tx']
57+
4758
def test_dersig_info(self, *, is_active):
4859
assert_equal(self.nodes[0].getblockchaininfo()['softforks']['bip66'],
4960
{
@@ -53,22 +64,18 @@ def test_dersig_info(self, *, is_active):
5364
},
5465
)
5566

56-
def skip_test_if_missing_module(self):
57-
self.skip_if_no_wallet()
58-
5967
def run_test(self):
6068
peer = self.nodes[0].add_p2p_connection(P2PInterface())
69+
self.miniwallet = MiniWallet(self.nodes[0], mode=MiniWalletMode.RAW_P2PK)
6170

6271
self.test_dersig_info(is_active=False)
6372

6473
self.log.info("Mining %d blocks", DERSIG_HEIGHT - 2)
65-
self.coinbase_txids = [self.nodes[0].getblock(b)['tx'][0] for b in self.nodes[0].generate(DERSIG_HEIGHT - 2)]
66-
self.nodeaddress = self.nodes[0].getnewaddress()
74+
self.coinbase_txids = [self.nodes[0].getblock(b)['tx'][0] for b in self.miniwallet.generate(DERSIG_HEIGHT - 2)]
6775

6876
self.log.info("Test that a transaction with non-DER signature can still appear in a block")
6977

70-
spendtx = create_transaction(self.nodes[0], self.coinbase_txids[0],
71-
self.nodeaddress, amount=1.0)
78+
spendtx = self.create_tx(self.coinbase_txids[0])
7279
unDERify(spendtx)
7380
spendtx.rehash()
7481

@@ -102,8 +109,7 @@ def run_test(self):
102109
self.log.info("Test that transactions with non-DER signatures cannot appear in a block")
103110
block.nVersion = 3
104111

105-
spendtx = create_transaction(self.nodes[0], self.coinbase_txids[1],
106-
self.nodeaddress, amount=1.0)
112+
spendtx = self.create_tx(self.coinbase_txids[1])
107113
unDERify(spendtx)
108114
spendtx.rehash()
109115

@@ -123,7 +129,7 @@ def run_test(self):
123129
peer.sync_with_ping()
124130

125131
self.log.info("Test that a version 3 block with a DERSIG-compliant transaction is accepted")
126-
block.vtx[1] = create_transaction(self.nodes[0], self.coinbase_txids[1], self.nodeaddress, amount=1.0)
132+
block.vtx[1] = self.create_tx(self.coinbase_txids[1])
127133
block.hashMerkleRoot = block.calc_merkle_root()
128134
block.rehash()
129135
block.solve()

0 commit comments

Comments
 (0)