@@ -97,11 +97,9 @@ def run_test(self):
97
97
blocks_h2 .append (create_block (tips [i ], create_coinbase (2 ), block_time ))
98
98
blocks_h2 [i ].solve ()
99
99
block_time += 1
100
- test_node .send_message (msg_block (blocks_h2 [0 ]))
101
- min_work_node .send_message (msg_block (blocks_h2 [1 ]))
100
+ test_node .send_and_ping (msg_block (blocks_h2 [0 ]))
101
+ min_work_node .send_and_ping (msg_block (blocks_h2 [1 ]))
102
102
103
- for x in [test_node , min_work_node ]:
104
- x .sync_with_ping ()
105
103
assert_equal (self .nodes [0 ].getblockcount (), 2 )
106
104
assert_equal (self .nodes [1 ].getblockcount (), 1 )
107
105
self .log .info ("First height 2 block accepted by node0; correctly rejected by node1" )
@@ -110,9 +108,8 @@ def run_test(self):
110
108
block_h1f = create_block (int ("0x" + self .nodes [0 ].getblockhash (0 ), 0 ), create_coinbase (1 ), block_time )
111
109
block_time += 1
112
110
block_h1f .solve ()
113
- test_node .send_message (msg_block (block_h1f ))
111
+ test_node .send_and_ping (msg_block (block_h1f ))
114
112
115
- test_node .sync_with_ping ()
116
113
tip_entry_found = False
117
114
for x in self .nodes [0 ].getchaintips ():
118
115
if x ['hash' ] == block_h1f .hash :
@@ -125,9 +122,8 @@ def run_test(self):
125
122
block_h2f = create_block (block_h1f .sha256 , create_coinbase (2 ), block_time )
126
123
block_time += 1
127
124
block_h2f .solve ()
128
- test_node .send_message (msg_block (block_h2f ))
125
+ test_node .send_and_ping (msg_block (block_h2f ))
129
126
130
- test_node .sync_with_ping ()
131
127
# Since the earlier block was not processed by node, the new block
132
128
# can't be fully validated.
133
129
tip_entry_found = False
@@ -144,9 +140,8 @@ def run_test(self):
144
140
# 4b. Now send another block that builds on the forking chain.
145
141
block_h3 = create_block (block_h2f .sha256 , create_coinbase (3 ), block_h2f .nTime + 1 )
146
142
block_h3 .solve ()
147
- test_node .send_message (msg_block (block_h3 ))
143
+ test_node .send_and_ping (msg_block (block_h3 ))
148
144
149
- test_node .sync_with_ping ()
150
145
# Since the earlier block was not processed by node, the new block
151
146
# can't be fully validated.
152
147
tip_entry_found = False
@@ -172,17 +167,15 @@ def run_test(self):
172
167
tip = next_block
173
168
174
169
# Now send the block at height 5 and check that it wasn't accepted (missing header)
175
- test_node .send_message (msg_block (all_blocks [1 ]))
176
- test_node .sync_with_ping ()
170
+ test_node .send_and_ping (msg_block (all_blocks [1 ]))
177
171
assert_raises_rpc_error (- 5 , "Block not found" , self .nodes [0 ].getblock , all_blocks [1 ].hash )
178
172
assert_raises_rpc_error (- 5 , "Block not found" , self .nodes [0 ].getblockheader , all_blocks [1 ].hash )
179
173
180
174
# The block at height 5 should be accepted if we provide the missing header, though
181
175
headers_message = msg_headers ()
182
176
headers_message .headers .append (CBlockHeader (all_blocks [0 ]))
183
177
test_node .send_message (headers_message )
184
- test_node .send_message (msg_block (all_blocks [1 ]))
185
- test_node .sync_with_ping ()
178
+ test_node .send_and_ping (msg_block (all_blocks [1 ]))
186
179
self .nodes [0 ].getblock (all_blocks [1 ].hash )
187
180
188
181
# Now send the blocks in all_blocks
@@ -207,9 +200,7 @@ def run_test(self):
207
200
208
201
test_node = self .nodes [0 ].add_p2p_connection (P2PInterface ())
209
202
210
- test_node .send_message (msg_block (block_h1f ))
211
-
212
- test_node .sync_with_ping ()
203
+ test_node .send_and_ping (msg_block (block_h1f ))
213
204
assert_equal (self .nodes [0 ].getblockcount (), 2 )
214
205
self .log .info ("Unrequested block that would complete more-work chain was ignored" )
215
206
@@ -230,9 +221,7 @@ def run_test(self):
230
221
self .log .info ("Inv at tip triggered getdata for unprocessed block" )
231
222
232
223
# 7. Send the missing block for the third time (now it is requested)
233
- test_node .send_message (msg_block (block_h1f ))
234
-
235
- test_node .sync_with_ping ()
224
+ test_node .send_and_ping (msg_block (block_h1f ))
236
225
assert_equal (self .nodes [0 ].getblockcount (), 290 )
237
226
self .nodes [0 ].getblock (all_blocks [286 ].hash )
238
227
assert_equal (self .nodes [0 ].getbestblockhash (), all_blocks [286 ].hash )
@@ -259,9 +248,8 @@ def run_test(self):
259
248
headers_message .headers .append (CBlockHeader (block_290f ))
260
249
headers_message .headers .append (CBlockHeader (block_291 ))
261
250
headers_message .headers .append (CBlockHeader (block_292 ))
262
- test_node .send_message (headers_message )
251
+ test_node .send_and_ping (headers_message )
263
252
264
- test_node .sync_with_ping ()
265
253
tip_entry_found = False
266
254
for x in self .nodes [0 ].getchaintips ():
267
255
if x ['hash' ] == block_292 .hash :
@@ -271,9 +259,8 @@ def run_test(self):
271
259
assert_raises_rpc_error (- 1 , "Block not found on disk" , self .nodes [0 ].getblock , block_292 .hash )
272
260
273
261
test_node .send_message (msg_block (block_289f ))
274
- test_node .send_message (msg_block (block_290f ))
262
+ test_node .send_and_ping (msg_block (block_290f ))
275
263
276
- test_node .sync_with_ping ()
277
264
self .nodes [0 ].getblock (block_289f .hash )
278
265
self .nodes [0 ].getblock (block_290f .hash )
279
266
0 commit comments