Skip to content

Commit a926d6d

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#22310: test: Add functional test for replacement relay fee check
c4ddee6 test: Add test for replacement relay fee check (Antoine Riard) Pull request description: This PR adds rename the `reject_reason` of our implementation of BIP125 rule 4 and adds missing functional test coverage. Note, `insufficient fee` is already the `reject_reason` of few others `PreChecks` replacement checks and as such might be confusing. > The replacement transaction must also pay for its own bandwidth at or above the rate set by the node's minimum relay fee setting. For example, if the minimum relay fee is 1 satoshi/byte and the replacement transaction is 500 bytes total, then the replacement must pay a fee at least 500 satoshis higher than the sum of the originals. ``` // Finally in addition to paying more fees than the conflicts the // new transaction must pay for its own bandwidth. CAmount nDeltaFees = nModifiedFees - nConflictingFees; if (nDeltaFees < ::incrementalRelayFee.GetFee(nSize)) { return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "insufficient fee", strprintf("rejecting replacement %s, not enough additional fees to relay; %s < %s", hash.ToString(), FormatMoney(nDeltaFees), FormatMoney(::incrementalRelayFee.GetFee(nSize)))); } ``` ACKs for top commit: MarcoFalke: cr ACK c4ddee6 glozow: ACK c4ddee6, one small suggestion if you retouch. Tree-SHA512: 7c5d1065db6e6fe57a9f083bf051a7a55eb9892de3a2888679d4a6853491608c93b6e35887ef383a9988d14713fa13a0b1d6134b7354af5fd54765f0d4e98568
2 parents 091d35c + c4ddee6 commit a926d6d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/functional/feature_rbf.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ def run_test(self):
122122
self.log.info("Running test no inherited signaling...")
123123
self.test_no_inherited_signaling()
124124

125+
self.log.info("Running test replacement relay fee...")
126+
self.test_replacement_relay_fee()
127+
125128
self.log.info("Passed")
126129

127130
def test_simple_doublespend(self):
@@ -627,6 +630,15 @@ def test_no_inherited_signaling(self):
627630
assert_equal(True, self.nodes[0].getmempoolentry(optin_parent_tx['txid'])['bip125-replaceable'])
628631
assert_raises_rpc_error(-26, 'txn-mempool-conflict', self.nodes[0].sendrawtransaction, replacement_child_tx["hex"], 0)
629632

633+
def test_replacement_relay_fee(self):
634+
wallet = MiniWallet(self.nodes[0])
635+
wallet.scan_blocks(start=77, num=1)
636+
tx = wallet.send_self_transfer(from_node=self.nodes[0])['tx']
637+
638+
# Higher fee, higher feerate, different txid, but the replacement does not provide a relay
639+
# fee conforming to node's `incrementalrelayfee` policy of 1000 sat per KB.
640+
tx.vout[0].nValue -= 1
641+
assert_raises_rpc_error(-26, "insufficient fee", self.nodes[0].sendrawtransaction, tx.serialize().hex())
630642

631643
if __name__ == '__main__':
632644
ReplaceByFeeTest().main()

0 commit comments

Comments
 (0)