Fix #30309 (review) inconsistency.
Currently, the test is passing due to a mistake in the test inputs selection process. We are selecting the parent transaction change output as one of the inputs of the transaction to fund, which helps to surpass the target amount when it shouldn’t due to the fee reduction.
The failure arises when the test behaves as intended by its coder; that is, when it does not select the change output. In this case, the pre-selected inputs aren’t enough to cover the target amount.
Fix this by excluding the parent transaction’s change output from the inputs selection and including an extra input to cover the tx fee.
The CI failure can be replicated with the following patch in master:
0diff --git a/test/functional/wallet_fundrawtransaction.py b/test/functional/wallet_fundrawtransaction.py
1--- a/test/functional/wallet_fundrawtransaction.py (revision 9b480f7a25a737c9c4ebc33401e94d66c2da9ec3)
2+++ b/test/functional/wallet_fundrawtransaction.py (date 1720652934739)
3@@ -1322,7 +1322,7 @@
4 outputs = []
5 for _ in range(1472):
6 outputs.append({wallet.getnewaddress(address_type="legacy"): 0.1})
7- txid = self.nodes[0].send(outputs=outputs)["txid"]
8+ txid = self.nodes[0].send(outputs=outputs, change_position=0)["txid"]
9 self.generate(self.nodes[0], 1)
10
11 # 272 WU per input (273 when high-s); picking 1471 inputs will exceed the max standard tx weight.
12@@ -1330,7 +1330,7 @@
13
14 # 1) Try to fund transaction only using the preset inputs
15 input_weights = []
16- for i in range(1471):
17+ for i in range(1, 1472): # skip first output as it is the parent tx change output
18 input_weights.append({"txid": txid, "vout": i, "weight": 273})
19 assert_raises_rpc_error(-4, "Transaction too large", wallet.fundrawtransaction, hexstring=rawtx, input_weights=input_weights)