Skip to content

Commit 1ee5978

Browse files
author
MacroFake
committed
Merge bitcoin/bitcoin#25503: test: pass datacarriersize option for tests using large outputs (instead of acceptnonstdtxn)
475aae8 test: pass `datacarriersize` option for tests using large outputs (instead of `acceptnonstdtxn`) (Sebastian Falbesoner) b1ba3ed test: let `gen_return_txouts` create a single large OP_RETURN output (Sebastian Falbesoner) f319287 test: assert serialized txouts size of `gen_return_txouts` helper (Sebastian Falbesoner) Pull request description: By specifying the `datacarriersize` option instead of the more generic `acceptnonstdtxn` for functional tests, we can be more specific about what part of the transaction is non-standard and can be sure that all other aspects follow the standard policy. Transactions with more than one OP_RETURN output are [never considered standard](https://github.com/bitcoin/bitcoin/blob/749b80b29e875cc6afa1c2674cccdfd7115cc16a/src/policy/policy.cpp#L149-L153), i.e. we have to change the `gen_return_txouts` helper to create only a single output in order to get rid of the `acceptnonstdxtn` option. Note that on master there is currently no test using the `datacarriersize` parameter, so this PR indirectly also increases the test coverage. The change affects the tests `mempool_limit.py`, `mining_prioritisetransaction.py` (call `gen_return_txouts` directly) and `feature_maxuploadtarget.py` (calls `gen_return_txouts` indirectly via the `mine_large_block(...)` helper). Top commit has no ACKs. Tree-SHA512: c17f032e00d28f5e5880a4d378773fbc8b1995ea9c377f237598d412628fe117f497a44ebdfa8af8cd8a3b1e3127e0cf7692efbf5c833c713764a71a85301f23
2 parents b6cf0f8 + 475aae8 commit 1ee5978

File tree

4 files changed

+8
-17
lines changed

4 files changed

+8
-17
lines changed

test/functional/feature_maxuploadtarget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def set_test_params(self):
4646
self.num_nodes = 1
4747
self.extra_args = [[
4848
"-maxuploadtarget=800M",
49-
"-acceptnonstdtxn=1",
49+
"-datacarriersize=100000",
5050
]]
5151
self.supports_cli = False
5252

test/functional/mempool_limit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def set_test_params(self):
2323
self.setup_clean_chain = True
2424
self.num_nodes = 1
2525
self.extra_args = [[
26-
"-acceptnonstdtxn=1",
26+
"-datacarriersize=100000",
2727
"-maxmempool=5",
2828
"-spendzeroconfchange=0",
2929
]]

test/functional/mining_prioritisetransaction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def set_test_params(self):
2626
self.num_nodes = 1
2727
self.extra_args = [[
2828
"-printpriority=1",
29-
"-acceptnonstdtxn=1",
29+
"-datacarriersize=100000",
3030
]] * self.num_nodes
3131
self.supports_cli = False
3232

test/functional/test_framework/util.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -499,22 +499,13 @@ def chain_transaction(node, parent_txids, vouts, value, fee, num_outputs):
499499

500500

501501
# Create large OP_RETURN txouts that can be appended to a transaction
502-
# to make it large (helper for constructing large transactions).
502+
# to make it large (helper for constructing large transactions). The
503+
# total serialized size of the txouts is about 66k vbytes.
503504
def gen_return_txouts():
504-
# Some pre-processing to create a bunch of OP_RETURN txouts to insert into transactions we create
505-
# So we have big transactions (and therefore can't fit very many into each block)
506-
# create one script_pubkey
507-
script_pubkey = "6a4d0200" # OP_RETURN OP_PUSH2 512 bytes
508-
for _ in range(512):
509-
script_pubkey = script_pubkey + "01"
510-
# concatenate 128 txouts of above script_pubkey which we'll insert before the txout for change
511-
txouts = []
512505
from .messages import CTxOut
513-
txout = CTxOut()
514-
txout.nValue = 0
515-
txout.scriptPubKey = bytes.fromhex(script_pubkey)
516-
for _ in range(128):
517-
txouts.append(txout)
506+
from .script import CScript, OP_RETURN
507+
txouts = [CTxOut(nValue=0, scriptPubKey=CScript([OP_RETURN, b'\x01'*67437]))]
508+
assert_equal(sum([len(txout.serialize()) for txout in txouts]), 67456)
518509
return txouts
519510

520511

0 commit comments

Comments
 (0)