mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-15 16:38:23 +01:00
test: simplify (w)txid checks by avoiding .calc_sha256 calls
Calls on the tx.calc_sha256 method can be confusing, as they return the result (either txid or wtxid, depending on the with_witness boolean parameter) as integer rather than as actual (w)txid. Use .rehash() and .getwtxid() instead to improve readability and in some cases avoid a conversion from string-txid to an integer.
This commit is contained in:
@@ -336,8 +336,7 @@ class SegWitTest(BitcoinTestFramework):
|
||||
|
||||
# Verify the hash with witness differs from the txid
|
||||
# (otherwise our testing framework must be broken!)
|
||||
tx.rehash()
|
||||
assert tx.sha256 != tx.calc_sha256(with_witness=True)
|
||||
assert tx.rehash() != tx.getwtxid()
|
||||
|
||||
# Construct a block that includes the transaction.
|
||||
block = self.build_next_block()
|
||||
@@ -1293,7 +1292,7 @@ class SegWitTest(BitcoinTestFramework):
|
||||
# Test that getrawtransaction returns correct witness information
|
||||
# hash, size, vsize
|
||||
raw_tx = self.nodes[0].getrawtransaction(tx3.hash, 1)
|
||||
assert_equal(int(raw_tx["hash"], 16), tx3.calc_sha256(True))
|
||||
assert_equal(raw_tx["hash"], tx3.getwtxid())
|
||||
assert_equal(raw_tx["size"], len(tx3.serialize_with_witness()))
|
||||
vsize = tx3.get_vsize()
|
||||
assert_equal(raw_tx["vsize"], vsize)
|
||||
|
||||
Reference in New Issue
Block a user