Skip to content

Commit ed427e1

Browse files
committed
tests: modified tests to use vsize_bip141 flag
1 parent 9cf46b6 commit ed427e1

File tree

7 files changed

+22
-0
lines changed

7 files changed

+22
-0
lines changed

test/functional/feature_segwit.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ def run_test(self):
288288

289289
# Check that weight and vsize are properly reported in mempool entry (txid1)
290290
assert_equal(self.nodes[0].getmempoolentry(txid1)["vsize"], tx1.get_vsize())
291+
assert_equal(self.nodes[0].getmempoolentry(txid1)["vsize_bip141"], tx1.get_vsize())
291292
assert_equal(self.nodes[0].getmempoolentry(txid1)["weight"], tx1.get_weight())
292293

293294
# Now create tx2, which will spend from txid1.
@@ -304,6 +305,7 @@ def run_test(self):
304305

305306
# Check that weight and vsize are properly reported in mempool entry (txid2)
306307
assert_equal(self.nodes[0].getmempoolentry(txid2)["vsize"], tx.get_vsize())
308+
assert_equal(self.nodes[0].getmempoolentry(txid2)["vsize_bip141"], tx.get_vsize())
307309
assert_equal(self.nodes[0].getmempoolentry(txid2)["weight"], tx.get_weight())
308310

309311
# Now create tx3, which will spend from txid2
@@ -327,6 +329,7 @@ def run_test(self):
327329

328330
# Check that weight and vsize are properly reported in mempool entry (txid3)
329331
assert_equal(self.nodes[0].getmempoolentry(txid3)["vsize"], tx.get_vsize())
332+
assert_equal(self.nodes[0].getmempoolentry(txid3)["vsize_bip141"], tx.get_vsize())
330333
assert_equal(self.nodes[0].getmempoolentry(txid3)["weight"], tx.get_weight())
331334

332335
# Mine a block to clear the gbt cache again.

test/functional/mempool_packages.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def run_test(self):
6969
descendant_vsize = 0
7070

7171
assert_equal(ancestor_vsize, sum([mempool[tx]['vsize'] for tx in mempool]))
72+
assert_equal(ancestor_vsize, sum([mempool[tx]['vsize_bip141'] for tx in mempool]))
7273
ancestor_count = DEFAULT_ANCESTOR_LIMIT
7374
assert_equal(ancestor_fees, sum([mempool[tx]['fees']['base'] for tx in mempool]))
7475

test/functional/mempool_sigoplimit.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def test_sigops_limit(self, bytes_per_sigop, num_sigops):
9191
res = self.nodes[0].testmempoolaccept([tx.serialize().hex()])[0]
9292
assert_equal(res['allowed'], True)
9393
assert_equal(res['vsize'], sigop_equivalent_vsize)
94+
assert_equal(res['vsize_bip141'], sigop_equivalent_vsize)
9495

9596
# increase the tx's vsize to be right above the sigop-limit equivalent size
9697
# => tx's vsize in mempool should also grow accordingly

test/functional/mining_prioritisetransaction.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,14 @@ def run_test(self):
207207
# create more transactions.
208208
mempool = self.nodes[0].getrawmempool(True)
209209
sizes = [0, 0, 0]
210+
sizes_bip141 = [0, 0, 0]
210211
for i in range(3):
211212
for j in txids[i]:
212213
assert j in mempool
213214
sizes[i] += mempool[j]['vsize']
215+
sizes_bip141[i] += mempool[j]['vsize_bip141']
214216
assert sizes[i] > MAX_BLOCK_WEIGHT // 4 # Fail => raise utxo_count
217+
assert sizes_bip141[i] > MAX_BLOCK_WEIGHT // 4 # Fail => raise utxo_count
215218

216219
assert_equal(self.nodes[0].getprioritisedtransactions(), {})
217220
# add a fee delta to something in the cheapest bucket and make sure it gets mined

test/functional/rpc_packages.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ def test_rbf(self):
244244
assert_equal(testres_replaceable["wtxid"], replaceable_tx["wtxid"])
245245
assert testres_replaceable["allowed"]
246246
assert_equal(testres_replaceable["vsize"], replaceable_tx["tx"].get_vsize())
247+
assert_equal(testres_replaceable["vsize_bip141"], replaceable_tx["tx"].get_vsize())
247248
assert_equal(testres_replaceable["fees"]["base"], fee)
248249
assert_fee_amount(fee, replaceable_tx["tx"].get_vsize(), testres_replaceable["fees"]["effective-feerate"])
249250
assert_equal(testres_replaceable["fees"]["effective-includes"], [replaceable_tx["wtxid"]])
@@ -280,9 +281,11 @@ def assert_equal_package_results(self, node, testmempoolaccept_result, submitpac
280281
# No "allowed" if the tx was already in the mempool
281282
if "allowed" in testres_tx and testres_tx["allowed"]:
282283
assert_equal(submitres_tx["vsize"], testres_tx["vsize"])
284+
assert_equal(submitres_tx["vsize_bip141"], testres_tx["vsize_bip141"])
283285
assert_equal(submitres_tx["fees"]["base"], testres_tx["fees"]["base"])
284286
entry_info = node.getmempoolentry(submitres_tx["txid"])
285287
assert_equal(submitres_tx["vsize"], entry_info["vsize"])
288+
assert_equal(submitres_tx["vsize_bip141"], entry_info["vsize_bip141"])
286289
assert_equal(submitres_tx["fees"]["base"], entry_info["fees"]["base"])
287290

288291
def test_submit_child_with_parents(self, num_parents, partial_submit):

test/functional/wallet_basic.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ def check_fee_amount(self, curr_balance, balance_with_fee, fee_per_byte, tx_size
6060
def get_vsize(self, txn):
6161
return self.nodes[0].decoderawtransaction(txn)['vsize']
6262

63+
def get_vsize_bip141(self, txn):
64+
return self.nodes[0].decoderawtransaction(txn)['vsize_bip141']
65+
6366
def run_test(self):
6467

6568
# Check that there's no UTXO on none of the nodes
@@ -487,10 +490,12 @@ def run_test(self):
487490
# Test passing fee_rate as an integer
488491
txid = self.nodes[2].sendtoaddress(address=address, amount=amount, fee_rate=fee_rate_sat_vb)
489492
tx_size = self.get_vsize(self.nodes[2].gettransaction(txid)['hex'])
493+
tx_size_bip141 = self.get_vsize_bip141(self.nodes[2].gettransaction(txid)['hex'])
490494
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
491495
postbalance = self.nodes[2].getbalance()
492496
fee = prebalance - postbalance - Decimal(amount)
493497
assert_fee_amount(fee, tx_size, Decimal(fee_rate_btc_kvb))
498+
assert_fee_amount(fee, tx_size_bip141, Decimal(fee_rate_btc_kvb))
494499

495500
prebalance = self.nodes[2].getbalance()
496501
amount = Decimal("0.001")
@@ -499,10 +504,12 @@ def run_test(self):
499504
# Test passing fee_rate as a string
500505
txid = self.nodes[2].sendtoaddress(address=address, amount=amount, fee_rate=str(fee_rate_sat_vb))
501506
tx_size = self.get_vsize(self.nodes[2].gettransaction(txid)['hex'])
507+
tx_size_bip141 = self.get_vsize_bip141(self.nodes[2].gettransaction(txid)['hex'])
502508
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
503509
postbalance = self.nodes[2].getbalance()
504510
fee = prebalance - postbalance - amount
505511
assert_fee_amount(fee, tx_size, Decimal(fee_rate_btc_kvb))
512+
assert_fee_amount(fee, tx_size_bip141, Decimal(fee_rate_btc_kvb))
506513

507514
# Test setting explicit fee rate just below the minimum.
508515
self.log.info("Test sendtoaddress raises 'fee rate too low' if fee_rate of 0.99999999 is passed")

test/functional/wallet_bumpfee.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ def test_notmine_bumpfee(self, rbf_node, peer_node, dest_address):
397397
entry = rbf_node.getmempoolentry(rbfid)
398398
old_fee = entry["fees"]["base"]
399399
old_feerate = int(old_fee / entry["vsize"] * Decimal(1e8))
400+
old_feerate_bip141 = int(old_fee / entry["vsize_bip141"] * Decimal(1e8))
400401
assert_raises_rpc_error(-4, "Transaction contains inputs that don't belong to this wallet",
401402
rbf_node.bumpfee, rbfid)
402403

@@ -415,6 +416,9 @@ def finish_psbtbumpfee(psbt):
415416
psbt = rbf_node.psbtbumpfee(txid=rbfid, fee_rate=old_feerate + 10)
416417
finish_psbtbumpfee(psbt["psbt"])
417418

419+
psbt = rbf_node.psbtbumpfee(txid=rbfid, fee_rate=old_feerate_bip141 + 10)
420+
finish_psbtbumpfee(psbt["psbt"])
421+
418422
self.clear_mempool()
419423

420424

0 commit comments

Comments
 (0)