12
12
from decimal import Decimal
13
13
from test_framework .test_framework import BitcoinTestFramework
14
14
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
15
18
16
19
17
20
class MempoolUpdateFromBlockTest (BitcoinTestFramework ):
18
21
def set_test_params (self ):
19
22
self .num_nodes = 1
20
23
self .extra_args = [['-limitdescendantsize=1000' , '-limitancestorsize=1000' , '-limitancestorcount=100' ]]
21
24
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
24
32
25
33
def transaction_graph_test (self , size , n_tx_to_mine = None , start_input_txid = '' , end_address = '' , fee = Decimal (0.00100000 )):
26
34
"""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
38
46
More details: https://en.wikipedia.org/wiki/Tournament_(graph_theory)
39
47
"""
40
48
49
+ self .priv_keys = [self .nodes [0 ].get_deterministic_priv_key ().key ]
41
50
if not start_input_txid :
42
51
start_input_txid = self .nodes [0 ].getblock (self .nodes [0 ].getblockhash (1 ))['tx' ][0 ]
43
52
44
53
if not end_address :
45
- end_address = self .nodes [ 0 ]. getnewaddress ()
54
+ end_address = self .get_new_address ()
46
55
47
56
first_block_hash = ''
48
57
tx_id = []
@@ -74,7 +83,7 @@ def transaction_graph_test(self, size, n_tx_to_mine=None, start_input_txid='', e
74
83
output_value = ((inputs_value - fee ) / Decimal (n_outputs )).quantize (Decimal ('0.00000001' ))
75
84
outputs = {}
76
85
for _ in range (n_outputs ):
77
- outputs [self .nodes [ 0 ]. getnewaddress ()] = output_value
86
+ outputs [self .get_new_address ()] = output_value
78
87
else :
79
88
output_value = (inputs_value - fee ).quantize (Decimal ('0.00000001' ))
80
89
outputs = {end_address : output_value }
@@ -84,7 +93,7 @@ def transaction_graph_test(self, size, n_tx_to_mine=None, start_input_txid='', e
84
93
85
94
# Create a new transaction.
86
95
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 )
88
97
tx_id .append (self .nodes [0 ].sendrawtransaction (signed_raw_tx ['hex' ]))
89
98
tx_size .append (self .nodes [0 ].getmempoolentry (tx_id [- 1 ])['vsize' ])
90
99
0 commit comments