7
7
to a hash that has been compiled into bitcoind.
8
8
9
9
The assumeutxo value generated and used here is committed to in
10
- `CRegTestParams::m_assumeutxo_data` in `src/chainparams.cpp`.
10
+ `CRegTestParams::m_assumeutxo_data` in `src/kernel/ chainparams.cpp`.
11
11
12
12
## Possible test improvements
13
13
40
40
assert_equal ,
41
41
assert_raises_rpc_error ,
42
42
)
43
- from test_framework .wallet import getnewdestination
44
-
43
+ from test_framework .wallet import (
44
+ getnewdestination ,
45
+ MiniWallet ,
46
+ )
45
47
46
48
START_HEIGHT = 199
47
49
SNAPSHOT_BASE_HEIGHT = 299
@@ -98,18 +100,18 @@ def expected_error(log_msg="", rpc_details=""):
98
100
99
101
self .log .info (" - snapshot file with alternated UTXO data" )
100
102
cases = [
101
- [b"\xff " * 32 , 0 , "05030e506678f2eca8d624ffed97090ab3beadad1b51ee6e5985ba91c5720e37 " ], # wrong outpoint hash
102
- [(1 ).to_bytes (4 , "little" ), 32 , "7d29cfe2c1e242bc6f103878bb70cfffa8b4dac20dbd001ff6ce24b7de2d2399 " ], # wrong outpoint index
103
- [b"\x81 " , 36 , "f03939a195531f96d5dff983e294a1af62af86049fa7a19a7627246f237c03f1 " ], # wrong coin code VARINT((coinbase ? 1 : 0) | (height << 1))
104
- [b"\x83 " , 36 , "e4577da84590fb288c0f7967e89575e1b0aa46624669640f6f5dfef028d39930 " ], # another wrong coin code
103
+ [b"\xff " * 32 , 0 , "7d52155c9a9fdc4525b637ef6170568e5dad6fabd0b1fdbb9432010b8453095b " ], # wrong outpoint hash
104
+ [(1 ).to_bytes (4 , "little" ), 32 , "9f4d897031ab8547665b4153317ae2fdbf0130c7840b66427ebc48b881cb80ad " ], # wrong outpoint index
105
+ [b"\x81 " , 36 , "3da966ba9826fb6d2604260e01607b55ba44e1a5de298606b08704bc62570ea8 " ], # wrong coin code VARINT((coinbase ? 1 : 0) | (height << 1))
106
+ [b"\x80 " , 36 , "091e893b3ccb4334378709578025356c8bcb0a623f37c7c4e493133c988648e5 " ], # another wrong coin code
105
107
]
106
108
107
109
for content , offset , wrong_hash in cases :
108
110
with open (bad_snapshot_path , "wb" ) as f :
109
111
f .write (valid_snapshot_contents [:(32 + 8 + offset )])
110
112
f .write (content )
111
113
f .write (valid_snapshot_contents [(32 + 8 + offset + len (content )):])
112
- expected_error (log_msg = f"[snapshot] bad snapshot content hash: expected 61d9c2b29a2571a5fe285fe2d8554f91f93309666fc9b8223ee96338de25ff53 , got { wrong_hash } " )
114
+ expected_error (log_msg = f"[snapshot] bad snapshot content hash: expected a4bf3407ccb2cc0145c49ebba8fa91199f8a3903daf0883875941497d2493c27 , got { wrong_hash } " )
113
115
114
116
def test_invalid_chainstate_scenarios (self ):
115
117
self .log .info ("Test different scenarios of invalid snapshot chainstate in datadir" )
@@ -145,6 +147,8 @@ def run_test(self):
145
147
n1 = self .nodes [1 ]
146
148
n2 = self .nodes [2 ]
147
149
150
+ self .mini_wallet = MiniWallet (n0 )
151
+
148
152
# Mock time for a deterministic chain
149
153
for n in self .nodes :
150
154
n .setmocktime (n .getblockheader (n .getbestblockhash ())['time' ])
@@ -157,6 +161,8 @@ def run_test(self):
157
161
# isn't waiting forever to see the header of the snapshot's base block
158
162
# while disconnected from n0.
159
163
for i in range (100 ):
164
+ if i % 3 == 0 :
165
+ self .mini_wallet .send_self_transfer (from_node = n0 )
160
166
self .generate (n0 , nblocks = 1 , sync_fun = self .no_op )
161
167
newblock = n0 .getblock (n0 .getbestblockhash (), 0 )
162
168
@@ -178,8 +184,8 @@ def run_test(self):
178
184
179
185
assert_equal (
180
186
dump_output ['txoutset_hash' ],
181
- '61d9c2b29a2571a5fe285fe2d8554f91f93309666fc9b8223ee96338de25ff53' )
182
- assert_equal (dump_output [' nchaintx' ], 300 )
187
+ "a4bf3407ccb2cc0145c49ebba8fa91199f8a3903daf0883875941497d2493c27" )
188
+ assert_equal (dump_output [" nchaintx" ], 334 )
183
189
assert_equal (n0 .getblockchaininfo ()["blocks" ], SNAPSHOT_BASE_HEIGHT )
184
190
185
191
# Mine more blocks on top of the snapshot that n1 hasn't yet seen. This
0 commit comments