test: refactor: replace unnecessary BytesIO uses

Rather than needing to create intermediate stream variables, we can use
helper functions like `tx_from_hex` instead or access the result
directly, leading both to increased readability and less code.
This commit is contained in:
Sebastian Falbesoner
2023-04-01 14:10:01 +02:00
parent a0d37d1d23
commit f842ed9a40
3 changed files with 9 additions and 15 deletions

View File

@@ -19,6 +19,7 @@ from test_framework.messages import (
CTxInWitness,
CTxOut,
SEQUENCE_FINAL,
tx_from_hex,
)
from test_framework.script import (
ANNEX_TAG,
@@ -109,7 +110,6 @@ from test_framework.address import (
program_to_witness,
)
from collections import OrderedDict, namedtuple
from io import BytesIO
import json
import hashlib
import os
@@ -1386,8 +1386,7 @@ class TaprootTest(BitcoinTestFramework):
# Add change
fund_tx.vout.append(CTxOut(balance - 10000, random.choice(host_spks)))
# Ask the wallet to sign
ss = BytesIO(bytes.fromhex(node.signrawtransactionwithwallet(fund_tx.serialize().hex())["hex"]))
fund_tx.deserialize(ss)
fund_tx = tx_from_hex(node.signrawtransactionwithwallet(fund_tx.serialize().hex())["hex"])
# Construct UTXOData entries
fund_tx.rehash()
for i in range(count_this_tx):