Skip to content

Commit 83a2216

Browse files
committed
Merge bitcoin/bitcoin#33118: test: fix anti-fee-sniping off-by-one error
e07e253 test: fix anti-fee-sniping off-by-one error (ishaanam) Pull request description: This fixes the off-by-one error in the anti-fee-sniping tests for `send` and `sendall`. `assert_greater_than` fails if the two values are equal. Closes #33114 ACKs for top commit: achow101: ACK e07e253 glozow: utACK e07e253 Tree-SHA512: 6c9c3d1256faf563361946703d9a51279777d73bc1a849873e03e5b5db52c3c2b9dea4bfe27b1f01b9c830ca246200a895b6a28484da6d822b93b0c7cba237c1
2 parents 75ed673 + e07e253 commit 83a2216

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

test/functional/wallet_send.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
assert_equal,
1616
assert_fee_amount,
1717
assert_greater_than,
18+
assert_greater_than_or_equal,
1819
assert_raises_rpc_error,
1920
count_bytes,
2021
)
@@ -149,7 +150,9 @@ def test_send(self, from_wallet, to_wallet=None, amount=None, data=None,
149150
else:
150151
if add_to_wallet:
151152
decoded_tx = from_wallet.gettransaction(txid=res["txid"], verbose=True)["decoded"]
152-
assert_greater_than(decoded_tx["locktime"], from_wallet.getblockcount() - 100)
153+
# the locktime should be within 100 blocks of the
154+
# block height
155+
assert_greater_than_or_equal(decoded_tx["locktime"], from_wallet.getblockcount() - 100)
153156

154157
if expect_sign:
155158
assert_equal(res["complete"], True)

test/functional/wallet_sendall.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from test_framework.util import (
1212
assert_equal,
1313
assert_greater_than,
14+
assert_greater_than_or_equal,
1415
assert_raises_rpc_error,
1516
)
1617

@@ -437,7 +438,9 @@ def sendall_anti_fee_sniping(self):
437438
self.add_utxos([10,11])
438439
tx_from_wallet = self.test_sendall_success(sendall_args = [self.remainder_target])
439440

440-
assert_greater_than(tx_from_wallet["decoded"]["locktime"], tx_from_wallet["blockheight"] - 100)
441+
# the locktime should be within 100 blocks of the
442+
# block height
443+
assert_greater_than_or_equal(tx_from_wallet["decoded"]["locktime"], tx_from_wallet["blockheight"] - 100)
441444

442445
self.log.info("Testing sendall does not do anti-fee-sniping when locktime is specified")
443446
self.add_utxos([10,11])

0 commit comments

Comments
 (0)