test: avoid unneeded hash -> uint256 -> hash roundtrips

In the functional test framework, we often treat hashes
as uint256 integers, which seems to be confusing and for no
good reason, as hashes are just sequences of bytes. This commit
gets rid of obvious internal instances of that where individual
functional tests are not affected. In the long-term, it might make
sense to store other hashes (mostly txids) as actual bytes to
avoid annoying conversions and improve code readability.
This commit is contained in:
Sebastian Falbesoner
2025-03-12 20:16:04 +01:00
parent aa68ed27b8
commit 346a099fc1
2 changed files with 13 additions and 15 deletions

View File

@@ -28,7 +28,6 @@ from .messages import (
ser_uint256,
tx_from_hex,
uint256_from_compact,
uint256_from_str,
WITNESS_SCALE_FACTOR,
)
from .script import (
@@ -111,8 +110,8 @@ def create_block(hashprev=None, coinbase=None, ntime=None, *, version=None, tmpl
return block
def get_witness_script(witness_root, witness_nonce):
witness_commitment = uint256_from_str(hash256(ser_uint256(witness_root) + ser_uint256(witness_nonce)))
output_data = WITNESS_COMMITMENT_HEADER + ser_uint256(witness_commitment)
witness_commitment = hash256(ser_uint256(witness_root) + ser_uint256(witness_nonce))
output_data = WITNESS_COMMITMENT_HEADER + witness_commitment
return CScript([OP_RETURN, output_data])
def add_witness_commitment(block, nonce=0):