83
83
assert_raises_rpc_error ,
84
84
)
85
85
86
- # The versionbit bit used to signal activation of SegWit
87
- VB_WITNESS_BIT = 1
88
- VB_TOP_BITS = 0x20000000
89
-
90
86
MAX_SIGOP_COST = 80000
91
87
92
88
SEGWIT_HEIGHT = 120
@@ -206,13 +202,13 @@ def skip_test_if_missing_module(self):
206
202
207
203
# Helper functions
208
204
209
- def build_next_block (self , version = 4 ):
205
+ def build_next_block (self ):
210
206
"""Build a block on top of node0's tip."""
211
207
tip = self .nodes [0 ].getbestblockhash ()
212
208
height = self .nodes [0 ].getblockcount () + 1
213
209
block_time = self .nodes [0 ].getblockheader (tip )["mediantime" ] + 1
214
210
block = create_block (int (tip , 16 ), create_coinbase (height ), block_time )
215
- block .nVersion = version
211
+ block .nVersion = 4
216
212
block .rehash ()
217
213
return block
218
214
@@ -298,7 +294,7 @@ def test_non_witness_transaction(self):
298
294
# Mine a block with an anyone-can-spend coinbase,
299
295
# let it mature, then try to spend it.
300
296
301
- block = self .build_next_block (version = 1 )
297
+ block = self .build_next_block ()
302
298
block .solve ()
303
299
self .test_node .send_and_ping (msg_no_witness_block (block )) # make sure the block was processed
304
300
txid = block .vtx [0 ].sha256
@@ -336,8 +332,8 @@ def test_unnecessary_witness_before_segwit_activation(self):
336
332
tx .rehash ()
337
333
assert tx .sha256 != tx .calc_sha256 (with_witness = True )
338
334
339
- # Construct a segwit-signaling block that includes the transaction.
340
- block = self .build_next_block (version = ( VB_TOP_BITS | ( 1 << VB_WITNESS_BIT )) )
335
+ # Construct a block that includes the transaction.
336
+ block = self .build_next_block ()
341
337
self .update_witness_block_with_transactions (block , [tx ])
342
338
# Sending witness data before activation is not allowed (anti-spam
343
339
# rule).
@@ -364,27 +360,21 @@ def test_block_relay(self):
364
360
# test_node has set NODE_WITNESS, so all getdata requests should be for
365
361
# witness blocks.
366
362
# Test announcing a block via inv results in a getdata, and that
367
- # announcing a version 4 or random VB block with a header results in a getdata
363
+ # announcing a block with a header results in a getdata
368
364
block1 = self .build_next_block ()
369
365
block1 .solve ()
370
366
371
367
self .test_node .announce_block_and_wait_for_getdata (block1 , use_header = False )
372
368
assert self .test_node .last_message ["getdata" ].inv [0 ].type == blocktype
373
369
test_witness_block (self .nodes [0 ], self .test_node , block1 , True )
374
370
375
- block2 = self .build_next_block (version = 4 )
371
+ block2 = self .build_next_block ()
376
372
block2 .solve ()
377
373
378
374
self .test_node .announce_block_and_wait_for_getdata (block2 , use_header = True )
379
375
assert self .test_node .last_message ["getdata" ].inv [0 ].type == blocktype
380
376
test_witness_block (self .nodes [0 ], self .test_node , block2 , True )
381
377
382
- block3 = self .build_next_block (version = (VB_TOP_BITS | (1 << 15 )))
383
- block3 .solve ()
384
- self .test_node .announce_block_and_wait_for_getdata (block3 , use_header = True )
385
- assert self .test_node .last_message ["getdata" ].inv [0 ].type == blocktype
386
- test_witness_block (self .nodes [0 ], self .test_node , block3 , True )
387
-
388
378
# Check that we can getdata for witness blocks or regular blocks,
389
379
# and the right thing happens.
390
380
if not self .segwit_active :
@@ -429,7 +419,7 @@ def test_block_relay(self):
429
419
assert_equal (rpc_details ["weight" ], block .get_weight ())
430
420
431
421
# Upgraded node should not ask for blocks from unupgraded
432
- block4 = self .build_next_block (version = 4 )
422
+ block4 = self .build_next_block ()
433
423
block4 .solve ()
434
424
self .old_node .getdataset = set ()
435
425
0 commit comments