Output the value that is tested, rather than the unmodified fee value.
Prompted by looking into: #11955
utACK 875d62f.
It would be nice to add tests for mempool min fee not met and mempool full errors, it's the missing cases of REJECT_INSUFFICIENTFEE.
49 | @@ -50,5 +50,18 @@ def run_test(self): 50 | assert_equal(self.nodes[0].getmempoolinfo()['minrelaytxfee'], Decimal('0.00001000')) 51 | assert_greater_than(self.nodes[0].getmempoolinfo()['mempoolminfee'], Decimal('0.00001000')) 52 | 53 | + self.log.info('Create a mempool tx that will not pass mempoolminfee') 54 | + us0 = utxos.pop() 55 | + inputs = [{ "txid" : us0["txid"], "vout" : us0["vout"]}] 56 | + outputs = {self.nodes[0].getnewaddress() : 0.0001} 57 | + tx = self.nodes[0].createrawtransaction(inputs, outputs) 58 | + self.nodes[0].settxfee(relayfee) # specifically fund this tx with a fee < mempoolminfee, >= than minrelaytxfee
I believe you can set feeRate option in fundrawtransaction instead.
59 | + txF = self.nodes[0].fundrawtransaction(tx) 60 | + self.nodes[0].settxfee(0) # return to automatic fee selection 61 | + tx_hex = self.nodes[0].signrawtransaction(txF['hex'])['hex'] 62 | + tx_id = self.nodes[0].decoderawtransaction(tx_hex)["txid"] 63 | + assert_raises_rpc_error(-26, "66: mempool min fee not met", self.nodes[0].sendrawtransaction, tx_hex) 64 | + assert(tx_id not in self.nodes[0].getrawmempool())
I guess there is no need to assert this, sendrawtransaction above failed. This assert makes sense when testing sendrawtransaction failure, so move it there if it's missing.
Fair enough, removed that and generally simplified the test.
Fyi I was following the example set in: https://github.com/bitcoin/bitcoin/blob/master/test/functional/mining_prioritisetransaction.py#L124
Make "Consistently use FormatStateMessage in RPC error output" commit the first (or second) so that the new test is not changed.
Output the value that is tested, rather than the unmodified fee value.
This will include the error code and debug output as well as the reason string.
See #11955 for the motivation.
56 | + outputs = {self.nodes[0].getnewaddress() : 0.0001} 57 | + tx = self.nodes[0].createrawtransaction(inputs, outputs) 58 | + # specifically fund this tx with a fee < mempoolminfee, >= than minrelaytxfee 59 | + txF = self.nodes[0].fundrawtransaction(tx, {'feeRate': relayfee}) 60 | + txFS = self.nodes[0].signrawtransaction(txF['hex']) 61 | + assert_raises_rpc_error(-26, "mempool min fee not met, 166 < 411 (code 66)", self.nodes[0].sendrawtransaction, txFS['hex'])
The transaction is created non-deterministically, thus you can't hardcode the exact value here.
See for example the following failure (off-by-two):
AssertionError: Expected substring not found:mempool min fee not met, 166 < 409 (code 66)
Ok, will send up a fix shortly.