v30.3-roots.1 · Commit 10: [PATCH 10/68] fix: harden Roots priority and wallet policy boundaries
test/functional/mempool_accept.py
Before: test/functional/mempool_accept.py · After: test/functional/mempool_accept.py
File metadata
index 7dbd7ba1e2ede54ae9c7cef2eeb6ed928a0072dc..54bf8fd447ad8b93d227619874a1bbd2e7c6fbf2 100755
Download original patch · Release notes
Diff rows 1–59 of 59. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.
test/functional/mempool_accept.py
CHANGED
|
@@ -60,7 +60,8 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
|
| 60 |
def set_test_params(self):
|
| 61 |
self.num_nodes = 1
|
| 62 |
self.extra_args = [[
|
| 63 |
-
'-txindex','-permitbaremultisig=0',
|
|
|
|
| 64 |
]] * self.num_nodes
|
| 65 |
self.supports_cli = False
|
| 66 |
|
|
@@ -78,6 +79,18 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
|
| 78 |
assert_equal(result_expected, result_test)
|
| 79 |
assert_equal(self.nodes[0].getmempoolinfo()['size'], self.mempool_size) # Must not change mempool state
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
def run_test(self):
|
| 82 |
node = self.nodes[0]
|
| 83 |
self.wallet = MiniWallet(node)
|
|
@@ -335,7 +348,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
|
| 335 |
tx.vout[0] = output_p2sh_burn
|
| 336 |
tx.vout[0].nValue -= 1 # Make output smaller, such that it is dust for our policy
|
| 337 |
self.check_mempool_result(
|
| 338 |
-
result_expected=[{'txid': tx.txid_hex, 'allowed': False, 'reject-reason': 'dust'}],
|
| 339 |
rawtxs=[tx.serialize().hex()],
|
| 340 |
)
|
| 341 |
|
|
@@ -353,7 +366,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
|
| 353 |
tx.vout.append(CTxOut(0, CScript([OP_RETURN, b'\xff'])))
|
| 354 |
tx.vout.append(CTxOut(0, CScript([OP_RETURN, b'\xff' * 50000])))
|
| 355 |
|
| 356 |
-
self.check_mempool_result(
|
| 357 |
result_expected=[{'txid': tx.txid_hex, 'allowed': True, 'vsize': tx.get_vsize(), 'fees': {'base': Decimal('0.05')}}],
|
| 358 |
rawtxs=[tx.serialize().hex()],
|
| 359 |
maxfeerate=0
|
|
@@ -365,7 +378,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
|
| 365 |
tx.vout[0].nValue = int(tx.vout[0].nValue / op_return_count)
|
| 366 |
tx.vout[0].scriptPubKey = CScript([OP_RETURN, b'\xff'])
|
| 367 |
tx.vout = [tx.vout[0]] * op_return_count
|
| 368 |
-
self.check_mempool_result(
|
| 369 |
result_expected=[{"txid": tx.txid_hex, "allowed": True, "vsize": tx.get_vsize(), "fees": {"base": Decimal("0.05000026")}}],
|
| 370 |
rawtxs=[tx.serialize().hex()],
|
| 371 |
)
|
|
@@ -448,7 +461,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
|
| 448 |
anchor_nonempty_wit_spend.wit.vtxinwit[0].scriptWitness.stack.append(b"f")
|
| 449 |
|
| 450 |
self.check_mempool_result(
|
| 451 |
-
result_expected=[{'txid': anchor_nonempty_wit_spend.txid_hex, 'allowed': False, 'reject-reason': 'bad-witness-nonstandard'}],
|
| 452 |
rawtxs=[anchor_nonempty_wit_spend.serialize().hex()],
|
| 453 |
maxfeerate=0,
|
| 454 |
)
|
|
|
|
| 60 |
def set_test_params(self):
|
| 61 |
self.num_nodes = 1
|
| 62 |
self.extra_args = [[
|
| 63 |
+
'-txindex', '-permitbaredatacarrier=1', '-permitbaremultisig=0',
|
| 64 |
+
'-datacarriersize=100000', '-maxscriptsize=100000',
|
| 65 |
]] * self.num_nodes
|
| 66 |
self.supports_cli = False
|
| 67 |
|
|
|
|
| 79 |
assert_equal(result_expected, result_test)
|
| 80 |
assert_equal(self.nodes[0].getmempoolinfo()['size'], self.mempool_size) # Must not change mempool state
|
| 81 |
|
| 82 |
+
def check_multi_op_return_result(self, result_expected, **kwargs):
|
| 83 |
+
# Roots deliberately rejects multiple OP_RETURN outputs as standard
|
| 84 |
+
# policy. Preserve Core's acceptance cases with the explicit regtest
|
| 85 |
+
# nonstandard override, and check both observable policy contracts.
|
| 86 |
+
self.check_mempool_result(
|
| 87 |
+
result_expected=[{'txid': result_expected[0]['txid'], 'allowed': False, 'reject-reason': 'multi-op-return'}],
|
| 88 |
+
**kwargs,
|
| 89 |
+
)
|
| 90 |
+
self.restart_node(0, extra_args=self.extra_args[0] + ['-acceptnonstdtxn=1'])
|
| 91 |
+
self.check_mempool_result(result_expected=result_expected, **kwargs)
|
| 92 |
+
self.restart_node(0)
|
| 93 |
+
|
| 94 |
def run_test(self):
|
| 95 |
node = self.nodes[0]
|
| 96 |
self.wallet = MiniWallet(node)
|
|
|
|
| 348 |
tx.vout[0] = output_p2sh_burn
|
| 349 |
tx.vout[0].nValue -= 1 # Make output smaller, such that it is dust for our policy
|
| 350 |
self.check_mempool_result(
|
| 351 |
+
result_expected=[{'txid': tx.txid_hex, 'allowed': False, 'reject-reason': 'dust-nonanchor'}],
|
| 352 |
rawtxs=[tx.serialize().hex()],
|
| 353 |
)
|
| 354 |
|
|
|
|
| 366 |
tx.vout.append(CTxOut(0, CScript([OP_RETURN, b'\xff'])))
|
| 367 |
tx.vout.append(CTxOut(0, CScript([OP_RETURN, b'\xff' * 50000])))
|
| 368 |
|
| 369 |
+
self.check_multi_op_return_result(
|
| 370 |
result_expected=[{'txid': tx.txid_hex, 'allowed': True, 'vsize': tx.get_vsize(), 'fees': {'base': Decimal('0.05')}}],
|
| 371 |
rawtxs=[tx.serialize().hex()],
|
| 372 |
maxfeerate=0
|
|
|
|
| 378 |
tx.vout[0].nValue = int(tx.vout[0].nValue / op_return_count)
|
| 379 |
tx.vout[0].scriptPubKey = CScript([OP_RETURN, b'\xff'])
|
| 380 |
tx.vout = [tx.vout[0]] * op_return_count
|
| 381 |
+
self.check_multi_op_return_result(
|
| 382 |
result_expected=[{"txid": tx.txid_hex, "allowed": True, "vsize": tx.get_vsize(), "fees": {"base": Decimal("0.05000026")}}],
|
| 383 |
rawtxs=[tx.serialize().hex()],
|
| 384 |
)
|
|
|
|
| 461 |
anchor_nonempty_wit_spend.wit.vtxinwit[0].scriptWitness.stack.append(b"f")
|
| 462 |
|
| 463 |
self.check_mempool_result(
|
| 464 |
+
result_expected=[{'txid': anchor_nonempty_wit_spend.txid_hex, 'allowed': False, 'reject-reason': 'bad-witness-anchor-not-empty'}],
|
| 465 |
rawtxs=[anchor_nonempty_wit_spend.serialize().hex()],
|
| 466 |
maxfeerate=0,
|
| 467 |
)
|