1212from decimal import Decimal
1313from test_framework .test_framework import BitcoinTestFramework
1414from 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
1720class 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