Skip to content

Commit d0d9112

Browse files
committed
Test new weight field in p2p_segwit
1 parent 2874709 commit d0d9112

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

test/functional/p2p_segwit.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from test_framework.script import *
1111
from test_framework.blocktools import create_block, create_coinbase, add_witness_commitment, get_witness_script, WITNESS_COMMITMENT_HEADER
1212
from test_framework.key import CECKey, CPubKey
13+
import math
1314
import time
1415
import random
1516
from binascii import hexlify
@@ -930,8 +931,10 @@ def test_tx_relay_after_segwit_activation(self):
930931
raw_tx = self.nodes[0].getrawtransaction(tx3.hash, 1)
931932
assert_equal(int(raw_tx["hash"], 16), tx3.calc_sha256(True))
932933
assert_equal(raw_tx["size"], len(tx3.serialize_with_witness()))
933-
vsize = (len(tx3.serialize_with_witness()) + 3*len(tx3.serialize_without_witness()) + 3) / 4
934+
weight = len(tx3.serialize_with_witness()) + 3*len(tx3.serialize_without_witness())
935+
vsize = math.ceil(weight / 4)
934936
assert_equal(raw_tx["vsize"], vsize)
937+
assert_equal(raw_tx["weight"], weight)
935938
assert_equal(len(raw_tx["vin"][0]["txinwitness"]), 1)
936939
assert_equal(raw_tx["vin"][0]["txinwitness"][0], hexlify(witness_program).decode('ascii'))
937940
assert(vsize != raw_tx["size"])

0 commit comments

Comments
 (0)