aboutsummaryrefslogtreecommitdiff
path: root/test/functional/p2p_segwit.py
diff options
context:
space:
mode:
authorMatt Corallo <git@bluematt.me>2018-03-27 17:21:17 -0400
committerMatt Corallo <git@bluematt.me>2018-04-13 15:18:26 -0400
commitd0d9112b79f8c08971dd140143306ca497c47de7 (patch)
treea33656d4a61e7e910d3b81dc6b1354c12f2d887c /test/functional/p2p_segwit.py
parent2874709a9f23d16eacfee1e53fadaff8081f16e6 (diff)
downloadbitcoin-d0d9112b79f8c08971dd140143306ca497c47de7.tar.xz
Test new weight field in p2p_segwit
Diffstat (limited to 'test/functional/p2p_segwit.py')
-rwxr-xr-xtest/functional/p2p_segwit.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/test/functional/p2p_segwit.py b/test/functional/p2p_segwit.py
index 5546bf6b29..856e4d5cfe 100755
--- a/test/functional/p2p_segwit.py
+++ b/test/functional/p2p_segwit.py
@@ -10,6 +10,7 @@ from test_framework.util import *
from test_framework.script import *
from test_framework.blocktools import create_block, create_coinbase, add_witness_commitment, get_witness_script, WITNESS_COMMITMENT_HEADER
from test_framework.key import CECKey, CPubKey
+import math
import time
import random
from binascii import hexlify
@@ -930,8 +931,10 @@ 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()))
- vsize = (len(tx3.serialize_with_witness()) + 3*len(tx3.serialize_without_witness()) + 3) / 4
+ weight = len(tx3.serialize_with_witness()) + 3*len(tx3.serialize_without_witness())
+ vsize = math.ceil(weight / 4)
assert_equal(raw_tx["vsize"], vsize)
+ assert_equal(raw_tx["weight"], weight)
assert_equal(len(raw_tx["vin"][0]["txinwitness"]), 1)
assert_equal(raw_tx["vin"][0]["txinwitness"][0], hexlify(witness_program).decode('ascii'))
assert(vsize != raw_tx["size"])