13
13
from collections import defaultdict
14
14
import time
15
15
16
- from test_framework .messages import CInv , MSG_BLOCK , msg_getdata
16
+ from test_framework .messages import (
17
+ CInv ,
18
+ MSG_BLOCK ,
19
+ msg_getdata ,
20
+ )
17
21
from test_framework .p2p import P2PInterface
18
22
from test_framework .test_framework import BitcoinTestFramework
19
- from test_framework .util import assert_equal , mine_large_block
23
+ from test_framework .util import (
24
+ assert_equal ,
25
+ mine_large_block ,
26
+ )
27
+ from test_framework .wallet import MiniWallet
28
+
20
29
21
30
class TestP2PConn (P2PInterface ):
22
31
def __init__ (self ):
@@ -41,12 +50,6 @@ def set_test_params(self):
41
50
]]
42
51
self .supports_cli = False
43
52
44
- # Cache for utxos, as the listunspent may take a long time later in the test
45
- self .utxo_cache = []
46
-
47
- def skip_test_if_missing_module (self ):
48
- self .skip_if_no_wallet ()
49
-
50
53
def run_test (self ):
51
54
# Before we connect anything, we first set the time on the node
52
55
# to be in the past, otherwise things break because the CNode
@@ -55,7 +58,8 @@ def run_test(self):
55
58
self .nodes [0 ].setmocktime (old_time )
56
59
57
60
# Generate some old blocks
58
- self .generate (self .nodes [0 ], 130 )
61
+ self .wallet = MiniWallet (self .nodes [0 ])
62
+ self .generate (self .wallet , 130 )
59
63
60
64
# p2p_conns[0] will only request old blocks
61
65
# p2p_conns[1] will only request new blocks
@@ -66,7 +70,7 @@ def run_test(self):
66
70
p2p_conns .append (self .nodes [0 ].add_p2p_connection (TestP2PConn ()))
67
71
68
72
# Now mine a big block
69
- mine_large_block (self , self .nodes [ 0 ] , self .utxo_cache )
73
+ mine_large_block (self , self .wallet , self .nodes [ 0 ] )
70
74
71
75
# Store the hash; we'll request this later
72
76
big_old_block = self .nodes [0 ].getbestblockhash ()
@@ -77,7 +81,7 @@ def run_test(self):
77
81
self .nodes [0 ].setmocktime (int (time .time ()) - 2 * 60 * 60 * 24 )
78
82
79
83
# Mine one more block, so that the prior block looks old
80
- mine_large_block (self , self .nodes [ 0 ] , self .utxo_cache )
84
+ mine_large_block (self , self .wallet , self .nodes [ 0 ] )
81
85
82
86
# We'll be requesting this new block too
83
87
big_new_block = self .nodes [0 ].getbestblockhash ()
0 commit comments