test: remove child_one/child_two (w)txid variables
What changed, and why it matters
This is a minor cleanup of a single test file. It removes four temporary variables that stored transaction IDs and replaces their uses with direct property access. There is no change to Bitcoin Core's actual network or wallet behavior, and no security relevance.
No action required. This is a non-security test-only refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
Commit 3f5211cba8e73e8eb03781e6ec32ba9c4a263782 refactors test/functional/mempool_accept_wtxid.py by inlining child_one/child_two txid_hex and wtxid_hex references. The diff removes 13 lines and adds 9 lines, all within one functional test. No production code, consensus logic, P2P protocol, or mempool rules are modified.
Changed components
test/functional/mempool_accept_wtxid.pyInspect captured patch +9 / −13
diff --git a/test/functional/mempool_accept_wtxid.py b/test/functional/mempool_accept_wtxid.py
index e388114d..a9edea6d 100755
--- a/test/functional/mempool_accept_wtxid.py
+++ b/test/functional/mempool_accept_wtxid.py
@@ -45,31 +45,27 @@ class MempoolWtxidTest(BitcoinTestFramework):
self.generate(node, 1)
peer_wtxid_relay = node.add_p2p_connection(P2PTxInvStore())
- child_one_wtxid = child_one.wtxid_hex
- child_one_txid = child_one.txid_hex
- child_two_wtxid = child_two.wtxid_hex
- child_two_txid = child_two.txid_hex
- assert_equal(child_one_txid, child_two_txid)
- assert_not_equal(child_one_wtxid, child_two_wtxid)
+ assert_equal(child_one.txid_hex, child_two.txid_hex)
+ assert_not_equal(child_one.wtxid_hex, child_two.wtxid_hex)
self.log.info("Submit child_one to the mempool")
txid_submitted = node.sendrawtransaction(child_one.serialize().hex())
- assert_equal(node.getmempoolentry(txid_submitted)['wtxid'], child_one_wtxid)
- peer_wtxid_relay.wait_for_broadcast([child_one_wtxid])
+ assert_equal(node.getmempoolentry(txid_submitted)['wtxid'], child_one.wtxid_hex)
+ peer_wtxid_relay.wait_for_broadcast([child_one.wtxid_hex])
assert_equal(node.getmempoolinfo()["unbroadcastcount"], 0)
# testmempoolaccept reports the "already in mempool" error
assert_equal(node.testmempoolaccept([child_one.serialize().hex()]), [{
- "txid": child_one_txid,
- "wtxid": child_one_wtxid,
+ "txid": child_one.txid_hex,
+ "wtxid": child_one.wtxid_hex,
"allowed": False,
"reject-reason": "txn-already-in-mempool",
"reject-details": "txn-already-in-mempool"
}])
assert_equal(node.testmempoolaccept([child_two.serialize().hex()])[0], {
- "txid": child_two_txid,
- "wtxid": child_two_wtxid,
+ "txid": child_two.txid_hex,
+ "wtxid": child_two.wtxid_hex,
"allowed": False,
"reject-reason": "txn-same-nonwitness-data-in-mempool",
"reject-details": "txn-same-nonwitness-data-in-mempool"
@@ -87,7 +83,7 @@ class MempoolWtxidTest(BitcoinTestFramework):
# The node should rebroadcast the transaction using the wtxid of the correct transaction
# (child_one, which is in its mempool).
- peer_wtxid_relay_2.wait_for_broadcast([child_one_wtxid])
+ peer_wtxid_relay_2.wait_for_broadcast([child_one.wtxid_hex])
assert_equal(node.getmempoolinfo()["unbroadcastcount"], 0)
if __name__ == '__main__':
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.