mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-19 09:53:47 +01:00
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.
This commit is contained in:
parent
fa086ef539
commit
faa46986aa
@ -83,7 +83,6 @@ class BIP66Test(BitcoinTestFramework):
|
||||
tip = self.nodes[0].getbestblockhash()
|
||||
block_time = self.nodes[0].getblockheader(tip)['mediantime'] + 1
|
||||
block = create_block(int(tip, 16), create_coinbase(DERSIG_HEIGHT - 1), block_time)
|
||||
block.nVersion = 2
|
||||
block.vtx.append(spendtx)
|
||||
block.hashMerkleRoot = block.calc_merkle_root()
|
||||
block.rehash()
|
||||
@ -110,7 +109,7 @@ class BIP66Test(BitcoinTestFramework):
|
||||
peer.sync_with_ping()
|
||||
|
||||
self.log.info("Test that transactions with non-DER signatures cannot appear in a block")
|
||||
block.nVersion = 3
|
||||
block.nVersion = 4
|
||||
|
||||
spendtx = self.create_tx(self.coinbase_txids[1])
|
||||
unDERify(spendtx)
|
||||
@ -139,7 +138,7 @@ class BIP66Test(BitcoinTestFramework):
|
||||
assert_equal(int(self.nodes[0].getbestblockhash(), 16), tip)
|
||||
peer.sync_with_ping()
|
||||
|
||||
self.log.info("Test that a version 3 block with a DERSIG-compliant transaction is accepted")
|
||||
self.log.info("Test that a block with a DERSIG-compliant transaction is accepted")
|
||||
block.vtx[1] = self.create_tx(self.coinbase_txids[1])
|
||||
block.hashMerkleRoot = block.calc_merkle_root()
|
||||
block.rehash()
|
||||
|
@ -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()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user