v31.1-roots.1 · Commit 2: [PATCH 02/17] feat(policy): preserve Roots parsing and local transaction checks
test/functional/p2p_segwit.py
Before: test/functional/p2p_segwit.py · After: test/functional/p2p_segwit.py
File metadata
index 17f8085b44f067f2fd3f61745e748c0dbb7dcc2a..b2361c0bdfddbcb251ca5a79a152447f6b64fe2a 100755
Download original patch · Release notes
Diff rows 1–68 of 68. 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/p2p_segwit.py
CHANGED
|
@@ -219,8 +219,8 @@ class SegWitTest(BitcoinTestFramework):
|
|
| 219 |
# -par=1 should not affect validation outcome or logging/reported failures. It is kept
|
| 220 |
# here to exercise the code path still (as it is distinct for multithread script
|
| 221 |
# validation).
|
| 222 |
-
["-acceptnonstdtxn=1", f"-testactivationheight=segwit@{SEGWIT_HEIGHT}", "-par=1"],
|
| 223 |
-
["-acceptnonstdtxn=0", f"-testactivationheight=segwit@{SEGWIT_HEIGHT}"],
|
| 224 |
]
|
| 225 |
|
| 226 |
# Helper functions
|
|
@@ -1387,7 +1387,7 @@ class SegWitTest(BitcoinTestFramework):
|
|
| 1387 |
# First we test this transaction against std_node
|
| 1388 |
# making sure the txid is added to the reject filter
|
| 1389 |
self.std_node.announce_tx_and_wait_for_getdata(tx3)
|
| 1390 |
-
test_transaction_acceptance(self.nodes[1], self.std_node, tx3, with_witness=True, accepted=False, reason="bad-txns-nonstandard-inputs")
|
| 1391 |
# Now the node will no longer ask for getdata of this transaction when advertised by same txid
|
| 1392 |
self.std_node.announce_tx_and_wait_for_getdata(tx3, success=False)
|
| 1393 |
|
|
@@ -1742,7 +1742,7 @@ class SegWitTest(BitcoinTestFramework):
|
|
| 1742 |
tx2.wit.vtxinwit[0].scriptWitness.stack = [b'a' * 400]
|
| 1743 |
# This will be rejected due to a policy check:
|
| 1744 |
# No witness is allowed, since it is not a witness program but a p2sh program
|
| 1745 |
-
test_transaction_acceptance(self.nodes[1], self.std_node, tx2, True, False, 'bad-witness-nonstandard')
|
| 1746 |
|
| 1747 |
# If we send without witness, it should be accepted.
|
| 1748 |
test_transaction_acceptance(self.nodes[1], self.std_node, tx2, False, True)
|
|
@@ -1807,13 +1807,13 @@ class SegWitTest(BitcoinTestFramework):
|
|
| 1807 |
# Testing native P2WSH
|
| 1808 |
# Witness stack size, excluding witnessScript, over 100 is non-standard
|
| 1809 |
p2wsh_txs[0].wit.vtxinwit[0].scriptWitness.stack = [pad] * 101 + [scripts[0]]
|
| 1810 |
-
test_transaction_acceptance(self.nodes[1], self.std_node, p2wsh_txs[0], True, False, 'bad-witness-nonstandard')
|
| 1811 |
# Non-standard nodes should accept
|
| 1812 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2wsh_txs[0], True, True)
|
| 1813 |
|
| 1814 |
# Stack element size over 80 bytes is non-standard
|
| 1815 |
p2wsh_txs[1].wit.vtxinwit[0].scriptWitness.stack = [pad * 81] * 100 + [scripts[1]]
|
| 1816 |
-
test_transaction_acceptance(self.nodes[1], self.std_node, p2wsh_txs[1], True, False, 'bad-witness-nonstandard')
|
| 1817 |
# Non-standard nodes should accept
|
| 1818 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2wsh_txs[1], True, True)
|
| 1819 |
# Standard nodes should accept if element size is not over 80 bytes
|
|
@@ -1827,16 +1827,16 @@ class SegWitTest(BitcoinTestFramework):
|
|
| 1827 |
|
| 1828 |
# witnessScript size at 3601 bytes is non-standard
|
| 1829 |
p2wsh_txs[3].wit.vtxinwit[0].scriptWitness.stack = [pad, pad, pad, scripts[3]]
|
| 1830 |
-
test_transaction_acceptance(self.nodes[1], self.std_node, p2wsh_txs[3], True, False, 'bad-witness-nonstandard')
|
| 1831 |
# Non-standard nodes should accept
|
| 1832 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2wsh_txs[3], True, True)
|
| 1833 |
|
| 1834 |
# Repeating the same tests with P2SH-P2WSH
|
| 1835 |
p2sh_txs[0].wit.vtxinwit[0].scriptWitness.stack = [pad] * 101 + [scripts[0]]
|
| 1836 |
-
test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[0], True, False, 'bad-witness-nonstandard')
|
| 1837 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[0], True, True)
|
| 1838 |
p2sh_txs[1].wit.vtxinwit[0].scriptWitness.stack = [pad * 81] * 100 + [scripts[1]]
|
| 1839 |
-
test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[1], True, False, 'bad-witness-nonstandard')
|
| 1840 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[1], True, True)
|
| 1841 |
p2sh_txs[1].wit.vtxinwit[0].scriptWitness.stack = [pad * 80] * 100 + [scripts[1]]
|
| 1842 |
test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[1], True, True)
|
|
@@ -1844,7 +1844,7 @@ class SegWitTest(BitcoinTestFramework):
|
|
| 1844 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[2], True, True)
|
| 1845 |
test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[2], True, True)
|
| 1846 |
p2sh_txs[3].wit.vtxinwit[0].scriptWitness.stack = [pad, pad, pad, scripts[3]]
|
| 1847 |
-
test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[3], True, False, 'bad-witness-nonstandard')
|
| 1848 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[3], True, True)
|
| 1849 |
|
| 1850 |
self.generate(self.nodes[0], 1) # Mine and clean up the mempool of non-standard node
|
|
|
|
| 219 |
# -par=1 should not affect validation outcome or logging/reported failures. It is kept
|
| 220 |
# here to exercise the code path still (as it is distinct for multithread script
|
| 221 |
# validation).
|
| 222 |
+
["-acceptnonstdtxn=1", "-acceptnonstddatacarrier=1", "-datacarriersize=100000", "-maxscriptsize=100000", f"-testactivationheight=segwit@{SEGWIT_HEIGHT}", "-par=1"],
|
| 223 |
+
["-acceptnonstdtxn=0", "-acceptnonstddatacarrier=1", "-datacarriersize=100000", "-maxscriptsize=100000", f"-testactivationheight=segwit@{SEGWIT_HEIGHT}"],
|
| 224 |
]
|
| 225 |
|
| 226 |
# Helper functions
|
|
|
|
| 1387 |
# First we test this transaction against std_node
|
| 1388 |
# making sure the txid is added to the reject filter
|
| 1389 |
self.std_node.announce_tx_and_wait_for_getdata(tx3)
|
| 1390 |
+
test_transaction_acceptance(self.nodes[1], self.std_node, tx3, with_witness=True, accepted=False, reason="bad-txns-input-witness-unknown")
|
| 1391 |
# Now the node will no longer ask for getdata of this transaction when advertised by same txid
|
| 1392 |
self.std_node.announce_tx_and_wait_for_getdata(tx3, success=False)
|
| 1393 |
|
|
|
|
| 1742 |
tx2.wit.vtxinwit[0].scriptWitness.stack = [b'a' * 400]
|
| 1743 |
# This will be rejected due to a policy check:
|
| 1744 |
# No witness is allowed, since it is not a witness program but a p2sh program
|
| 1745 |
+
test_transaction_acceptance(self.nodes[1], self.std_node, tx2, True, False, 'bad-witness-nonwitness-input')
|
| 1746 |
|
| 1747 |
# If we send without witness, it should be accepted.
|
| 1748 |
test_transaction_acceptance(self.nodes[1], self.std_node, tx2, False, True)
|
|
|
|
| 1807 |
# Testing native P2WSH
|
| 1808 |
# Witness stack size, excluding witnessScript, over 100 is non-standard
|
| 1809 |
p2wsh_txs[0].wit.vtxinwit[0].scriptWitness.stack = [pad] * 101 + [scripts[0]]
|
| 1810 |
+
test_transaction_acceptance(self.nodes[1], self.std_node, p2wsh_txs[0], True, False, 'bad-witness-stackitem-count')
|
| 1811 |
# Non-standard nodes should accept
|
| 1812 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2wsh_txs[0], True, True)
|
| 1813 |
|
| 1814 |
# Stack element size over 80 bytes is non-standard
|
| 1815 |
p2wsh_txs[1].wit.vtxinwit[0].scriptWitness.stack = [pad * 81] * 100 + [scripts[1]]
|
| 1816 |
+
test_transaction_acceptance(self.nodes[1], self.std_node, p2wsh_txs[1], True, False, 'bad-witness-stackitem-size')
|
| 1817 |
# Non-standard nodes should accept
|
| 1818 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2wsh_txs[1], True, True)
|
| 1819 |
# Standard nodes should accept if element size is not over 80 bytes
|
|
|
|
| 1827 |
|
| 1828 |
# witnessScript size at 3601 bytes is non-standard
|
| 1829 |
p2wsh_txs[3].wit.vtxinwit[0].scriptWitness.stack = [pad, pad, pad, scripts[3]]
|
| 1830 |
+
test_transaction_acceptance(self.nodes[1], self.std_node, p2wsh_txs[3], True, False, 'bad-witness-script-size')
|
| 1831 |
# Non-standard nodes should accept
|
| 1832 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2wsh_txs[3], True, True)
|
| 1833 |
|
| 1834 |
# Repeating the same tests with P2SH-P2WSH
|
| 1835 |
p2sh_txs[0].wit.vtxinwit[0].scriptWitness.stack = [pad] * 101 + [scripts[0]]
|
| 1836 |
+
test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[0], True, False, 'bad-witness-stackitem-count')
|
| 1837 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[0], True, True)
|
| 1838 |
p2sh_txs[1].wit.vtxinwit[0].scriptWitness.stack = [pad * 81] * 100 + [scripts[1]]
|
| 1839 |
+
test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[1], True, False, 'bad-witness-stackitem-size')
|
| 1840 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[1], True, True)
|
| 1841 |
p2sh_txs[1].wit.vtxinwit[0].scriptWitness.stack = [pad * 80] * 100 + [scripts[1]]
|
| 1842 |
test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[1], True, True)
|
|
|
|
| 1844 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[2], True, True)
|
| 1845 |
test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[2], True, True)
|
| 1846 |
p2sh_txs[3].wit.vtxinwit[0].scriptWitness.stack = [pad, pad, pad, scripts[3]]
|
| 1847 |
+
test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[3], True, False, 'bad-witness-script-size')
|
| 1848 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[3], True, True)
|
| 1849 |
|
| 1850 |
self.generate(self.nodes[0], 1) # Mine and clean up the mempool of non-standard node
|