Skip to content

Commit e11050b

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

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

test/functional/rpc_createmultisig.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ def checkbalances(self):
144144
balw = self.wallet.get_balance()
145145

146146
height = node0.getblockchaininfo()["blocks"]
147-
assert 150 < height < 350
147+
assert_greater_than(350, height)
148+
assert_greater_than(height, 150)
148149
total = 149 * 50 + (height - 149 - 100) * 25
149150
assert bal1 == 0
150151
assert bal2 == self.moved

test/functional/test_framework/p2p.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,8 @@ def listen(cls, p2p, callback, port=None, addr=None, idx=1):
745745
for connections, call `callback`."""
746746

747747
if port is None:
748-
assert 0 < idx <= MAX_NODES
748+
assert_greater_than(idx, 0)
749+
assert idx <= MAX_NODES
749750
port = p2p_port(MAX_NODES - idx)
750751
if addr is None:
751752
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_greater_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_greater_than(len(txTo.vin), input_index)
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

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ def test_anti_fee_sniping(self):
4646
self.generate(self.nodes[0], 1)
4747
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)
4848
tx = self.nodes[0].gettransaction(txid=txid, verbose=True)['decoded']
49-
assert 0 < tx['locktime'] <= 201
49+
assert_greater_than(tx['locktime'], 0)
50+
assert tx['locktime'] <= 201
5051

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

0 commit comments

Comments
 (0)