mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-29 10:19:26 +02:00
test: introduce get_weight()
helper for CTransaction
This commit is contained in:
@ -4,7 +4,6 @@
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
"""Test segwit transactions and blocks on P2P network."""
|
||||
from decimal import Decimal
|
||||
import math
|
||||
import random
|
||||
import struct
|
||||
import time
|
||||
@ -1367,10 +1366,9 @@ class SegWitTest(BitcoinTestFramework):
|
||||
raw_tx = self.nodes[0].getrawtransaction(tx3.hash, 1)
|
||||
assert_equal(int(raw_tx["hash"], 16), tx3.calc_sha256(True))
|
||||
assert_equal(raw_tx["size"], len(tx3.serialize_with_witness()))
|
||||
weight = len(tx3.serialize_with_witness()) + 3 * len(tx3.serialize_without_witness())
|
||||
vsize = math.ceil(weight / 4)
|
||||
vsize = tx3.get_vsize()
|
||||
assert_equal(raw_tx["vsize"], vsize)
|
||||
assert_equal(raw_tx["weight"], weight)
|
||||
assert_equal(raw_tx["weight"], tx3.get_weight())
|
||||
assert_equal(len(raw_tx["vin"][0]["txinwitness"]), 1)
|
||||
assert_equal(raw_tx["vin"][0]["txinwitness"][0], witness_program.hex())
|
||||
assert vsize != raw_tx["size"]
|
||||
|
Reference in New Issue
Block a user