17
17
from test_framework .util import (
18
18
assert_equal ,
19
19
assert_raises_rpc_error ,
20
+ ensure_for ,
20
21
)
21
22
from test_framework .wallet import MiniWallet
22
23
@@ -34,17 +35,18 @@ def add_options(self, parser):
34
35
35
36
def set_test_params (self ):
36
37
"""Use the pregenerated, deterministic chain up to height 199."""
37
- self .num_nodes = 2
38
+ self .num_nodes = 3
38
39
self .rpc_timeout = 120
39
40
self .extra_args = [
40
41
[],
41
42
[],
43
+ [],
42
44
]
43
45
44
46
def setup_network (self ):
45
47
"""Start with the nodes disconnected so that one can generate a snapshot
46
48
including blocks the other hasn't yet seen."""
47
- self .add_nodes (2 )
49
+ self .add_nodes (3 )
48
50
self .start_nodes (extra_args = self .extra_args )
49
51
50
52
def run_test (self ):
@@ -57,6 +59,7 @@ def run_test(self):
57
59
"""
58
60
n0 = self .nodes [0 ]
59
61
n1 = self .nodes [1 ]
62
+ n2 = self .nodes [2 ]
60
63
61
64
self .mini_wallet = MiniWallet (n0 )
62
65
@@ -88,6 +91,7 @@ def run_test(self):
88
91
89
92
# make n1 aware of the new header, but don't give it the block.
90
93
n1 .submitheader (newblock )
94
+ n2 .submitheader (newblock )
91
95
92
96
# Ensure everyone is seeing the same headers.
93
97
for n in self .nodes :
@@ -125,6 +129,7 @@ def run_test(self):
125
129
126
130
assert_equal (n0 .getblockcount (), FINAL_HEIGHT )
127
131
assert_equal (n1 .getblockcount (), START_HEIGHT )
132
+ assert_equal (n2 .getblockcount (), START_HEIGHT )
128
133
129
134
assert_equal (n0 .getblockchaininfo ()["blocks" ], FINAL_HEIGHT )
130
135
@@ -192,6 +197,13 @@ def run_test(self):
192
197
w = n1 .get_wallet_rpc ("w" )
193
198
assert_equal (w .getbalance (), 34 )
194
199
200
+ self .log .info ("Check balance of a wallet that is active during snapshot completion" )
201
+ n2 .restorewallet ("w" , "backup_w.dat" )
202
+ loaded = n2 .loadtxoutset (dump_output ['path' ])
203
+ self .connect_nodes (0 , 2 )
204
+ self .wait_until (lambda : len (n2 .getchainstates ()['chainstates' ]) == 1 )
205
+ ensure_for (duration = 1 , f = lambda : (n2 .getbalance () == 34 ))
206
+
195
207
196
208
if __name__ == '__main__' :
197
209
AssumeutxoTest (__file__ ).main ()
0 commit comments