HomePhabricator

test: remove txid caching in CTransaction class

Description

test: remove txid caching in CTransaction class

Summary:
Rather than txids (represented by the fields .sha256 and .hash)
being stateful, simply compute them on-the-fly. This ensures that
the correct values are always returned and takes the burden of
rehashing from test writers, making the code shorter overall.
In a first step, the fields are kept at the same name with @property
functions as drop-in replacements, for a minimal diff. In later commits,
the names are changed to be more descriptive and indicating the return
type of the txid.

This is a partial backport of core#32421
https://github.com/bitcoin/bitcoin/pull/32421/commits/a2724e3ea392cdbd5526735516862b17bf687624

Depends on D18711

Note that contrary to Bitcoin Core, Bitcoin ABC never uses the return value of CTransaction.calc_sha256() so we can remove it immediately.

Test Plan: ninja check-functional-extended

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D18712

Details

Provenance
Sebastian Falbesoner <sebastian.falbesoner@gmail.com>Authored on May 4 2025, 17:01
PiRKCommitted on Sep 30 2025, 09:48
PiRKPushed on Sep 30 2025, 09:48
Reviewer
Restricted Project
Differential Revision
D18712: test: remove txid caching in CTransaction class
Parents
rABCfe4ce9642e82: test: remove unused code from p2p_compactblocks
Branches
Unknown
Tags
Unknown