Skip to content

Commit

Permalink
test: using assert_less_than for tests that also have <=
Browse files Browse the repository at this point in the history
  • Loading branch information
kevkevinpal committed May 2, 2024
1 parent 46e39e0 commit c51464c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion test/functional/test_framework/p2p.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
MAX_NODES,
p2p_port,
wait_until_helper_internal,
assert_less_than,
)
from test_framework.v2_p2p import (
EncryptedP2PState,
Expand Down Expand Up @@ -744,7 +745,8 @@ def listen(cls, p2p, callback, port=None, addr=None, idx=1):
for connections, call `callback`."""

if port is None:
assert 0 < idx <= MAX_NODES
assert_less_than(0, idx)
assert idx <= MAX_NODES
port = p2p_port(MAX_NODES - idx)
if addr is None:
addr = '127.0.0.1'
Expand Down
4 changes: 2 additions & 2 deletions test/functional/test_framework/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import unittest

from .key import TaggedHash, tweak_add_pubkey, compute_xonly_pubkey

from .util import assert_less_than

from .messages import (
CTransaction,
Expand Down Expand Up @@ -814,7 +814,7 @@ def BIP341_sha_outputs(txTo):

def TaprootSignatureMsg(txTo, spent_utxos, hash_type, input_index = 0, scriptpath = False, script = CScript(), codeseparator_pos = -1, annex = None, leaf_ver = LEAF_VERSION_TAPSCRIPT):
assert (len(txTo.vin) == len(spent_utxos))
assert (input_index < len(txTo.vin))
assert_less_than(input_index, len(txTo.vin))
out_type = SIGHASH_ALL if hash_type == 0 else hash_type & 3
in_type = hash_type & SIGHASH_ANYONECANPAY
spk = spent_utxos[input_index].scriptPubKey
Expand Down
4 changes: 3 additions & 1 deletion test/functional/wallet_create_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
assert_less_than,
assert_raises_rpc_error,
)
from test_framework.blocktools import (
Expand Down Expand Up @@ -45,7 +46,8 @@ def test_anti_fee_sniping(self):
self.generate(self.nodes[0], 1)
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)
tx = self.nodes[0].gettransaction(txid=txid, verbose=True)['decoded']
assert 0 < tx['locktime'] <= 201
assert_less_than(0, tx['locktime'])
assert tx['locktime'] <= 201

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

0 comments on commit c51464c

Please sign in to comment.