mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
Merge bitcoin/bitcoin#25503: test: pass datacarriersize
option for tests using large outputs (instead of acceptnonstdtxn
)
475aae846e
test: pass `datacarriersize` option for tests using large outputs (instead of `acceptnonstdtxn`) (Sebastian Falbesoner)b1ba3ed155
test: let `gen_return_txouts` create a single large OP_RETURN output (Sebastian Falbesoner)f319287d81
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](749b80b29e/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
This commit is contained in:
commit
1ee597817f
4 changed files with 8 additions and 17 deletions
|
@ -46,7 +46,7 @@ class MaxUploadTest(BitcoinTestFramework):
|
|||
self.num_nodes = 1
|
||||
self.extra_args = [[
|
||||
"-maxuploadtarget=800M",
|
||||
"-acceptnonstdtxn=1",
|
||||
"-datacarriersize=100000",
|
||||
]]
|
||||
self.supports_cli = False
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ class MempoolLimitTest(BitcoinTestFramework):
|
|||
self.setup_clean_chain = True
|
||||
self.num_nodes = 1
|
||||
self.extra_args = [[
|
||||
"-acceptnonstdtxn=1",
|
||||
"-datacarriersize=100000",
|
||||
"-maxmempool=5",
|
||||
"-spendzeroconfchange=0",
|
||||
]]
|
||||
|
|
|
@ -26,7 +26,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
|
|||
self.num_nodes = 1
|
||||
self.extra_args = [[
|
||||
"-printpriority=1",
|
||||
"-acceptnonstdtxn=1",
|
||||
"-datacarriersize=100000",
|
||||
]] * self.num_nodes
|
||||
self.supports_cli = False
|
||||
|
||||
|
|
|
@ -499,22 +499,13 @@ def chain_transaction(node, parent_txids, vouts, value, fee, num_outputs):
|
|||
|
||||
|
||||
# Create large OP_RETURN txouts that can be appended to a transaction
|
||||
# to make it large (helper for constructing large transactions).
|
||||
# to make it large (helper for constructing large transactions). The
|
||||
# total serialized size of the txouts is about 66k vbytes.
|
||||
def gen_return_txouts():
|
||||
# Some pre-processing to create a bunch of OP_RETURN txouts to insert into transactions we create
|
||||
# So we have big transactions (and therefore can't fit very many into each block)
|
||||
# create one script_pubkey
|
||||
script_pubkey = "6a4d0200" # OP_RETURN OP_PUSH2 512 bytes
|
||||
for _ in range(512):
|
||||
script_pubkey = script_pubkey + "01"
|
||||
# concatenate 128 txouts of above script_pubkey which we'll insert before the txout for change
|
||||
txouts = []
|
||||
from .messages import CTxOut
|
||||
txout = CTxOut()
|
||||
txout.nValue = 0
|
||||
txout.scriptPubKey = bytes.fromhex(script_pubkey)
|
||||
for _ in range(128):
|
||||
txouts.append(txout)
|
||||
from .script import CScript, OP_RETURN
|
||||
txouts = [CTxOut(nValue=0, scriptPubKey=CScript([OP_RETURN, b'\x01'*67437]))]
|
||||
assert_equal(sum([len(txout.serialize()) for txout in txouts]), 67456)
|
||||
return txouts
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue