Skip to content

Commit d7ebacc

Browse files
TheBlueMattajtowns
authored andcommitted
Avoid creating <= 64-byte transactions in most functional tests.
1 parent 955d365 commit d7ebacc

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

test/functional/p2p_ibd_stalling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def run_test(self):
8282

8383
# Need to wait until 1023 blocks are received - the magic total bytes number is a workaround in lack of an rpc
8484
# returning the number of downloaded (but not connected) blocks.
85-
bytes_recv = 172761 if not self.options.v2transport else 169692
85+
bytes_recv = 172761+2*1023 if not self.options.v2transport else 169692+2*1023
8686
self.wait_until(lambda: self.total_bytes_recv_for_blocks() == bytes_recv)
8787

8888
self.all_sync_send_with_ping(peers)

test/functional/test_framework/blocktools.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
OP_0,
3939
OP_RETURN,
4040
OP_TRUE,
41+
OP_DROP,
4142
)
4243
from .script_util import (
4344
key_to_p2pk_script,
@@ -164,7 +165,8 @@ def create_coinbase(height, pubkey=None, *, script_pubkey=None, extra_output_scr
164165
elif script_pubkey is not None:
165166
coinbaseoutput.scriptPubKey = script_pubkey
166167
else:
167-
coinbaseoutput.scriptPubKey = CScript([OP_TRUE])
168+
# Use two OP_TRUEs and an OP_DROP to ensure we're always > 64 bytes in non-witness size
169+
coinbaseoutput.scriptPubKey = CScript([OP_TRUE, OP_TRUE, OP_DROP])
168170
coinbase.vout = [coinbaseoutput]
169171
if extra_output_script is not None:
170172
coinbaseoutput2 = CTxOut()
@@ -181,7 +183,7 @@ def create_tx_with_script(prevtx, n, script_sig=b"", *, amount, output_script=No
181183
Can optionally pass scriptPubKey and scriptSig, default is anyone-can-spend output.
182184
"""
183185
if output_script is None:
184-
output_script = CScript()
186+
output_script = CScript([OP_TRUE, OP_DROP, OP_TRUE, OP_DROP])
185187
tx = CTransaction()
186188
assert n < len(prevtx.vout)
187189
tx.vin.append(CTxIn(COutPoint(prevtx.sha256, n), script_sig, SEQUENCE_FINAL))

0 commit comments

Comments
 (0)