mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-02 09:15:04 +02: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:
@@ -267,7 +267,7 @@ class SegWitTest(BitcoinTestFramework):
|
||||
tx1 = tx_from_hex(tx1_hex)
|
||||
|
||||
# Check that wtxid is properly reported in mempool entry (txid1)
|
||||
assert_equal(int(self.nodes[0].getmempoolentry(txid1)["wtxid"], 16), tx1.calc_sha256(True))
|
||||
assert_equal(self.nodes[0].getmempoolentry(txid1)["wtxid"], tx1.getwtxid())
|
||||
|
||||
# Check that weight and vsize are properly reported in mempool entry (txid1)
|
||||
assert_equal(self.nodes[0].getmempoolentry(txid1)["vsize"], tx1.get_vsize())
|
||||
@@ -283,7 +283,7 @@ class SegWitTest(BitcoinTestFramework):
|
||||
assert not tx.wit.is_null()
|
||||
|
||||
# Check that wtxid is properly reported in mempool entry (txid2)
|
||||
assert_equal(int(self.nodes[0].getmempoolentry(txid2)["wtxid"], 16), tx.calc_sha256(True))
|
||||
assert_equal(self.nodes[0].getmempoolentry(txid2)["wtxid"], tx.getwtxid())
|
||||
|
||||
# Check that weight and vsize are properly reported in mempool entry (txid2)
|
||||
assert_equal(self.nodes[0].getmempoolentry(txid2)["vsize"], tx.get_vsize())
|
||||
@@ -306,7 +306,7 @@ class SegWitTest(BitcoinTestFramework):
|
||||
assert txid3 in template_txids
|
||||
|
||||
# Check that wtxid is properly reported in mempool entry (txid3)
|
||||
assert_equal(int(self.nodes[0].getmempoolentry(txid3)["wtxid"], 16), tx.calc_sha256(True))
|
||||
assert_equal(self.nodes[0].getmempoolentry(txid3)["wtxid"], tx.getwtxid())
|
||||
|
||||
# Check that weight and vsize are properly reported in mempool entry (txid3)
|
||||
assert_equal(self.nodes[0].getmempoolentry(txid3)["vsize"], tx.get_vsize())
|
||||
|
||||
Reference in New Issue
Block a user