Skip to content

Commit 4eb532f

Browse files
committed
test: check for block reject reasons in p2p_segwit.py [1/2]
This commit adds specific expected reject reasons for segwit blocks sent to the node, that are independent of whether multiple script threads are activated or not.
1 parent b1488c4 commit 4eb532f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

test/functional/p2p_segwit.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ def test_witness_commitments(self):
790790
block_3.rehash()
791791
block_3.solve()
792792

793-
test_witness_block(self.nodes[0], self.test_node, block_3, accepted=False)
793+
test_witness_block(self.nodes[0], self.test_node, block_3, accepted=False, reason='bad-witness-merkle-match')
794794

795795
# Add a different commitment with different nonce, but in the
796796
# right location, and with some funds burned(!).
@@ -856,7 +856,7 @@ def test_block_malleability(self):
856856
# Change the nonce -- should not cause the block to be permanently
857857
# failed
858858
block.vtx[0].wit.vtxinwit[0].scriptWitness.stack = [ser_uint256(1)]
859-
test_witness_block(self.nodes[0], self.test_node, block, accepted=False)
859+
test_witness_block(self.nodes[0], self.test_node, block, accepted=False, reason='bad-witness-merkle-match')
860860

861861
# Changing the witness reserved value doesn't change the block hash
862862
block.vtx[0].wit.vtxinwit[0].scriptWitness.stack = [ser_uint256(0)]
@@ -921,7 +921,7 @@ def test_witness_block_size(self):
921921
# limit
922922
assert len(block.serialize()) > 2 * 1024 * 1024
923923

924-
test_witness_block(self.nodes[0], self.test_node, block, accepted=False)
924+
test_witness_block(self.nodes[0], self.test_node, block, accepted=False, reason='bad-blk-weight')
925925

926926
# Now resize the second transaction to make the block fit.
927927
cur_length = len(block.vtx[-1].wit.vtxinwit[0].scriptWitness.stack[0])
@@ -1180,7 +1180,7 @@ def serialize_with_witness(self):
11801180

11811181
block = self.build_next_block()
11821182
self.update_witness_block_with_transactions(block, [tx2])
1183-
test_witness_block(self.nodes[0], self.test_node, block, accepted=False)
1183+
test_witness_block(self.nodes[0], self.test_node, block, accepted=False, reason='bad-txnmrklroot')
11841184

11851185
# Now try using a too short vtxinwit
11861186
tx2.wit.vtxinwit.pop()
@@ -1419,7 +1419,7 @@ def test_premature_coinbase_witness_spend(self):
14191419
self.sync_blocks()
14201420
block2 = self.build_next_block()
14211421
self.update_witness_block_with_transactions(block2, [spend_tx])
1422-
test_witness_block(self.nodes[0], self.test_node, block2, accepted=False)
1422+
test_witness_block(self.nodes[0], self.test_node, block2, accepted=False, reason='bad-txns-premature-spend-of-coinbase')
14231423

14241424
# Advancing one more block should allow the spend.
14251425
self.generate(self.nodes[0], 1)
@@ -1922,7 +1922,7 @@ def test_witness_sigops(self):
19221922

19231923
block_2 = self.build_next_block()
19241924
self.update_witness_block_with_transactions(block_2, [tx2])
1925-
test_witness_block(self.nodes[0], self.test_node, block_2, accepted=False)
1925+
test_witness_block(self.nodes[0], self.test_node, block_2, accepted=False, reason='bad-blk-sigops')
19261926

19271927
# Try dropping the last input in tx2, and add an output that has
19281928
# too many sigops (contributing to legacy sigop count).
@@ -1935,7 +1935,7 @@ def test_witness_sigops(self):
19351935
tx2.rehash()
19361936
block_3 = self.build_next_block()
19371937
self.update_witness_block_with_transactions(block_3, [tx2])
1938-
test_witness_block(self.nodes[0], self.test_node, block_3, accepted=False)
1938+
test_witness_block(self.nodes[0], self.test_node, block_3, accepted=False, reason='bad-blk-sigops')
19391939

19401940
# If we drop the last checksig in this output, the tx should succeed.
19411941
block_4 = self.build_next_block()

0 commit comments

Comments
 (0)