diff options
author | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2021-06-30 23:40:39 +0200 |
---|---|---|
committer | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2021-07-01 02:32:25 +0200 |
commit | a084ebe1330bcec15715e08b0f65319142927ad1 (patch) | |
tree | 6d5e8b0add4924c36d47ad1736a43f159d2683b2 /test/functional/test_framework | |
parent | 3fc20abab03d71a982d6fe9c47155834b256ab17 (diff) |
test: introduce `get_weight()` helper for CTransaction
Diffstat (limited to 'test/functional/test_framework')
-rwxr-xr-x | test/functional/test_framework/messages.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index 504c8c70d4..8d0bd9f69a 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -590,12 +590,15 @@ class CTransaction: return False return True - # Calculate the virtual transaction size using witness and non-witness + # Calculate the transaction weight using witness and non-witness # serialization size (does NOT use sigops). - def get_vsize(self): + def get_weight(self): with_witness_size = len(self.serialize_with_witness()) without_witness_size = len(self.serialize_without_witness()) - return math.ceil(((WITNESS_SCALE_FACTOR - 1) * without_witness_size + with_witness_size) / WITNESS_SCALE_FACTOR) + return (WITNESS_SCALE_FACTOR - 1) * without_witness_size + with_witness_size + + def get_vsize(self): + return math.ceil(self.get_weight() / WITNESS_SCALE_FACTOR) def __repr__(self): return "CTransaction(nVersion=%i vin=%s vout=%s wit=%s nLockTime=%i)" \ |