test: prep manual equality assert conversions

The later scripted diff only handles plain `assert x == y` lines.
Some remaining tests still use equality inside comprehensions, parenthesized asserts, and other shapes that the line-based rewrite would misread.
Rewrite those sites by hand first so the later mechanical conversion stays safe.
The commit also simplifies the dead `len(["errors"]) == 0` branch in `blocktools.py`, which can never be true.
This commit is contained in:
Lőrinc
2026-03-08 21:22:43 +00:00
parent 4f4516e3f6
commit dcd90fbe54
16 changed files with 49 additions and 34 deletions

View File

@@ -267,7 +267,7 @@ def send_to_witness(use_p2wsh, node, utxo, pubkey, encode_p2sh, amount, sign=Tru
tx_to_witness = create_witness_tx(node, use_p2wsh, utxo, pubkey, encode_p2sh, amount)
if (sign):
signed = node.signrawtransactionwithwallet(tx_to_witness)
assert "errors" not in signed or len(["errors"]) == 0
assert "errors" not in signed
return node.sendrawtransaction(signed["hex"])
else:
if (insert_redeem_script):

View File

@@ -21,6 +21,7 @@ from .messages import (
)
from .crypto.ripemd160 import ripemd160
from .util import assert_equal
MAX_SCRIPT_ELEMENT_SIZE = 520
MAX_SCRIPT_SIZE = 10000
@@ -814,8 +815,8 @@ def BIP341_sha_outputs(txTo):
return sha256(b"".join(o.serialize() for o in txTo.vout))
def TaprootSignatureMsg(txTo, spent_utxos, hash_type, input_index=0, *, scriptpath=False, leaf_script=None, codeseparator_pos=-1, annex=None, leaf_ver=LEAF_VERSION_TAPSCRIPT):
assert (len(txTo.vin) == len(spent_utxos))
assert (input_index < len(txTo.vin))
assert_equal(len(txTo.vin), len(spent_utxos))
assert input_index < len(txTo.vin)
out_type = SIGHASH_ALL if hash_type == 0 else hash_type & 3
in_type = hash_type & SIGHASH_ANYONECANPAY
spk = spent_utxos[input_index].scriptPubKey

View File

@@ -673,7 +673,8 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
`[{"txid": txid, "vout": vout1}, {"txid": txid, "vout": vout2}, ...]`.
The result can be used to specify inputs for RPCs like `createrawtransaction`,
`createpsbt`, `lockunspent` etc."""
assert all(len(output.keys()) == 1 for output in outputs)
for output in outputs:
assert_equal(len(output.keys()), 1)
send_res = node.send(outputs)
assert send_res["complete"]
utxos = []