test: raise an error when target_vsize is below tx virtual size

This commit is contained in:
ismaelsadeeq 2024-10-01 23:21:29 +01:00
parent a8780c937f
commit 92787dd52c
No known key found for this signature in database
GPG Key ID: 0E3908F364989888

View File

@ -121,6 +121,9 @@ class MiniWallet:
"""Pad a transaction with extra outputs until it reaches a target vsize.
returns the tx
"""
if target_vsize < tx.get_vsize():
raise RuntimeError(f"target_vsize {target_vsize} is less than transaction virtual size {tx.get_vsize()}")
tx.vout.append(CTxOut(nValue=0, scriptPubKey=CScript([OP_RETURN])))
# determine number of needed padding bytes
dummy_vbytes = target_vsize - tx.get_vsize()