75
75
assert_equal ,
76
76
bytes_to_hex_str ,
77
77
connect_nodes ,
78
+ disconnect_nodes ,
78
79
get_bip9_status ,
79
80
hex_str_to_bytes ,
80
81
sync_blocks ,
@@ -236,37 +237,30 @@ def run_test(self):
236
237
# Keep a place to store utxo's that can be used in later tests
237
238
self .utxo = []
238
239
240
+ # Segwit status 'defined'
239
241
self .segwit_status = 'defined'
240
242
241
243
self .test_non_witness_transaction ()
242
244
self .test_unnecessary_witness_before_segwit_activation ()
243
245
self .test_v0_outputs_arent_spendable ()
244
246
self .test_block_relay ()
245
-
246
- # Advance to segwit being 'started'
247
247
self .advance_to_segwit_started ()
248
- sync_blocks (self .nodes )
249
- self .test_getblocktemplate_before_lockin ()
250
248
251
- sync_blocks ( self . nodes )
249
+ # Segwit status 'started'
252
250
253
- # At lockin, nothing should change.
251
+ self . test_getblocktemplate_before_lockin ()
254
252
self .advance_to_segwit_lockin ()
255
253
256
- # Retest unnecessary witnesses
254
+ # Segwit status 'locked_in'
255
+
257
256
self .test_unnecessary_witness_before_segwit_activation ()
258
257
self .test_witness_tx_relay_before_segwit_activation ()
259
258
self .test_block_relay ()
260
259
self .test_standardness_v0 ()
261
-
262
- sync_blocks (self .nodes )
263
-
264
- # Now activate segwit
265
260
self .advance_to_segwit_active ()
266
261
267
- sync_blocks ( self . nodes )
262
+ # Segwit status 'active'
268
263
269
- # Test P2SH witness handling again
270
264
self .test_p2sh_witness ()
271
265
self .test_witness_commitments ()
272
266
self .test_block_malleability ()
@@ -285,7 +279,6 @@ def run_test(self):
285
279
self .test_signature_version_1 ()
286
280
self .test_non_standard_witness_blinding ()
287
281
self .test_non_standard_witness ()
288
- sync_blocks (self .nodes )
289
282
self .test_upgrade_after_activation ()
290
283
self .test_witness_sigops ()
291
284
@@ -300,6 +293,7 @@ def func_wrapper(self, *args, **kwargs):
300
293
func (self , * args , ** kwargs )
301
294
# Each subtest should leave some utxos for the next subtest
302
295
assert self .utxo
296
+ sync_blocks (self .nodes )
303
297
# Assert segwit status is as expected at end of subtest
304
298
assert_equal (get_bip9_status (self .nodes [0 ], 'segwit' )['status' ], self .segwit_status )
305
299
@@ -368,8 +362,6 @@ def test_unnecessary_witness_before_segwit_activation(self):
368
362
self .test_node .sync_with_ping ()
369
363
assert_equal (self .nodes [0 ].getbestblockhash (), block .hash )
370
364
371
- sync_blocks (self .nodes )
372
-
373
365
# Update our utxo list; we spent the first entry.
374
366
self .utxo .pop (0 )
375
367
self .utxo .append (UTXO (tx .sha256 , 0 , tx .vout [0 ].nValue ))
@@ -482,6 +474,11 @@ def test_v0_outputs_arent_spendable(self):
482
474
witness, and so can't be spent before segwit activation (the point at which
483
475
blocks are permitted to contain witnesses)."""
484
476
477
+ # node2 doesn't need to be connected for this test.
478
+ # (If it's connected, node0 may propogate an invalid block to it over
479
+ # compact blocks and the nodes would have inconsistent tips.)
480
+ disconnect_nodes (self .nodes [0 ], 2 )
481
+
485
482
# Create two outputs, a p2wsh and p2sh-p2wsh
486
483
witness_program = CScript ([OP_TRUE ])
487
484
witness_hash = sha256 (witness_program )
@@ -542,6 +539,8 @@ def test_v0_outputs_arent_spendable(self):
542
539
# TODO: support multiple acceptable reject reasons.
543
540
test_witness_block (self .nodes [0 ], self .test_node , block , accepted = False , with_witness = False )
544
541
542
+ connect_nodes (self .nodes [0 ], 2 )
543
+
545
544
self .utxo .pop (0 )
546
545
self .utxo .append (UTXO (txid , 2 , value ))
547
546
@@ -1964,9 +1963,6 @@ def test_non_standard_witness(self):
1964
1963
def test_upgrade_after_activation (self ):
1965
1964
"""Test the behavior of starting up a segwit-aware node after the softfork has activated."""
1966
1965
1967
- # Make sure the nodes are all up
1968
- sync_blocks (self .nodes )
1969
-
1970
1966
# Restart with the new binary
1971
1967
self .stop_node (2 )
1972
1968
self .start_node (2 , extra_args = ["-vbparams=segwit:0:999999999999" ])
0 commit comments