test: convert equality asserts with comments or special chars
What changed, and why it matters
This commit only changes test code. It replaces plain Python `assert x == y` checks with a helper called `assert_equal` in a handful of test files. The reason is cosmetic/preparatory: some test lines contain inline comments, list literals, or descriptor strings with `#` characters, so they need to be converted by hand before a later automated rewrite can safely convert the rest. There is no change to Bitcoin Core's actual node or wallet logic, so it cannot affect live users, funds, or network security.
No security action required. This is a normal test-maintenance refactor. Reviewers can verify that the replacements are semantically equivalent and that the import was added correctly.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff is a pure test-framework refactoring across five functional test files. It imports assert_equal in test_framework/v2_p2p.py and replaces six assert equality comparisons with assert_equal(...) calls in p2p_segwit.py, rpc_createmultisig.py, rpc_decodescript.py, v2_p2p.py, and wallet_listdescriptors.py. The commit message explicitly states the goal is to keep a later mechanical rewrite simple. No production code, consensus code, RPC behavior, or cryptography is modified.
Changed components
test/functional/p2p_segwit.pytest/functional/rpc_createmultisig.pytest/functional/rpc_decodescript.pytest/functional/test_framework/v2_p2p.pytest/functional/wallet_listdescriptors.pyInspect captured patch +7 / −6
diff --git a/test/functional/p2p_segwit.py b/test/functional/p2p_segwit.py
index 17f8085b..85fe0412 100755
--- a/test/functional/p2p_segwit.py
+++ b/test/functional/p2p_segwit.py
@@ -790,7 +790,7 @@ class SegWitTest(BitcoinTestFramework):
block_3.vtx[0].vout[0].nValue -= 1
block_3.vtx[0].vout[-1].nValue += 1
block_3.hashMerkleRoot = block_3.calc_merkle_root()
- assert len(block_3.vtx[0].vout) == 4 # 3 OP_returns
+ assert_equal(len(block_3.vtx[0].vout), 4) # 3 OP_returns
block_3.solve()
test_witness_block(self.nodes[0], self.test_node, block_3, accepted=True)
diff --git a/test/functional/rpc_createmultisig.py b/test/functional/rpc_createmultisig.py
index 74b9debf..199e9c44 100755
--- a/test/functional/rpc_createmultisig.py
+++ b/test/functional/rpc_createmultisig.py
@@ -103,7 +103,7 @@ class RpcCreateMultiSigTest(BitcoinTestFramework):
mredeem = msig["redeemScript"]
assert_equal(desc, msig['descriptor'])
if output_type == 'bech32':
- assert madd[0:4] == "bcrt" # actually a bech32 address
+ assert_equal(madd[0:4], "bcrt") # actually a bech32 address
spk = address_to_scriptpubkey(madd)
value = decimal.Decimal("0.00004000")
diff --git a/test/functional/rpc_decodescript.py b/test/functional/rpc_decodescript.py
index d23b9edf..2ab73444 100755
--- a/test/functional/rpc_decodescript.py
+++ b/test/functional/rpc_decodescript.py
@@ -278,10 +278,10 @@ class DecodeScriptTest(BitcoinTestFramework):
# Sourced from https://github.com/bitcoin/bitcoin/pull/27037#issuecomment-1416151907.
# Miniscript-compatible offered HTLC
res = self.nodes[0].decodescript("82012088a914ffffffffffffffffffffffffffffffffffffffff88210250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0ad51b2")
- assert res["segwit"]["desc"] == "wsh(and_v(and_v(v:hash160(ffffffffffffffffffffffffffffffffffffffff),v:pk(0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0)),older(1)))#gm8xz4fl"
+ assert_equal(res["segwit"]["desc"], "wsh(and_v(and_v(v:hash160(ffffffffffffffffffffffffffffffffffffffff),v:pk(0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0)),older(1)))#gm8xz4fl")
# Miniscript-incompatible offered HTLC
res = self.nodes[0].decodescript("82012088a914ffffffffffffffffffffffffffffffffffffffff882102ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffacb2")
- assert res["segwit"]["desc"] == "addr(bcrt1q73qyfypp47hvgnkjqnav0j3k2lq3v76wg22dk8tmwuz5sfgv66xsvxg6uu)#9p3q328s"
+ assert_equal(res["segwit"]["desc"], "addr(bcrt1q73qyfypp47hvgnkjqnav0j3k2lq3v76wg22dk8tmwuz5sfgv66xsvxg6uu)#9p3q328s")
# Miniscript-compatible multisig bigger than 520 byte P2SH limit.
res = self.nodes[0].decodescript("5b21020e0338c96a8870479f2396c373cc7696ba124e8635d41b0ea581112b678172612102675333a4e4b8fb51d9d4e22fa5a8eaced3fdac8a8cbf9be8c030f75712e6af992102896807d54bc55c24981f24a453c60ad3e8993d693732288068a23df3d9f50d4821029e51a5ef5db3137051de8323b001749932f2ff0d34c82e96a2c2461de96ae56c2102a4e1a9638d46923272c266631d94d36bdb03a64ee0e14c7518e49d2f29bc401021031c41fdbcebe17bec8d49816e00ca1b5ac34766b91c9f2ac37d39c63e5e008afb2103079e252e85abffd3c401a69b087e590a9b86f33f574f08129ccbd3521ecf516b2103111cf405b627e22135b3b3733a4a34aa5723fb0f58379a16d32861bf576b0ec2210318f331b3e5d38156da6633b31929c5b220349859cc9ca3d33fb4e68aa08401742103230dae6b4ac93480aeab26d000841298e3b8f6157028e47b0897c1e025165de121035abff4281ff00660f99ab27bb53e6b33689c2cd8dcd364bc3c90ca5aea0d71a62103bd45cddfacf2083b14310ae4a84e25de61e451637346325222747b157446614c2103cc297026b06c71cbfa52089149157b5ff23de027ac5ab781800a578192d175462103d3bde5d63bdb3a6379b461be64dad45eabff42f758543a9645afd42f6d4248282103ed1e8d5109c9ed66f7941bc53cc71137baa76d50d274bda8d5e8ffbd6e61fe9a5fae736402c00fb269522103aab896d53a8e7d6433137bbba940f9c521e085dd07e60994579b64a6d992cf79210291b7d0b1b692f8f524516ed950872e5da10fb1b808b5a526dedc6fed1cf29807210386aa9372fbab374593466bc5451dc59954e90787f08060964d95c87ef34ca5bb53ae68")
assert_equal(res["segwit"]["desc"], "wsh(or_d(multi(11,020e0338c96a8870479f2396c373cc7696ba124e8635d41b0ea581112b67817261,02675333a4e4b8fb51d9d4e22fa5a8eaced3fdac8a8cbf9be8c030f75712e6af99,02896807d54bc55c24981f24a453c60ad3e8993d693732288068a23df3d9f50d48,029e51a5ef5db3137051de8323b001749932f2ff0d34c82e96a2c2461de96ae56c,02a4e1a9638d46923272c266631d94d36bdb03a64ee0e14c7518e49d2f29bc4010,031c41fdbcebe17bec8d49816e00ca1b5ac34766b91c9f2ac37d39c63e5e008afb,03079e252e85abffd3c401a69b087e590a9b86f33f574f08129ccbd3521ecf516b,03111cf405b627e22135b3b3733a4a34aa5723fb0f58379a16d32861bf576b0ec2,0318f331b3e5d38156da6633b31929c5b220349859cc9ca3d33fb4e68aa0840174,03230dae6b4ac93480aeab26d000841298e3b8f6157028e47b0897c1e025165de1,035abff4281ff00660f99ab27bb53e6b33689c2cd8dcd364bc3c90ca5aea0d71a6,03bd45cddfacf2083b14310ae4a84e25de61e451637346325222747b157446614c,03cc297026b06c71cbfa52089149157b5ff23de027ac5ab781800a578192d17546,03d3bde5d63bdb3a6379b461be64dad45eabff42f758543a9645afd42f6d424828,03ed1e8d5109c9ed66f7941bc53cc71137baa76d50d274bda8d5e8ffbd6e61fe9a),and_v(v:older(4032),multi(2,03aab896d53a8e7d6433137bbba940f9c521e085dd07e60994579b64a6d992cf79,0291b7d0b1b692f8f524516ed950872e5da10fb1b808b5a526dedc6fed1cf29807,0386aa9372fbab374593466bc5451dc59954e90787f08060964d95c87ef34ca5bb))))#7jwwklk4")
diff --git a/test/functional/test_framework/v2_p2p.py b/test/functional/test_framework/v2_p2p.py
index 5315aaf8..087b885a 100644
--- a/test/functional/test_framework/v2_p2p.py
+++ b/test/functional/test_framework/v2_p2p.py
@@ -12,6 +12,7 @@ from .crypto.ellswift import ellswift_create, ellswift_ecdh_xonly
from .crypto.hkdf import hkdf_sha256
from .key import TaggedHash
from .messages import MAGIC_BYTES
+from .util import assert_equal
CHACHA20POLY1305_EXPANSION = 16
@@ -218,7 +219,7 @@ class EncryptedP2PState:
# decoy packets have contents = None. v2 handshake is complete only when version packet
# (can be empty with contents = b"") with contents != None is received.
if contents is not None:
- assert contents == b"" # currently TestNode sends an empty version packet
+ assert_equal(contents, b"") # currently TestNode sends an empty version packet
self.tried_v2_handshake = True
return processed_length, True
response = response[length:]
diff --git a/test/functional/wallet_listdescriptors.py b/test/functional/wallet_listdescriptors.py
index e7d33cc2..8fae9290 100755
--- a/test/functional/wallet_listdescriptors.py
+++ b/test/functional/wallet_listdescriptors.py
@@ -47,7 +47,7 @@ class ListDescriptorsTest(BitcoinTestFramework):
for item in result['descriptors']:
assert_not_equal(item['desc'], '')
assert item['next_index'] == 0
- assert item['range'] == [0, 0]
+ assert_equal(item['range'], [0, 0])
assert item['timestamp'] is not None
self.log.info('Test that descriptor strings are returned in lexicographically sorted order.')
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.