aboutsummaryrefslogtreecommitdiff
path: root/test/functional/p2p_segwit.py
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-08-27 16:36:17 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-09-16 18:52:19 +0200
commitfaa46986aaec69e4cf016101ae517ce8778e2ac5 (patch)
treeac5e11c632980775ca9f0e6b49e04de13dbb1aa2 /test/functional/p2p_segwit.py
parentfa086ef5398b5ffded86e4f0d6633c523cb774e9 (diff)
downloadbitcoin-faa46986aaec69e4cf016101ae517ce8778e2ac5.tar.xz
test: Remove version argument from build_next_block in p2p_segwit test
The block version does not have any effect on the segwit consensus rules or block relay logic. Same for feature_dersig.
Diffstat (limited to 'test/functional/p2p_segwit.py')
-rwxr-xr-xtest/functional/p2p_segwit.py26
1 files changed, 8 insertions, 18 deletions
diff --git a/test/functional/p2p_segwit.py b/test/functional/p2p_segwit.py
index a71f736bd6..1b316268d7 100755
--- a/test/functional/p2p_segwit.py
+++ b/test/functional/p2p_segwit.py
@@ -83,10 +83,6 @@ from test_framework.util import (
assert_raises_rpc_error,
)
-# The versionbit bit used to signal activation of SegWit
-VB_WITNESS_BIT = 1
-VB_TOP_BITS = 0x20000000
-
MAX_SIGOP_COST = 80000
SEGWIT_HEIGHT = 120
@@ -206,13 +202,13 @@ class SegWitTest(BitcoinTestFramework):
# Helper functions
- def build_next_block(self, version=4):
+ def build_next_block(self):
"""Build a block on top of node0's tip."""
tip = self.nodes[0].getbestblockhash()
height = self.nodes[0].getblockcount() + 1
block_time = self.nodes[0].getblockheader(tip)["mediantime"] + 1
block = create_block(int(tip, 16), create_coinbase(height), block_time)
- block.nVersion = version
+ block.nVersion = 4
block.rehash()
return block
@@ -298,7 +294,7 @@ class SegWitTest(BitcoinTestFramework):
# Mine a block with an anyone-can-spend coinbase,
# let it mature, then try to spend it.
- block = self.build_next_block(version=1)
+ block = self.build_next_block()
block.solve()
self.test_node.send_and_ping(msg_no_witness_block(block)) # make sure the block was processed
txid = block.vtx[0].sha256
@@ -336,8 +332,8 @@ class SegWitTest(BitcoinTestFramework):
tx.rehash()
assert tx.sha256 != tx.calc_sha256(with_witness=True)
- # Construct a segwit-signaling block that includes the transaction.
- block = self.build_next_block(version=(VB_TOP_BITS | (1 << VB_WITNESS_BIT)))
+ # Construct a block that includes the transaction.
+ block = self.build_next_block()
self.update_witness_block_with_transactions(block, [tx])
# Sending witness data before activation is not allowed (anti-spam
# rule).
@@ -364,7 +360,7 @@ class SegWitTest(BitcoinTestFramework):
# test_node has set NODE_WITNESS, so all getdata requests should be for
# witness blocks.
# Test announcing a block via inv results in a getdata, and that
- # announcing a version 4 or random VB block with a header results in a getdata
+ # announcing a block with a header results in a getdata
block1 = self.build_next_block()
block1.solve()
@@ -372,19 +368,13 @@ class SegWitTest(BitcoinTestFramework):
assert self.test_node.last_message["getdata"].inv[0].type == blocktype
test_witness_block(self.nodes[0], self.test_node, block1, True)
- block2 = self.build_next_block(version=4)
+ block2 = self.build_next_block()
block2.solve()
self.test_node.announce_block_and_wait_for_getdata(block2, use_header=True)
assert self.test_node.last_message["getdata"].inv[0].type == blocktype
test_witness_block(self.nodes[0], self.test_node, block2, True)
- block3 = self.build_next_block(version=(VB_TOP_BITS | (1 << 15)))
- block3.solve()
- self.test_node.announce_block_and_wait_for_getdata(block3, use_header=True)
- assert self.test_node.last_message["getdata"].inv[0].type == blocktype
- test_witness_block(self.nodes[0], self.test_node, block3, True)
-
# Check that we can getdata for witness blocks or regular blocks,
# and the right thing happens.
if not self.segwit_active:
@@ -429,7 +419,7 @@ class SegWitTest(BitcoinTestFramework):
assert_equal(rpc_details["weight"], block.get_weight())
# Upgraded node should not ask for blocks from unupgraded
- block4 = self.build_next_block(version=4)
+ block4 = self.build_next_block()
block4.solve()
self.old_node.getdataset = set()