aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework
diff options
context:
space:
mode:
authorMacroFake <falke.marco@gmail.com>2022-08-03 12:10:52 +0200
committerMacroFake <falke.marco@gmail.com>2022-08-03 12:02:20 +0200
commitfa2537cf0a7629d81df1bc5b4ae6a22dc572647b (patch)
tree405ae8ae998a9399345bfdc81c255b256b21dfcb /test/functional/test_framework
parent9155f9b7af22a9c97cbeee461f5bbd9217adb56d (diff)
downloadbitcoin-fa2537cf0a7629d81df1bc5b4ae6a22dc572647b.tar.xz
test: Target exact weight in MiniWallet _bulk_tx
Also, replace broad -acceptnonstdtxn=1 with -datacarriersize=100000
Diffstat (limited to 'test/functional/test_framework')
-rw-r--r--test/functional/test_framework/wallet.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/test/functional/test_framework/wallet.py b/test/functional/test_framework/wallet.py
index b671ecbaf2..374fda5c23 100644
--- a/test/functional/test_framework/wallet.py
+++ b/test/functional/test_framework/wallet.py
@@ -39,6 +39,7 @@ from test_framework.script import (
LegacySignatureHash,
LEAF_VERSION_TAPSCRIPT,
OP_NOP,
+ OP_RETURN,
OP_TRUE,
SIGHASH_ALL,
taproot_construct,
@@ -107,11 +108,13 @@ class MiniWallet:
"""Pad a transaction with extra outputs until it reaches a target weight (or higher).
returns the tx
"""
- assert_greater_than_or_equal(target_weight, tx.get_weight())
- while tx.get_weight() < target_weight:
- script_pubkey = ( b"6a4d0200" # OP_RETURN OP_PUSH2 512 bytes
- + b"01" * 512 )
- tx.vout.append(CTxOut(0, script_pubkey))
+ tx.vout.append(CTxOut(nValue=0, scriptPubKey=CScript([OP_RETURN, b'a'])))
+ dummy_vbytes = (target_weight - tx.get_weight() + 3) // 4
+ tx.vout[-1].scriptPubKey = CScript([OP_RETURN, b'a' * dummy_vbytes])
+ # Lower bound should always be off by at most 3
+ assert_greater_than_or_equal(tx.get_weight(), target_weight)
+ # Higher bound should always be off by at most 3 + 12 weight (for encoding the length)
+ assert_greater_than_or_equal(target_weight + 15, tx.get_weight())
def get_balance(self):
return sum(u['value'] for u in self._utxos)