mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-27 06:19:09 +01:00
Merge bitcoin/bitcoin#24839: test: use MiniWallet for mining_prioritisetransaction.py
b167e536d0test: refactor: use `create_lots_of_big_transactions` to dedup where possible (Sebastian Falbesoner)8973eeb412test: use MiniWallet for mining_prioritisetransaction.py (Sebastian Falbesoner) Pull request description: This PR enables one more of the non-wallet functional tests (mining_prioritisetransaction.py) to be run even with the Bitcoin Code wallet by using the MiniWallet instead, as proposed in #20078. Note that the adapted helper function `create_lots_of_big_transactions` is currently only used in this test, i.e. there was no need to change any others. ACKs for top commit: ayush933: tACKb167e53danielabrozzoni: tACKb167e536d0kouloumos: ACKb167e536d0furszy: ACKb167e536Tree-SHA512: ccae20d7d414a720efdeea9c2ae399aa53a3a0e7db72bff8d0cb75d90621a7ae7c019ba68d24f9d06f7b111f87ff33bb9d8e5aa08b763e606cf10268780e205c
This commit is contained in:
@@ -553,24 +553,22 @@ def gen_return_txouts():
|
||||
|
||||
# Create a spend of each passed-in utxo, splicing in "txouts" to each raw
|
||||
# transaction to make it large. See gen_return_txouts() above.
|
||||
def create_lots_of_big_transactions(node, txouts, utxos, num, fee):
|
||||
addr = node.getnewaddress()
|
||||
def create_lots_of_big_transactions(mini_wallet, node, fee, tx_batch_size, txouts, utxos=None):
|
||||
from .messages import COIN
|
||||
fee_sats = int(fee * COIN)
|
||||
txids = []
|
||||
from .messages import tx_from_hex
|
||||
for _ in range(num):
|
||||
t = utxos.pop()
|
||||
inputs = [{"txid": t["txid"], "vout": t["vout"]}]
|
||||
outputs = {}
|
||||
change = t['amount'] - fee
|
||||
outputs[addr] = satoshi_round(change)
|
||||
rawtx = node.createrawtransaction(inputs, outputs)
|
||||
tx = tx_from_hex(rawtx)
|
||||
for txout in txouts:
|
||||
tx.vout.append(txout)
|
||||
newtx = tx.serialize().hex()
|
||||
signresult = node.signrawtransactionwithwallet(newtx, None, "NONE")
|
||||
txid = node.sendrawtransaction(signresult["hex"], 0)
|
||||
txids.append(txid)
|
||||
use_internal_utxos = utxos is None
|
||||
for _ in range(tx_batch_size):
|
||||
tx = mini_wallet.create_self_transfer(
|
||||
from_node=node,
|
||||
utxo_to_spend=None if use_internal_utxos else utxos.pop(),
|
||||
fee_rate=0,
|
||||
mempool_valid=False)['tx']
|
||||
tx.vout[0].nValue -= fee_sats
|
||||
tx.vout.extend(txouts)
|
||||
res = node.testmempoolaccept([tx.serialize().hex()])[0]
|
||||
assert_equal(res['fees']['base'], fee)
|
||||
txids.append(node.sendrawtransaction(tx.serialize().hex()))
|
||||
return txids
|
||||
|
||||
|
||||
@@ -578,13 +576,8 @@ def mine_large_block(test_framework, mini_wallet, node):
|
||||
# generate a 66k transaction,
|
||||
# and 14 of them is close to the 1MB block limit
|
||||
txouts = gen_return_txouts()
|
||||
from .messages import COIN
|
||||
fee = 100 * int(node.getnetworkinfo()["relayfee"] * COIN)
|
||||
for _ in range(14):
|
||||
tx = mini_wallet.create_self_transfer(from_node=node, fee_rate=0, mempool_valid=False)['tx']
|
||||
tx.vout[0].nValue -= fee
|
||||
tx.vout.extend(txouts)
|
||||
mini_wallet.sendrawtransaction(from_node=node, tx_hex=tx.serialize().hex())
|
||||
fee = 100 * node.getnetworkinfo()["relayfee"]
|
||||
create_lots_of_big_transactions(mini_wallet, node, fee, 14, txouts)
|
||||
test_framework.generate(node, 1)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user