Skip to content

Commit

Permalink
test: create assert_not_equal util and add to where imports are needed
Browse files Browse the repository at this point in the history
In the functional tests there are lots of cases where we assert != which
this new util will replace, we also are adding the imports and the
following commit will add the new assertion
  • Loading branch information
kevkevinpal committed Nov 12, 2024
1 parent 1dda189 commit 48b67ba
Show file tree
Hide file tree
Showing 40 changed files with 63 additions and 8 deletions.
1 change: 1 addition & 0 deletions test/functional/feature_assumeutxo.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from test_framework.util import (
assert_approx,
assert_equal,
assert_not_equal,
assert_raises_rpc_error,
sha256sum_file,
try_rpc,
Expand Down
5 changes: 4 additions & 1 deletion test/functional/feature_bind_port_discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"""

from test_framework.test_framework import BitcoinTestFramework, SkipTest
from test_framework.util import assert_equal
from test_framework.util import (
assert_equal,
assert_not_equal,
)

# We need to bind to a routable address for this test to exercise the relevant code
# and also must have another routable address on another interface which must not
Expand Down
1 change: 1 addition & 0 deletions test/functional/feature_coinstatsindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_not_equal,
assert_equal,
assert_raises_rpc_error,
)
Expand Down
1 change: 1 addition & 0 deletions test/functional/feature_dbcrash.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_not_equal,
assert_equal,
)
from test_framework.wallet import (
Expand Down
1 change: 1 addition & 0 deletions test/functional/feature_fee_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_not_equal,
assert_equal,
assert_greater_than,
assert_greater_than_or_equal,
Expand Down
5 changes: 4 additions & 1 deletion test/functional/feature_minchainwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@

from test_framework.p2p import P2PInterface, msg_getheaders
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal
from test_framework.util import (
assert_equal,
assert_not_equal,
)

# 2 hashes required per regtest block (with no difficulty adjustment)
REGTEST_WORK_PER_BLOCK = 2
Expand Down
1 change: 1 addition & 0 deletions test/functional/feature_taproot.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_not_equal,
assert_raises_rpc_error,
assert_equal,
)
Expand Down
1 change: 1 addition & 0 deletions test/functional/mempool_accept_wtxid.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_not_equal,
assert_equal,
)

Expand Down
1 change: 1 addition & 0 deletions test/functional/mempool_truc.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_not_equal,
assert_equal,
assert_greater_than,
assert_greater_than_or_equal,
Expand Down
1 change: 1 addition & 0 deletions test/functional/mining_prioritisetransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_not_equal,
assert_equal,
assert_raises_rpc_error,
create_lots_of_big_transactions,
Expand Down
1 change: 1 addition & 0 deletions test/functional/p2p_blockfilters.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from test_framework.p2p import P2PInterface
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_not_equal,
assert_equal,
)

Expand Down
1 change: 1 addition & 0 deletions test/functional/p2p_compactblocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_not_equal,
assert_equal,
softfork_active,
)
Expand Down
1 change: 1 addition & 0 deletions test/functional/p2p_getaddr_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_not_equal,
assert_equal,
p2p_port,
)
Expand Down
1 change: 1 addition & 0 deletions test/functional/p2p_handshake.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import time

from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_not_equal
from test_framework.messages import (
NODE_NETWORK,
NODE_NETWORK_LIMITED,
Expand Down
5 changes: 4 additions & 1 deletion test/functional/p2p_invalid_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
from test_framework.p2p import P2PDataStore
from test_framework.script import OP_TRUE
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal
from test_framework.util import (
assert_equal,
assert_not_equal,
)


class InvalidBlockRequestTest(BitcoinTestFramework):
Expand Down
1 change: 1 addition & 0 deletions test/functional/p2p_orphan_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
TXID_RELAY_DELAY,
)
from test_framework.util import (
assert_not_equal,
assert_equal,
)
from test_framework.test_framework import BitcoinTestFramework
Expand Down
5 changes: 4 additions & 1 deletion test/functional/p2p_ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
from test_framework.messages import msg_pong
from test_framework.p2p import P2PInterface
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal
from test_framework.util import (
assert_equal,
assert_not_equal,
)


PING_INTERVAL = 2 * 60
Expand Down
1 change: 1 addition & 0 deletions test/functional/p2p_segwit.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_not_equal,
assert_equal,
softfork_active,
assert_raises_rpc_error,
Expand Down
5 changes: 4 additions & 1 deletion test/functional/p2p_sendtxrcncl.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
P2P_VERSION,
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal
from test_framework.util import (
assert_equal,
assert_not_equal,
)

class PeerNoVerack(P2PInterface):
def __init__(self, wtxidrelay=True):
Expand Down
1 change: 1 addition & 0 deletions test/functional/p2p_v2_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from test_framework.messages import MAGIC_BYTES, NODE_P2P_V2
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_not_equal,
assert_equal,
p2p_port,
assert_raises_rpc_error
Expand Down
1 change: 1 addition & 0 deletions test/functional/rpc_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from test_framework.script import hash256, OP_TRUE
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_not_equal,
assert_equal,
assert_greater_than,
assert_greater_than_or_equal,
Expand Down
1 change: 1 addition & 0 deletions test/functional/rpc_orphans.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from test_framework.p2p import P2PInterface
from test_framework.util import (
assert_equal,
assert_not_equal,
assert_raises_rpc_error,
)
from test_framework.test_framework import BitcoinTestFramework
Expand Down
1 change: 1 addition & 0 deletions test/functional/rpc_preciousblock.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_not_equal,
assert_equal,
)

Expand Down
1 change: 1 addition & 0 deletions test/functional/rpc_psbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from test_framework.script_util import MIN_STANDARD_TX_NONWITNESS_SIZE
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_not_equal,
assert_approx,
assert_equal,
assert_greater_than,
Expand Down
1 change: 1 addition & 0 deletions test/functional/test_framework/crypto/secp256k1.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import unittest
from hashlib import sha256
from test_framework.util import assert_not_equal

class FE:
"""Objects of this class represent elements of the field GF(2**256 - 2**32 - 977).
Expand Down
2 changes: 1 addition & 1 deletion test/functional/test_framework/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import unittest

from test_framework.crypto import secp256k1
from test_framework.util import random_bitflip
from test_framework.util import assert_not_equal, random_bitflip

# Point with no known discrete log.
H_POINT = "50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"
Expand Down
1 change: 1 addition & 0 deletions test/functional/test_framework/p2p.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
sha256,
)
from test_framework.util import (
assert_not_equal,
MAX_NODES,
p2p_port,
wait_until_helper_internal,
Expand Down
1 change: 1 addition & 0 deletions test/functional/test_framework/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from .util import (
MAX_NODES,
assert_equal,
assert_not_equal,
append_config,
delete_cookie_file,
get_auth_cookie,
Expand Down
4 changes: 4 additions & 0 deletions test/functional/test_framework/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ def assert_equal(thing1, thing2, *args):
if thing1 != thing2 or any(thing1 != arg for arg in args):
raise AssertionError("not(%s)" % " == ".join(str(arg) for arg in (thing1, thing2) + args))

def assert_not_equal(thing1, thing2, error_message=""):
if thing1 == thing2:
raise AssertionError("%s == %s %s" % (str(thing1), str(thing2), str(error_message)))


def assert_greater_than(thing1, thing2):
if thing1 <= thing2:
Expand Down
1 change: 1 addition & 0 deletions test/functional/wallet_avoidreuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from test_framework.address import address_to_scriptpubkey
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_not_equal,
assert_approx,
assert_equal,
assert_raises_rpc_error,
Expand Down
1 change: 1 addition & 0 deletions test/functional/wallet_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from test_framework.descriptors import descsum_create
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_not_equal,
assert_equal,
assert_raises_rpc_error
)
Expand Down
1 change: 1 addition & 0 deletions test/functional/wallet_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_not_equal,
assert_equal,
assert_raises_rpc_error,
)
Expand Down
1 change: 1 addition & 0 deletions test/functional/wallet_fundrawtransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_not_equal,
assert_approx,
assert_equal,
assert_fee_amount,
Expand Down
1 change: 1 addition & 0 deletions test/functional/wallet_gethdkeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from test_framework.util import (
assert_equal,
assert_raises_rpc_error,
assert_not_equal,
)
from test_framework.wallet_util import WalletUnlock

Expand Down
1 change: 1 addition & 0 deletions test/functional/wallet_hd.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from test_framework.blocktools import COINBASE_MATURITY
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_not_equal,
assert_equal,
assert_raises_rpc_error,
)
Expand Down
6 changes: 5 additions & 1 deletion test/functional/wallet_keypool.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
from decimal import Decimal

from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_raises_rpc_error
from test_framework.util import (
assert_equal,
assert_not_equal,
assert_raises_rpc_error,
)
from test_framework.wallet_util import WalletUnlock

class KeyPoolTest(BitcoinTestFramework):
Expand Down
1 change: 1 addition & 0 deletions test/functional/wallet_listdescriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_not_equal,
assert_equal,
assert_raises_rpc_error,
)
Expand Down
1 change: 1 addition & 0 deletions test/functional/wallet_listtransactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_not_equal,
assert_array_result,
assert_equal,
assert_raises_rpc_error,
Expand Down
3 changes: 2 additions & 1 deletion test/functional/wallet_reorgsrestore.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
assert_not_equal,
assert_equal,
)

class ReorgsRestoreTest(BitcoinTestFramework):
Expand Down
1 change: 1 addition & 0 deletions test/functional/wallet_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from test_framework.descriptors import descsum_create
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_not_equal,
assert_equal,
assert_fee_amount,
assert_greater_than,
Expand Down

0 comments on commit 48b67ba

Please sign in to comment.