Skip to content

Commit a120125

Browse files
committed
test: using assert_less_than for tests that also have <=
1 parent fd385c3 commit a120125

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

test/functional/test_framework/p2p.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
MAX_NODES,
8181
p2p_port,
8282
wait_until_helper_internal,
83+
assert_less_than,
8384
)
8485
from test_framework.v2_p2p import (
8586
EncryptedP2PState,
@@ -744,7 +745,8 @@ def listen(cls, p2p, callback, port=None, addr=None, idx=1):
744745
for connections, call `callback`."""
745746

746747
if port is None:
747-
assert 0 < idx <= MAX_NODES
748+
assert_less_than(0, idx)
749+
assert idx <= MAX_NODES
748750
port = p2p_port(MAX_NODES - idx)
749751
if addr is None:
750752
addr = '127.0.0.1'

test/functional/test_framework/script.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import unittest
1313

1414
from .key import TaggedHash, tweak_add_pubkey, compute_xonly_pubkey
15-
15+
from .util import assert_less_than
1616

1717
from .messages import (
1818
CTransaction,
@@ -814,7 +814,7 @@ def BIP341_sha_outputs(txTo):
814814

815815
def TaprootSignatureMsg(txTo, spent_utxos, hash_type, input_index = 0, scriptpath = False, script = CScript(), codeseparator_pos = -1, annex = None, leaf_ver = LEAF_VERSION_TAPSCRIPT):
816816
assert (len(txTo.vin) == len(spent_utxos))
817-
assert (input_index < len(txTo.vin))
817+
assert_less_than(input_index, len(txTo.vin))
818818
out_type = SIGHASH_ALL if hash_type == 0 else hash_type & 3
819819
in_type = hash_type & SIGHASH_ANYONECANPAY
820820
spk = spent_utxos[input_index].scriptPubKey

test/functional/wallet_create_tx.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from test_framework.test_framework import BitcoinTestFramework
77
from test_framework.util import (
88
assert_equal,
9+
assert_less_than,
910
assert_raises_rpc_error,
1011
)
1112
from test_framework.blocktools import (
@@ -45,7 +46,8 @@ def test_anti_fee_sniping(self):
4546
self.generate(self.nodes[0], 1)
4647
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)
4748
tx = self.nodes[0].gettransaction(txid=txid, verbose=True)['decoded']
48-
assert 0 < tx['locktime'] <= 201
49+
assert_less_than(0, tx['locktime'])
50+
assert tx['locktime'] <= 201
4951

5052
def test_tx_size_too_large(self):
5153
# More than 10kB of outputs, so that we hit -maxtxfee with a high feerate

0 commit comments

Comments
 (0)