It is my understanding that the feature_block.py test suites turns on -acceptnonstdtxn=1 which turns off this policy check. Thus we don't receive any error message when submitting the transaction to the mempool.
I assume you are referring to the functional test p2p_invalid_tx.py rather than feature_block.py, as the latter only sends blocks to the node rather than individual txs? Specifying the error message as reject_reason (meaning the invalid tx case is used to test both via block and individual tx submission) seems to work after increasing the tx size, in order to avoid a "tx-size-small" rejection:
diff --git a/test/functional/data/invalid_txs.py b/test/functional/data/invalid_txs.py
index db8871e001..d128ac1682 100644
--- a/test/functional/data/invalid_txs.py
+++ b/test/functional/data/invalid_txs.py
@@ -135,14 +135,13 @@ class SizeTooSmall(BadTxTemplate):
# reject a transaction that contains a witness
# but doesnt spend a segwit output
class ExtraWitness(BadTxTemplate):
- expect_disconnect = False
- valid_in_block = False
- block_reject_reason = "mandatory-script-verify-flag-failed (Witness provided for non-witness script)"
+ expect_disconnect = True
+ reject_reason = "mandatory-script-verify-flag-failed (Witness provided for non-witness script)"
def get_tx(self):
tx = CTransaction()
tx.vin.append(self.valid_txin)
- tx.vout.append(CTxOut(0, CScript()))
+ tx.vout.append(CTxOut(0, basic_p2sh))
tx.wit.vtxinwit = [CTxInWitness()]
tx.wit.vtxinwit[0].scriptWitness.stack = [CScript([OP_TRUE])]
return tx
diff --git a/test/functional/p2p_invalid_tx.py b/test/functional/p2p_invalid_tx.py
index ae9771e7cb..b1979cc76d 100755
--- a/test/functional/p2p_invalid_tx.py
+++ b/test/functional/p2p_invalid_tx.py
@@ -160,7 +160,7 @@ class InvalidTxRequestTest(BitcoinTestFramework):
node.p2ps[0].send_txs_and_test([rejected_parent], node, success=False)
self.log.info('Test that a peer disconnection causes erase its transactions from the orphan pool')
- with node.assert_debug_log(['Erased 100 orphan transaction(s) from peer=26']):
+ with node.assert_debug_log(['Erased 100 orphan transaction(s) from peer=27']):
self.reconnect_p2p(num_connections=1)
self.log.info('Test that a transaction in the orphan pool is included in a new tip block causes erase this transaction from the orphan pool')
In general, I think only specifying a block_reject_reason rarely makes sense, as a consensus-invalid tx is usually also rejected by mempool. The only exception I could think of is txs that land in the orphanage due to missing inputs. Currently that's the case for the invalid tx classes BadInputOutpointIndex and NonexistentInput.