3c21db7b78 [test] add 8 error messages to feature_segwit and change version to type (Gloria Zhao)
Pull request description:
Followup to [this](https://github.com/bitcoin/bitcoin/pull/15169/files#r303673472) comment on functional test feature_segwit.py verifying that unsigned witness transactions are invalid.
(1) Changes 8 error messages from "mandatory-script-verify-flag" to "non-mandatory-script-verify-flag" and with more specific error messages.
(2) Edits comments that incorrectly describe the test, namely that the `v` variable corresponds to using P2WSH versus P2WPKH, not witness versions.
ACKs for top commit:
MarcoFalke:
ACK 3c21db7b78🍾
Tree-SHA512: 3734ea3762667636c4fb20f5285634ab94d6b3527b7390fcc5e41b4582829dfe0099beabeaed42098613d168ede3385a6ffcd73989d1fa9dbd18004f5e9cf083
self.fail_accept(self.nodes[2],"mandatory-script-verify-flag-failed (Operation not valid with the current stack size)",p2sh_ids[NODE_2][P2WPKH][1],sign=False)
self.fail_accept(self.nodes[2],"mandatory-script-verify-flag-failed (Operation not valid with the current stack size)",p2sh_ids[NODE_2][P2WSH][1],sign=False)
self.nodes[2].generate(4)# blocks 428-431
@ -173,13 +173,13 @@ class SegWitTest(BitcoinTestFramework):
self.log.info("Verify default node can't accept txs with missing witness")
self.fail_accept(self.nodes[0],"non-mandatory-script-verify-flag (Witness program hash mismatch)",wit_ids[NODE_0][P2WPKH][0],sign=False)
self.fail_accept(self.nodes[0],"non-mandatory-script-verify-flag (Witness program was passed an empty witness)",wit_ids[NODE_0][P2WSH][0],sign=False)
self.fail_accept(self.nodes[0],"mandatory-script-verify-flag-failed (Operation not valid with the current stack size)",p2sh_ids[NODE_0][P2WPKH][0],sign=False)
self.fail_accept(self.nodes[0],"mandatory-script-verify-flag-failed (Operation not valid with the current stack size)",p2sh_ids[NODE_0][P2WSH][0],sign=False)
self.fail_accept(self.nodes[0],"non-mandatory-script-verify-flag (Witness program hash mismatch)",p2sh_ids[NODE_0][P2WPKH][0],sign=False,redeem_script=witness_script(False,self.pubkey[0]))
self.fail_accept(self.nodes[0],"non-mandatory-script-verify-flag (Witness program was passed an empty witness)",p2sh_ids[NODE_0][P2WSH][0],sign=False,redeem_script=witness_script(True,self.pubkey[0]))
self.log.info("Verify block and transaction serialization rpcs return differing serializations depending on rpc serialization flag")
self.log.info("Verify witness txs without witness data are invalid after the fork")
self.fail_accept(self.nodes[2],'non-mandatory-script-verify-flag (Witness program hash mismatch)',wit_ids[NODE_2][WIT_V0][2],sign=False)
self.fail_accept(self.nodes[2],'non-mandatory-script-verify-flag (Witness program was passed an empty witness)',wit_ids[NODE_2][WIT_V1][2],sign=False)
self.fail_accept(self.nodes[2],'non-mandatory-script-verify-flag (Witness program hash mismatch)',p2sh_ids[NODE_2][WIT_V0][2],sign=False,redeem_script=witness_script(False,self.pubkey[2]))
self.fail_accept(self.nodes[2],'non-mandatory-script-verify-flag (Witness program was passed an empty witness)',p2sh_ids[NODE_2][WIT_V1][2],sign=False,redeem_script=witness_script(True,self.pubkey[2]))
self.fail_accept(self.nodes[2],'non-mandatory-script-verify-flag (Witness program hash mismatch)',wit_ids[NODE_2][P2WPKH][2],sign=False)
self.fail_accept(self.nodes[2],'non-mandatory-script-verify-flag (Witness program was passed an empty witness)',wit_ids[NODE_2][P2WSH][2],sign=False)
self.fail_accept(self.nodes[2],'non-mandatory-script-verify-flag (Witness program hash mismatch)',p2sh_ids[NODE_2][P2WPKH][2],sign=False,redeem_script=witness_script(False,self.pubkey[2]))
self.fail_accept(self.nodes[2],'non-mandatory-script-verify-flag (Witness program was passed an empty witness)',p2sh_ids[NODE_2][P2WSH][2],sign=False,redeem_script=witness_script(True,self.pubkey[2]))
self.log.info("Verify default node can now use witness txs")