@@ -80,13 +80,6 @@ def sync(self, test_function, timeout=60):
8080 timeout -= self .sleep_time
8181 raise AssertionError ("Sync failed to complete" )
8282
83- def sync_with_ping (self , timeout = 60 ):
84- self .send_message (msg_ping (nonce = self .ping_counter ))
85- test_function = lambda : self .last_pong .nonce == self .ping_counter
86- self .sync (test_function , timeout )
87- self .ping_counter += 1
88- return
89-
9083 def wait_for_block (self , blockhash , timeout = 60 ):
9184 test_function = lambda : self .last_block != None and self .last_block .sha256 == blockhash
9285 self .sync (test_function , timeout )
@@ -148,7 +141,7 @@ def test_transaction_acceptance(self, tx, with_witness, accepted, reason=None):
148141 if with_witness :
149142 tx_message = msg_witness_tx (tx )
150143 self .send_message (tx_message )
151- self .sync_with_ping ()
144+ self .sync_with_ping (60 )
152145 assert_equal (tx .hash in self .connection .rpc .getrawmempool (), accepted )
153146 if (reason != None and not accepted ):
154147 # Check the rejection reason as well.
@@ -161,7 +154,7 @@ def test_witness_block(self, block, accepted, with_witness=True):
161154 self .send_message (msg_witness_block (block ))
162155 else :
163156 self .send_message (msg_block (block ))
164- self .sync_with_ping ()
157+ self .sync_with_ping (60 )
165158 assert_equal (self .connection .rpc .getbestblockhash () == block .hash , accepted )
166159
167160
@@ -235,7 +228,7 @@ def test_non_witness_transaction(self):
235228 block = self .build_next_block (nVersion = 1 )
236229 block .solve ()
237230 self .test_node .send_message (msg_block (block ))
238- self .test_node .sync_with_ping () # make sure the block was processed
231+ self .test_node .sync_with_ping (60 ) # make sure the block was processed
239232 txid = block .vtx [0 ].sha256
240233
241234 self .nodes [0 ].generate (99 ) # let the block mature
@@ -251,7 +244,7 @@ def test_non_witness_transaction(self):
251244 assert_equal (msg_tx (tx ).serialize (), msg_witness_tx (tx ).serialize ())
252245
253246 self .test_node .send_message (msg_witness_tx (tx ))
254- self .test_node .sync_with_ping () # make sure the tx was processed
247+ self .test_node .sync_with_ping (60 ) # make sure the tx was processed
255248 assert (tx .hash in self .nodes [0 ].getrawmempool ())
256249 # Save this transaction for later
257250 self .utxo .append (UTXO (tx .sha256 , 0 , 49 * 100000000 ))
@@ -291,7 +284,7 @@ def test_unnecessary_witness_before_segwit_activation(self):
291284 # But it should not be permanently marked bad...
292285 # Resend without witness information.
293286 self .test_node .send_message (msg_block (block ))
294- self .test_node .sync_with_ping ()
287+ self .test_node .sync_with_ping (60 )
295288 assert_equal (self .nodes [0 ].getbestblockhash (), block .hash )
296289
297290 sync_blocks (self .nodes )
@@ -1257,7 +1250,7 @@ def test_segwit_versions(self):
12571250 # Spending a higher version witness output is not allowed by policy,
12581251 # even with fRequireStandard=false.
12591252 self .test_node .test_transaction_acceptance (tx3 , with_witness = True , accepted = False )
1260- self .test_node .sync_with_ping ()
1253+ self .test_node .sync_with_ping (60 )
12611254 with mininode_lock :
12621255 assert (b"reserved for soft-fork upgrades" in self .test_node .last_reject .reason )
12631256
@@ -1387,7 +1380,7 @@ def test_signature_version_1(self):
13871380 for i in range (NUM_TESTS ):
13881381 # Ping regularly to keep the connection alive
13891382 if (not i % 100 ):
1390- self .test_node .sync_with_ping ()
1383+ self .test_node .sync_with_ping (60 )
13911384 # Choose random number of inputs to use.
13921385 num_inputs = random .randint (1 , 10 )
13931386 # Create a slight bias for producing more utxos
0 commit comments