@@ -241,7 +241,7 @@ def run_test(self):
241
241
self .test_non_witness_transaction ()
242
242
self .test_unnecessary_witness_before_segwit_activation ()
243
243
self .test_v0_outputs_arent_spendable ()
244
- self .test_block_relay (segwit_activated = False )
244
+ self .test_block_relay ()
245
245
246
246
# Advance to segwit being 'started'
247
247
self .advance_to_segwit_started ()
@@ -256,8 +256,8 @@ def run_test(self):
256
256
# Retest unnecessary witnesses
257
257
self .test_unnecessary_witness_before_segwit_activation ()
258
258
self .test_witness_tx_relay_before_segwit_activation ()
259
- self .test_block_relay (segwit_activated = False )
260
- self .test_standardness_v0 (segwit_activated = False )
259
+ self .test_block_relay ()
260
+ self .test_standardness_v0 ()
261
261
262
262
sync_blocks (self .nodes )
263
263
@@ -267,7 +267,7 @@ def run_test(self):
267
267
sync_blocks (self .nodes )
268
268
269
269
# Test P2SH witness handling again
270
- self .test_p2sh_witness (segwit_activated = True )
270
+ self .test_p2sh_witness ()
271
271
self .test_witness_commitments ()
272
272
self .test_block_malleability ()
273
273
self .test_witness_block_size ()
@@ -276,17 +276,17 @@ def run_test(self):
276
276
self .test_max_witness_push_length ()
277
277
self .test_max_witness_program_length ()
278
278
self .test_witness_input_length ()
279
- self .test_block_relay (segwit_activated = True )
279
+ self .test_block_relay ()
280
280
self .test_tx_relay_after_segwit_activation ()
281
- self .test_standardness_v0 (segwit_activated = True )
281
+ self .test_standardness_v0 ()
282
282
self .test_segwit_versions ()
283
283
self .test_premature_coinbase_witness_spend ()
284
284
self .test_uncompressed_pubkey ()
285
285
self .test_signature_version_1 ()
286
286
self .test_non_standard_witness_blinding ()
287
287
self .test_non_standard_witness ()
288
288
sync_blocks (self .nodes )
289
- self .test_upgrade_after_activation (node_id = 2 )
289
+ self .test_upgrade_after_activation ()
290
290
self .test_witness_sigops ()
291
291
292
292
# Individual tests
@@ -375,7 +375,7 @@ def test_unnecessary_witness_before_segwit_activation(self):
375
375
self .utxo .append (UTXO (tx .sha256 , 0 , tx .vout [0 ].nValue ))
376
376
377
377
@subtest
378
- def test_block_relay (self , segwit_activated ):
378
+ def test_block_relay (self ):
379
379
"""Test that block requests to NODE_WITNESS peer are with MSG_WITNESS_FLAG.
380
380
381
381
This is true regardless of segwit activation.
@@ -409,7 +409,7 @@ def test_block_relay(self, segwit_activated):
409
409
410
410
# Check that we can getdata for witness blocks or regular blocks,
411
411
# and the right thing happens.
412
- if not segwit_activated :
412
+ if self . segwit_status != 'active' :
413
413
# Before activation, we should be able to request old blocks with
414
414
# or without witness, and they should be the same.
415
415
chain_height = self .nodes [0 ].getblockcount ()
@@ -662,7 +662,7 @@ def test_witness_tx_relay_before_segwit_activation(self):
662
662
self .utxo .append (UTXO (tx_hash , 0 , tx_value ))
663
663
664
664
@subtest
665
- def test_standardness_v0 (self , segwit_activated ):
665
+ def test_standardness_v0 (self ):
666
666
"""Test V0 txout standardness.
667
667
668
668
V0 segwit outputs and inputs are always standard.
@@ -721,7 +721,7 @@ def test_standardness_v0(self, segwit_activated):
721
721
tx3 .wit .vtxinwit .append (CTxInWitness ())
722
722
tx3 .wit .vtxinwit [0 ].scriptWitness .stack = [witness_program ]
723
723
tx3 .rehash ()
724
- if not segwit_activated :
724
+ if self . segwit_status != 'active' :
725
725
# Just check mempool acceptance, but don't add the transaction to the mempool, since witness is disallowed
726
726
# in blocks and the tx is impossible to mine right now.
727
727
assert_equal (self .nodes [0 ].testmempoolaccept ([bytes_to_hex_str (tx3 .serialize_with_witness ())]), [{'txid' : tx3 .hash , 'allowed' : True }])
@@ -753,7 +753,7 @@ def advance_to_segwit_active(self):
753
753
self .segwit_status = 'active'
754
754
755
755
@subtest
756
- def test_p2sh_witness (self , segwit_activated ):
756
+ def test_p2sh_witness (self ):
757
757
"""Test P2SH wrapped witness programs."""
758
758
759
759
# Prepare the p2sh-wrapped witness output
@@ -774,7 +774,7 @@ def test_p2sh_witness(self, segwit_activated):
774
774
test_transaction_acceptance (self .nodes [0 ].rpc , self .test_node , tx , with_witness = False , accepted = True )
775
775
block = self .build_next_block ()
776
776
self .update_witness_block_with_transactions (block , [tx ])
777
- test_witness_block (self .nodes [0 ].rpc , self .test_node , block , accepted = True , with_witness = segwit_activated )
777
+ test_witness_block (self .nodes [0 ].rpc , self .test_node , block , accepted = True , with_witness = True )
778
778
sync_blocks (self .nodes )
779
779
780
780
# Now test attempts to spend the output.
@@ -803,18 +803,15 @@ def test_p2sh_witness(self, segwit_activated):
803
803
spend_tx .wit .vtxinwit [0 ].scriptWitness .stack = [b'a' , witness_program ]
804
804
805
805
# Verify mempool acceptance
806
- test_transaction_acceptance (self .nodes [0 ].rpc , self .test_node , spend_tx , with_witness = True , accepted = segwit_activated )
806
+ test_transaction_acceptance (self .nodes [0 ].rpc , self .test_node , spend_tx , with_witness = True , accepted = True )
807
807
block = self .build_next_block ()
808
808
self .update_witness_block_with_transactions (block , [spend_tx ])
809
809
810
810
# If we're after activation, then sending this with witnesses should be valid.
811
811
# This no longer works before activation, because SCRIPT_VERIFY_WITNESS
812
812
# is always set.
813
813
# TODO: rewrite this test to make clear that it only works after activation.
814
- if segwit_activated :
815
- test_witness_block (self .nodes [0 ].rpc , self .test_node , block , accepted = True )
816
- else :
817
- test_witness_block (self .nodes [0 ].rpc , self .test_node , block , accepted = True , with_witness = False )
814
+ test_witness_block (self .nodes [0 ].rpc , self .test_node , block , accepted = True )
818
815
819
816
# Update self.utxo
820
817
self .utxo .pop (0 )
@@ -1964,30 +1961,28 @@ def test_non_standard_witness(self):
1964
1961
self .utxo .pop (0 )
1965
1962
1966
1963
@subtest
1967
- def test_upgrade_after_activation (self , node_id ):
1964
+ def test_upgrade_after_activation (self ):
1968
1965
"""Test the behavior of starting up a segwit-aware node after the softfork has activated."""
1969
1966
1970
- assert (node_id != 0 ) # node0 is assumed to be a segwit-active bitcoind
1971
-
1972
1967
# Make sure the nodes are all up
1973
1968
sync_blocks (self .nodes )
1974
1969
1975
1970
# Restart with the new binary
1976
- self .stop_node (node_id )
1977
- self .start_node (node_id , extra_args = ["-vbparams=segwit:0:999999999999" ])
1978
- connect_nodes (self .nodes [0 ], node_id )
1971
+ self .stop_node (2 )
1972
+ self .start_node (2 , extra_args = ["-vbparams=segwit:0:999999999999" ])
1973
+ connect_nodes (self .nodes [0 ], 2 )
1979
1974
1980
1975
sync_blocks (self .nodes )
1981
1976
1982
1977
# Make sure that this peer thinks segwit has activated.
1983
- assert (get_bip9_status (self .nodes [node_id ], 'segwit' )['status' ] == "active" )
1978
+ assert (get_bip9_status (self .nodes [2 ], 'segwit' )['status' ] == "active" )
1984
1979
1985
1980
# Make sure this peer's blocks match those of node0.
1986
- height = self .nodes [node_id ].getblockcount ()
1981
+ height = self .nodes [2 ].getblockcount ()
1987
1982
while height >= 0 :
1988
- block_hash = self .nodes [node_id ].getblockhash (height )
1983
+ block_hash = self .nodes [2 ].getblockhash (height )
1989
1984
assert_equal (block_hash , self .nodes [0 ].getblockhash (height ))
1990
- assert_equal (self .nodes [0 ].getblock (block_hash ), self .nodes [node_id ].getblock (block_hash ))
1985
+ assert_equal (self .nodes [0 ].getblock (block_hash ), self .nodes [2 ].getblock (block_hash ))
1991
1986
height -= 1
1992
1987
1993
1988
@subtest
0 commit comments