v30.3-roots.1 · Commit 3: [PATCH 03/68] feat(policy): preserve Roots relay and network controls on Core 30.3
test/functional/mempool_datacarrier.py
Before: test/functional/mempool_datacarrier.py · After: test/functional/mempool_datacarrier.py
File metadata
index ca113fcbcebbf936bb37bff50f3c479950586e31..ca7265d832c6a05c03bb91661bbb3d6c0b08de3e 100755
Download original patch · Release notes
Diff rows 1–74 of 74. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.
test/functional/mempool_datacarrier.py
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
# Distributed under the MIT software license, see the accompanying
|
|
4
4
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
5
5
|
"""Test datacarrier functionality"""
|
|
6
|
+
from test_framework.blocktools import MAX_STANDARD_TX_WEIGHT
|
|
6
7
|
from test_framework.messages import (
|
|
7
8
|
CTxOut,
|
|
8
|
-
MAX_OP_RETURN_RELAY,
|
|
9
9
|
)
|
|
10
10
|
from test_framework.script import (
|
|
11
11
|
CScript,
|
|
@@ -28,13 +28,13 @@ class DataCarrierTest(BitcoinTestFramework):
|
|
|
28
28
|
def set_test_params(self):
|
|
29
29
|
self.num_nodes = 4
|
|
30
30
|
self.extra_args = [
|
|
31
|
-
[], # default is uncapped
|
|
31
|
+
[], # default aggregate size is 83 bytes
|
|
32
32
|
["-datacarrier=0"], # no relay of datacarrier
|
|
33
33
|
["-datacarrier=1", f"-datacarriersize={CUSTOM_DATACARRIER_ARG}"],
|
|
34
34
|
["-datacarrier=1", "-datacarriersize=2"],
|
|
35
35
|
]
|
|
36
36
|
|
|
37
|
-
def test_null_data_transaction(self, node: TestNode, data, success: bool) -> None:
|
|
37
|
+
def test_null_data_transaction(self, node: TestNode, data, success: bool) -> str:
|
|
38
38
|
tx = self.wallet.create_self_transfer(fee_rate=0)["tx"]
|
|
39
39
|
data = [] if data is None else [data]
|
|
40
40
|
tx.vout.append(CTxOut(nValue=0, scriptPubKey=CScript([OP_RETURN] + data)))
|
|
@@ -47,31 +47,32 @@ class DataCarrierTest(BitcoinTestFramework):
|
|
|
47
47
|
assert tx.txid_hex in node.getrawmempool(True), f'{tx_hex} not in mempool'
|
|
48
48
|
else:
|
|
49
49
|
assert_raises_rpc_error(-26, "datacarrier", self.wallet.sendrawtransaction, from_node=node, tx_hex=tx_hex)
|
|
50
|
+
return tx_hex
|
|
50
51
|
|
|
51
52
|
def run_test(self):
|
|
52
53
|
self.wallet = MiniWallet(self.nodes[0])
|
|
53
54
|
|
|
54
|
-
# Test that bare multisig is allowed by default. Do it here rather than create a new test for it.
|
|
55
|
-
assert_equal(self.nodes[0].getmempoolinfo()["permitbaremultisig"], True)
|
|
55
|
+
# Roots rejects bare multisig by default; report the actual configured policy.
|
|
56
|
+
assert_equal(self.nodes[0].getmempoolinfo()["permitbaremultisig"], False)
|
|
56
57
|
|
|
57
|
-
assert_equal(self.nodes[0].getmempoolinfo()["maxdatacarriersize"], MAX_OP_RETURN_RELAY)
|
|
58
|
+
assert_equal(self.nodes[0].getmempoolinfo()["maxdatacarriersize"], CUSTOM_DATACARRIER_ARG)
|
|
58
59
|
assert_equal(self.nodes[1].getmempoolinfo()["maxdatacarriersize"], 0)
|
|
59
60
|
assert_equal(self.nodes[2].getmempoolinfo()["maxdatacarriersize"], CUSTOM_DATACARRIER_ARG)
|
|
60
61
|
assert_equal(self.nodes[3].getmempoolinfo()["maxdatacarriersize"], 2)
|
|
61
62
|
|
|
62
|
-
# By default, any size is allowed.
|
|
63
63
|
|
|
64
64
|
# If it is custom set to 83, the historical value,
|
|
65
65
|
# only 80 bytes are used for data (+1 for OP_RETURN, +2 for the pushdata opcodes).
|
|
66
66
|
custom_size_data = randbytes(CUSTOM_DATACARRIER_ARG - 3)
|
|
67
67
|
too_long_data = randbytes(CUSTOM_DATACARRIER_ARG - 2)
|
|
68
|
-
extremely_long_data = randbytes(MAX_OP_RETURN_RELAY - 200)
|
|
69
68
|
one_byte = randbytes(1)
|
|
70
69
|
zero_bytes = randbytes(0)
|
|
71
70
|
|
|
72
|
-
self.log.info("Testing a null data transaction succeeds for default arg regardless of size.")
|
|
73
|
-
self.test_null_data_transaction(node=self.nodes[0], data=too_long_data, success=True)
|
|
74
|
-
self.test_null_data_transaction(node=self.nodes[0], data=extremely_long_data, success=True)
|
|
71
|
+
self.log.info("Testing null data with the default 83-byte aggregate limit.")
|
|
72
|
+
self.test_null_data_transaction(node=self.nodes[0], data=custom_size_data, success=True)
|
|
73
|
+
rejected_tx = self.test_null_data_transaction(node=self.nodes[0], data=too_long_data, success=False)
|
|
74
|
+
# Relay limits do not alter block validity.
|
|
75
|
+
self.generateblock(self.nodes[0], output="raw(42)", transactions=[rejected_tx], sync_fun=self.no_op)
|
|
75
76
|
|
|
76
77
|
self.log.info("Testing a null data transaction with -datacarrier=false.")
|
|
77
78
|
self.test_null_data_transaction(node=self.nodes[1], data=custom_size_data, success=False)
|
|
@@ -100,5 +101,9 @@ class DataCarrierTest(BitcoinTestFramework):
|
|
|
100
101
|
self.test_null_data_transaction(node=self.nodes[2], data=one_byte, success=True)
|
|
101
102
|
self.test_null_data_transaction(node=self.nodes[3], data=one_byte, success=False)
|
|
102
103
|
|
|
104
|
+
self.log.info("Testing an explicit large data-carrier limit below the standard transaction weight boundary.")
|
|
105
|
+
self.restart_node(0, extra_args=["-datacarriersize=100000", "-maxscriptsize=100000", "-datacarriercost=1"])
|
|
106
|
+
self.test_null_data_transaction(node=self.nodes[0], data=randbytes(MAX_STANDARD_TX_WEIGHT // 4 - 200), success=True)
|
|
107
|
+
|
|
103
108
|
if __name__ == '__main__':
|
|
104
109
|
DataCarrierTest(__file__).main()
|