From 3118c2e365d91f58086b3042068dadaec1e34a3c Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Wed, 8 Mar 2023 15:31:49 +1000 Subject: [PATCH] tests: in p2p_segwit, check non-mandatory errors with -acceptnonstdtxn=0 node Prepare for updating -acceptnonstdtxn to allow txns that violate STANDARD_SCRIPT_VERIFY_FLAGS but not MANDATORY_SCRIPT_VERIFY_FLAGS by checking the non-mandatory flags with node that enforces standardness. --- test/functional/p2p_segwit.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/functional/p2p_segwit.py b/test/functional/p2p_segwit.py index 45bbd7f1c3..ddad41d226 100755 --- a/test/functional/p2p_segwit.py +++ b/test/functional/p2p_segwit.py @@ -1396,10 +1396,10 @@ class SegWitTest(BitcoinTestFramework): # even with the node that accepts non-standard txs. test_transaction_acceptance(self.nodes[0], self.test_node, tx3, with_witness=True, accepted=False, reason="reserved for soft-fork upgrades") - # Building a block with the transaction must be valid, however. + # Building a block with the transaction must be valid, however even without -acceptnonstdtxn. block = self.build_next_block() self.update_witness_block_with_transactions(block, [tx2, tx3]) - test_witness_block(self.nodes[0], self.test_node, block, accepted=True) + test_witness_block(self.nodes[1], self.std_node, block, accepted=True) self.sync_blocks() # Add utxo to our list @@ -1480,11 +1480,11 @@ class SegWitTest(BitcoinTestFramework): sign_input_segwitv0(tx2, 0, script, tx.vout[0].nValue, key) # Should fail policy test. - test_transaction_acceptance(self.nodes[0], self.test_node, tx2, True, False, 'non-mandatory-script-verify-flag (Using non-compressed keys in segwit)') + test_transaction_acceptance(self.nodes[1], self.std_node, tx2, True, False, 'non-mandatory-script-verify-flag (Using non-compressed keys in segwit)') # But passes consensus. block = self.build_next_block() self.update_witness_block_with_transactions(block, [tx2]) - test_witness_block(self.nodes[0], self.test_node, block, accepted=True) + test_witness_block(self.nodes[1], self.std_node, block, accepted=True) # Test 2: P2WSH # Try to spend the P2WSH output created in last test. @@ -1499,11 +1499,11 @@ class SegWitTest(BitcoinTestFramework): sign_p2pk_witness_input(witness_script, tx3, 0, SIGHASH_ALL, tx2.vout[0].nValue, key) # Should fail policy test. - test_transaction_acceptance(self.nodes[0], self.test_node, tx3, True, False, 'non-mandatory-script-verify-flag (Using non-compressed keys in segwit)') + test_transaction_acceptance(self.nodes[1], self.std_node, tx3, True, False, 'non-mandatory-script-verify-flag (Using non-compressed keys in segwit)') # But passes consensus. block = self.build_next_block() self.update_witness_block_with_transactions(block, [tx3]) - test_witness_block(self.nodes[0], self.test_node, block, accepted=True) + test_witness_block(self.nodes[1], self.std_node, block, accepted=True) # Test 3: P2SH(P2WSH) # Try to spend the P2SH output created in the last test. @@ -1516,10 +1516,10 @@ class SegWitTest(BitcoinTestFramework): sign_p2pk_witness_input(witness_script, tx4, 0, SIGHASH_ALL, tx3.vout[0].nValue, key) # Should fail policy test. - test_transaction_acceptance(self.nodes[0], self.test_node, tx4, True, False, 'non-mandatory-script-verify-flag (Using non-compressed keys in segwit)') + test_transaction_acceptance(self.nodes[1], self.std_node, tx4, True, False, 'non-mandatory-script-verify-flag (Using non-compressed keys in segwit)') block = self.build_next_block() self.update_witness_block_with_transactions(block, [tx4]) - test_witness_block(self.nodes[0], self.test_node, block, accepted=True) + test_witness_block(self.nodes[1], self.std_node, block, accepted=True) # Test 4: Uncompressed pubkeys should still be valid in non-segwit # transactions.