Skip to content

Commit b167e53

Browse files
committed
test: refactor: use create_lots_of_big_transactions to dedup where possible
1 parent 8973eeb commit b167e53

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed

test/functional/mempool_limit.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
from decimal import Decimal
88

99
from test_framework.blocktools import COINBASE_MATURITY
10-
from test_framework.messages import COIN
1110
from test_framework.test_framework import BitcoinTestFramework
1211
from test_framework.util import (
1312
assert_equal,
1413
assert_greater_than,
1514
assert_raises_rpc_error,
15+
create_lots_of_big_transactions,
1616
gen_return_txouts,
1717
)
1818
from test_framework.wallet import MiniWallet
@@ -29,16 +29,6 @@ def set_test_params(self):
2929
]]
3030
self.supports_cli = False
3131

32-
def send_large_txs(self, node, miniwallet, txouts, fee, tx_batch_size):
33-
for _ in range(tx_batch_size):
34-
tx = miniwallet.create_self_transfer(from_node=node, fee_rate=0, mempool_valid=False)['tx']
35-
for txout in txouts:
36-
tx.vout.append(txout)
37-
tx.vout[0].nValue -= int(fee * COIN)
38-
res = node.testmempoolaccept([tx.serialize().hex()])[0]
39-
assert_equal(res['fees']['base'], fee)
40-
miniwallet.sendrawtransaction(from_node=node, tx_hex=tx.serialize().hex())
41-
4232
def run_test(self):
4333
txouts = gen_return_txouts()
4434
node = self.nodes[0]
@@ -71,7 +61,7 @@ def run_test(self):
7161
self.log.info("Fill up the mempool with txs with higher fee rate")
7262
for batch_of_txid in range(num_of_batches):
7363
fee = (batch_of_txid + 1) * base_fee
74-
self.send_large_txs(node, miniwallet, txouts, fee, tx_batch_size)
64+
create_lots_of_big_transactions(miniwallet, node, fee, tx_batch_size, txouts)
7565

7666
self.log.info('The tx should be evicted by now')
7767
# The number of transactions created should be greater than the ones present in the mempool

test/functional/test_framework/util.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -575,13 +575,8 @@ def mine_large_block(test_framework, mini_wallet, node):
575575
# generate a 66k transaction,
576576
# and 14 of them is close to the 1MB block limit
577577
txouts = gen_return_txouts()
578-
from .messages import COIN
579-
fee = 100 * int(node.getnetworkinfo()["relayfee"] * COIN)
580-
for _ in range(14):
581-
tx = mini_wallet.create_self_transfer(from_node=node, fee_rate=0, mempool_valid=False)['tx']
582-
tx.vout[0].nValue -= fee
583-
tx.vout.extend(txouts)
584-
mini_wallet.sendrawtransaction(from_node=node, tx_hex=tx.serialize().hex())
578+
fee = 100 * node.getnetworkinfo()["relayfee"]
579+
create_lots_of_big_transactions(mini_wallet, node, fee, 14, txouts)
585580
test_framework.generate(node, 1)
586581

587582

0 commit comments

Comments
 (0)