Skip to content

Commit 67c6b61

Browse files
author
MacroFake
committed
Merge bitcoin/bitcoin#25525: test: remove wallet dependency from mempool_updatefromblock.py
eac1099 test: remove wallet dependency from mempool_updatefromblock.py (Ayush Sharma) Pull request description: This PR enables one of the non-wallet functional tests(`mempool_updatefromblock.py`) to be run with the wallet disabled. ACKs for top commit: aureleoules: tACK eac1099. Tree-SHA512: 9734815f2d2e65e8813bd776cf1d847a55ba4181e218c5e7b066ec69a556261069214f675681d672f5d7b0ba8e06342c4a456619dcc005cbf5618a0527303b7f
2 parents aeab1b4 + eac1099 commit 67c6b61

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

test/functional/mempool_updatefromblock.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,23 @@
1212
from decimal import Decimal
1313
from test_framework.test_framework import BitcoinTestFramework
1414
from test_framework.util import assert_equal
15+
from test_framework.address import key_to_p2pkh
16+
from test_framework.wallet_util import bytes_to_wif
17+
from test_framework.key import ECKey
1518

1619

1720
class MempoolUpdateFromBlockTest(BitcoinTestFramework):
1821
def set_test_params(self):
1922
self.num_nodes = 1
2023
self.extra_args = [['-limitdescendantsize=1000', '-limitancestorsize=1000', '-limitancestorcount=100']]
2124

22-
def skip_test_if_missing_module(self):
23-
self.skip_if_no_wallet()
25+
def get_new_address(self):
26+
key = ECKey()
27+
key.generate()
28+
pubkey = key.get_pubkey().get_bytes()
29+
address = key_to_p2pkh(pubkey)
30+
self.priv_keys.append(bytes_to_wif(key.get_bytes()))
31+
return address
2432

2533
def transaction_graph_test(self, size, n_tx_to_mine=None, start_input_txid='', end_address='', fee=Decimal(0.00100000)):
2634
"""Create an acyclic tournament (a type of directed graph) of transactions and use it for testing.
@@ -38,11 +46,12 @@ def transaction_graph_test(self, size, n_tx_to_mine=None, start_input_txid='', e
3846
More details: https://en.wikipedia.org/wiki/Tournament_(graph_theory)
3947
"""
4048

49+
self.priv_keys = [self.nodes[0].get_deterministic_priv_key().key]
4150
if not start_input_txid:
4251
start_input_txid = self.nodes[0].getblock(self.nodes[0].getblockhash(1))['tx'][0]
4352

4453
if not end_address:
45-
end_address = self.nodes[0].getnewaddress()
54+
end_address = self.get_new_address()
4655

4756
first_block_hash = ''
4857
tx_id = []
@@ -74,7 +83,7 @@ def transaction_graph_test(self, size, n_tx_to_mine=None, start_input_txid='', e
7483
output_value = ((inputs_value - fee) / Decimal(n_outputs)).quantize(Decimal('0.00000001'))
7584
outputs = {}
7685
for _ in range(n_outputs):
77-
outputs[self.nodes[0].getnewaddress()] = output_value
86+
outputs[self.get_new_address()] = output_value
7887
else:
7988
output_value = (inputs_value - fee).quantize(Decimal('0.00000001'))
8089
outputs = {end_address: output_value}
@@ -84,7 +93,7 @@ def transaction_graph_test(self, size, n_tx_to_mine=None, start_input_txid='', e
8493

8594
# Create a new transaction.
8695
unsigned_raw_tx = self.nodes[0].createrawtransaction(inputs, outputs)
87-
signed_raw_tx = self.nodes[0].signrawtransactionwithwallet(unsigned_raw_tx)
96+
signed_raw_tx = self.nodes[0].signrawtransactionwithkey(unsigned_raw_tx, self.priv_keys)
8897
tx_id.append(self.nodes[0].sendrawtransaction(signed_raw_tx['hex']))
8998
tx_size.append(self.nodes[0].getmempoolentry(tx_id[-1])['vsize'])
9099

0 commit comments

Comments
 (0)