mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-29 05:22:30 +02:00
Merge #15282: test: Replace hard-coded hex tx with class in test framework
8f250ab788
TEST: Replace hard-coded hex tx with classes (Steven Roose) Pull request description: Came across these breaking Elements. ACKs for top commit: MarcoFalke: ACK8f250ab788
instagibbs: utACK8f250ab788
Tree-SHA512: e8615dad4cda0beea4b0c7d4951a467fb9882a0a64d49c9b5ecf167369ea62a3fe5348e2401153162b0ccadecdb128492c94be36ebb881c3c42659626d86eda8
This commit is contained in:
commit
0822b44d8a
@ -19,6 +19,7 @@ import time
|
|||||||
|
|
||||||
from . import coverage
|
from . import coverage
|
||||||
from .authproxy import AuthServiceProxy, JSONRPCException
|
from .authproxy import AuthServiceProxy, JSONRPCException
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
logger = logging.getLogger("TestFramework.utils")
|
logger = logging.getLogger("TestFramework.utils")
|
||||||
|
|
||||||
@ -515,14 +516,13 @@ def gen_return_txouts():
|
|||||||
for i in range(512):
|
for i in range(512):
|
||||||
script_pubkey = script_pubkey + "01"
|
script_pubkey = script_pubkey + "01"
|
||||||
# concatenate 128 txouts of above script_pubkey which we'll insert before the txout for change
|
# concatenate 128 txouts of above script_pubkey which we'll insert before the txout for change
|
||||||
txouts = "81"
|
txouts = []
|
||||||
|
from .messages import CTxOut
|
||||||
|
txout = CTxOut()
|
||||||
|
txout.nValue = 0
|
||||||
|
txout.scriptPubKey = hex_str_to_bytes(script_pubkey)
|
||||||
for k in range(128):
|
for k in range(128):
|
||||||
# add txout value
|
txouts.append(txout)
|
||||||
txouts = txouts + "0000000000000000"
|
|
||||||
# add length of script_pubkey
|
|
||||||
txouts = txouts + "fd0402"
|
|
||||||
# add script_pubkey
|
|
||||||
txouts = txouts + script_pubkey
|
|
||||||
return txouts
|
return txouts
|
||||||
|
|
||||||
# Create a spend of each passed-in utxo, splicing in "txouts" to each raw
|
# Create a spend of each passed-in utxo, splicing in "txouts" to each raw
|
||||||
@ -530,6 +530,7 @@ def gen_return_txouts():
|
|||||||
def create_lots_of_big_transactions(node, txouts, utxos, num, fee):
|
def create_lots_of_big_transactions(node, txouts, utxos, num, fee):
|
||||||
addr = node.getnewaddress()
|
addr = node.getnewaddress()
|
||||||
txids = []
|
txids = []
|
||||||
|
from .messages import CTransaction
|
||||||
for _ in range(num):
|
for _ in range(num):
|
||||||
t = utxos.pop()
|
t = utxos.pop()
|
||||||
inputs = [{"txid": t["txid"], "vout": t["vout"]}]
|
inputs = [{"txid": t["txid"], "vout": t["vout"]}]
|
||||||
@ -537,9 +538,11 @@ def create_lots_of_big_transactions(node, txouts, utxos, num, fee):
|
|||||||
change = t['amount'] - fee
|
change = t['amount'] - fee
|
||||||
outputs[addr] = satoshi_round(change)
|
outputs[addr] = satoshi_round(change)
|
||||||
rawtx = node.createrawtransaction(inputs, outputs)
|
rawtx = node.createrawtransaction(inputs, outputs)
|
||||||
newtx = rawtx[0:92]
|
tx = CTransaction()
|
||||||
newtx = newtx + txouts
|
tx.deserialize(BytesIO(hex_str_to_bytes(rawtx)))
|
||||||
newtx = newtx + rawtx[94:]
|
for txout in txouts:
|
||||||
|
tx.vout.append(txout)
|
||||||
|
newtx = tx.serialize().hex()
|
||||||
signresult = node.signrawtransactionwithwallet(newtx, None, "NONE")
|
signresult = node.signrawtransactionwithwallet(newtx, None, "NONE")
|
||||||
txid = node.sendrawtransaction(signresult["hex"], 0)
|
txid = node.sendrawtransaction(signresult["hex"], 0)
|
||||||
txids.append(txid)
|
txids.append(txid)
|
||||||
|
Loading…
Reference in New Issue
Block a user