0--- a/test/functional/feature_rbf.py
1+++ b/test/functional/feature_rbf.py
2@@ -107,6 +107,11 @@ class ReplaceByFeeTest(BitcoinTestFramework):
3
4 return self.wallet.get_utxo(txid=tx["txid"], vout=tx["sent_vout"])
5
6+ def assert_rejected_by_testmempoolaccept(self, tx_hex, msg):
7+ result = self.nodes[0].testmempoolaccept(rawtxs=[tx_hex])[0]
8+ assert not result["allowed"]
9+ assert msg in result["reject-reason"]
10+
11 def test_simple_doublespend(self):
12 """Simple doublespend"""
13 # we use MiniWallet to create a transaction template with inputs correctly set,
14@@ -121,9 +126,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
15 # This will raise an exception due to insufficient fee
16 debug_message = f"insufficient fee, rejecting replacement {tx.hash}; new feerate"
17 assert_raises_rpc_error(-26, debug_message, self.nodes[0].sendrawtransaction, tx.serialize().hex(), 0)
18- res = self.nodes[0].testmempoolaccept(rawtxs=[tx.serialize().hex()])[0]
19- assert not res['allowed']
20- assert debug_message in res['reject-reason']
21+ self.assert_rejected_by_testmempoolaccept(tx.serialize().hex(), debug_message)
22
23 # Extra 0.1 BTC fee
24 tx.vout[0].nValue -= int(0.1 * COIN)
25@@ -168,9 +171,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
26 # This will raise an exception due to insufficient fee
27 debug_message = f"insufficient fee, rejecting replacement {dbl_tx['txid']}; less fees than conflicting txs"
28 assert_raises_rpc_error(-26, debug_message, self.nodes[0].sendrawtransaction, dbl_tx["hex"], 0)
29- res = self.nodes[0].testmempoolaccept(rawtxs=[dbl_tx["hex"]])[0]
30- assert not res['allowed']
31- assert debug_message in res['reject-reason']
32+ self.assert_rejected_by_testmempoolaccept(dbl_tx["hex"], debug_message)
33
34 # Accepted with sufficient fee
35 dbl_tx["tx"].vout[0].nValue = int(0.1 * COIN)
36@@ -307,9 +308,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
37 # This will raise an exception
38 debug_message = f"bad-txns-spends-conflicting-tx, {tx2['txid']} spends conflicting transaction {tx1a['txid']}"
39 assert_raises_rpc_error(-26, debug_message, self.nodes[0].sendrawtransaction, tx2["hex"], 0)
40- res = self.nodes[0].testmempoolaccept(rawtxs=[tx2["hex"]])[0]
41- assert not res['allowed']
42- assert debug_message in res['reject-reason']
43+ self.assert_rejected_by_testmempoolaccept(tx2["hex"], debug_message)
44
45 # Spend tx1a's output to test the indirect case.
46 tx1b_utxo = self.wallet.send_self_transfer(
47@@ -349,9 +348,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
48 # This will raise an exception
49 debug_message = f"replacement-adds-unconfirmed, replacement {tx2['txid']} adds unconfirmed input, idx"
50 assert_raises_rpc_error(-26, debug_message, self.nodes[0].sendrawtransaction, tx2["hex"], 0)
51- res = self.nodes[0].testmempoolaccept(rawtxs=[tx2["hex"]])[0]
52- assert not res['allowed']
53- assert debug_message in res['reject-reason']
54+ self.assert_rejected_by_testmempoolaccept(tx2["hex"], debug_message)
55
56 def test_too_many_replacements(self):
57 """Replacements that evict too many transactions are rejected"""
58@@ -394,9 +391,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
59 # This will raise an exception
60 debug_message = f"too many potential replacements, rejecting replacement {double_tx['txid']}; too many potential replacements"
61 assert_raises_rpc_error(-26, debug_message, self.nodes[0].sendrawtransaction, double_tx["hex"], 0)
62- res = self.nodes[0].testmempoolaccept(rawtxs=[double_tx["hex"]])[0]
63- assert not res['allowed']
64- assert debug_message in res['reject-reason']
65+ self.assert_rejected_by_testmempoolaccept(double_tx["hex"], debug_message)
66
67 # If we remove an input, it should pass
68 double_tx["tx"].vin.pop()
69@@ -720,9 +715,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
70 tx.rehash()
71 debug_message = f"insufficient fee, rejecting replacement {tx.hash}; not enough additional fees to relay"
72 assert_raises_rpc_error(-26, debug_message, self.nodes[0].sendrawtransaction, tx.serialize().hex())
73- res = self.nodes[0].testmempoolaccept(rawtxs=[tx.serialize().hex()])[0]
74- assert not res['allowed']
75- assert debug_message in res['reject-reason']
76+ self.assert_rejected_by_testmempoolaccept(tx.serialize().hex(), debug_message)
77
78 def test_fullrbf(self):