v30.3-roots.1 · Commit 7: [PATCH 07/68] build: adapt Roots maintenance and assurance to Core 30.3
test/functional/mempool_datacarrier.py
Before: test/functional/mempool_datacarrier.py · After: test/functional/mempool_datacarrier.py
File metadata
index ca7265d832c6a05c03bb91661bbb3d6c0b08de3e..649aad4a291a4dd737fb504db7eec6caeb90be1d 100755
Download original patch · Release notes
Diff rows 1–38 of 38. 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,6 +3,8 @@
|
|
|
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 random import randbytes
|
|
7
|
+
|
|
6
8
|
from test_framework.blocktools import MAX_STANDARD_TX_WEIGHT
|
|
7
9
|
from test_framework.messages import (
|
|
8
10
|
CTxOut,
|
|
@@ -19,7 +21,6 @@ from test_framework.util import (
|
|
|
19
21
|
)
|
|
20
22
|
from test_framework.wallet import MiniWallet
|
|
21
23
|
|
|
22
|
-
from random import randbytes
|
|
23
24
|
|
|
24
25
|
# The historical maximum, now used to test coverage
|
|
25
26
|
CUSTOM_DATACARRIER_ARG = 83
|
|
@@ -105,5 +106,23 @@ class DataCarrierTest(BitcoinTestFramework):
|
|
|
105
106
|
self.restart_node(0, extra_args=["-datacarriersize=100000", "-maxscriptsize=100000", "-datacarriercost=1"])
|
|
106
107
|
self.test_null_data_transaction(node=self.nodes[0], data=randbytes(MAX_STANDARD_TX_WEIGHT // 4 - 200), success=True)
|
|
107
108
|
|
|
109
|
+
self.log.info("Testing the maximum carrier-cost setting without overflowing virtual size.")
|
|
110
|
+
self.restart_node(0, extra_args=["-datacarriercost=1073741823.75"])
|
|
111
|
+
tx = self.wallet.create_self_transfer(fee_rate=0)["tx"]
|
|
112
|
+
tx.vout.append(CTxOut(0, CScript([OP_RETURN, b"x" * 80])))
|
|
113
|
+
tx.vout[0].nValue -= tx.get_vsize()
|
|
114
|
+
tx_hex = tx.serialize().hex()
|
|
115
|
+
result = self.nodes[0].testmempoolaccept([tx_hex])[0]
|
|
116
|
+
assert_equal(result["allowed"], False)
|
|
117
|
+
assert_equal(result["reject-reason"], "min relay fee not met")
|
|
118
|
+
# An extreme local fee policy still cannot invalidate a valid block.
|
|
119
|
+
self.generateblock(self.nodes[0], output="raw(42)", transactions=[tx_hex], sync_fun=self.no_op)
|
|
120
|
+
|
|
121
|
+
self.stop_node(0)
|
|
122
|
+
for cost in ["-1", "1073741823.76", "1e999", "invalid"]:
|
|
123
|
+
self.nodes[0].assert_start_raises_init_error(
|
|
124
|
+
[f"-datacarriercost={cost}"], f"Error: Invalid -datacarriercost value: '{cost}'")
|
|
125
|
+
self.start_node(0)
|
|
126
|
+
|
|
108
127
|
if __name__ == '__main__':
|
|
109
128
|
DataCarrierTest(__file__).main()
|