v30.3-roots.1 · Commit 8: [PATCH 08/68] ci: restore Roots assurance on Core 30.3 interfaces
test/functional/p2p_segwit.py
Before: test/functional/p2p_segwit.py · After: test/functional/p2p_segwit.py
File metadata
index 8a61eaf3be14b89950576ba990d00cfc67472d69..eee34a5fe11f391a78b9ceb84215f156b55c08df 100755
Download original patch · Release notes
Diff rows 1–84 of 84. 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
|
@@ -215,11 +215,24 @@ class SegWitTest(BitcoinTestFramework):
|
|
| 215 |
self.noban_tx_relay = True
|
| 216 |
# This test tests SegWit both pre and post-activation, so use the normal BIP9 activation.
|
| 217 |
self.extra_args = [
|
|
|
|
|
|
|
| 218 |
# -par=1 should not affect validation outcome or logging/reported failures. It is kept
|
| 219 |
# here to exercise the code path still (as it is distinct for multithread script
|
| 220 |
# validation).
|
| 221 |
-
["-acceptnonstdtxn=1", f"-testactivationheight=segwit@{SEGWIT_HEIGHT}", "-par=1"],
|
| 222 |
-
["-acceptnonstdtxn=0", f"-testactivationheight=segwit@{SEGWIT_HEIGHT}"],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 223 |
]
|
| 224 |
|
| 225 |
# Helper functions
|
|
@@ -1357,7 +1370,7 @@ class SegWitTest(BitcoinTestFramework):
|
|
| 1357 |
# First we test this transaction against std_node
|
| 1358 |
# making sure the txid is added to the reject filter
|
| 1359 |
self.std_node.announce_tx_and_wait_for_getdata(tx3)
|
| 1360 |
-
test_transaction_acceptance(self.nodes[1], self.std_node, tx3, with_witness=True, accepted=False, reason="bad-txns-nonstandard-inputs")
|
| 1361 |
# Now the node will no longer ask for getdata of this transaction when advertised by same txid
|
| 1362 |
self.std_node.announce_tx_and_wait_for_getdata(tx3, success=False)
|
| 1363 |
|
|
@@ -1712,7 +1725,7 @@ class SegWitTest(BitcoinTestFramework):
|
|
| 1712 |
tx2.wit.vtxinwit[0].scriptWitness.stack = [b'a' * 400]
|
| 1713 |
# This will be rejected due to a policy check:
|
| 1714 |
# No witness is allowed, since it is not a witness program but a p2sh program
|
| 1715 |
-
test_transaction_acceptance(self.nodes[1], self.std_node, tx2, True, False, 'bad-witness-nonstandard')
|
| 1716 |
|
| 1717 |
# If we send without witness, it should be accepted.
|
| 1718 |
test_transaction_acceptance(self.nodes[1], self.std_node, tx2, False, True)
|
|
@@ -1777,13 +1790,13 @@ class SegWitTest(BitcoinTestFramework):
|
|
| 1777 |
# Testing native P2WSH
|
| 1778 |
# Witness stack size, excluding witnessScript, over 100 is non-standard
|
| 1779 |
p2wsh_txs[0].wit.vtxinwit[0].scriptWitness.stack = [pad] * 101 + [scripts[0]]
|
| 1780 |
-
test_transaction_acceptance(self.nodes[1], self.std_node, p2wsh_txs[0], True, False, 'bad-witness-nonstandard')
|
| 1781 |
# Non-standard nodes should accept
|
| 1782 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2wsh_txs[0], True, True)
|
| 1783 |
|
| 1784 |
# Stack element size over 80 bytes is non-standard
|
| 1785 |
p2wsh_txs[1].wit.vtxinwit[0].scriptWitness.stack = [pad * 81] * 100 + [scripts[1]]
|
| 1786 |
-
test_transaction_acceptance(self.nodes[1], self.std_node, p2wsh_txs[1], True, False, 'bad-witness-nonstandard')
|
| 1787 |
# Non-standard nodes should accept
|
| 1788 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2wsh_txs[1], True, True)
|
| 1789 |
# Standard nodes should accept if element size is not over 80 bytes
|
|
@@ -1797,16 +1810,16 @@ class SegWitTest(BitcoinTestFramework):
|
|
| 1797 |
|
| 1798 |
# witnessScript size at 3601 bytes is non-standard
|
| 1799 |
p2wsh_txs[3].wit.vtxinwit[0].scriptWitness.stack = [pad, pad, pad, scripts[3]]
|
| 1800 |
-
test_transaction_acceptance(self.nodes[1], self.std_node, p2wsh_txs[3], True, False, 'bad-witness-nonstandard')
|
| 1801 |
# Non-standard nodes should accept
|
| 1802 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2wsh_txs[3], True, True)
|
| 1803 |
|
| 1804 |
# Repeating the same tests with P2SH-P2WSH
|
| 1805 |
p2sh_txs[0].wit.vtxinwit[0].scriptWitness.stack = [pad] * 101 + [scripts[0]]
|
| 1806 |
-
test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[0], True, False, 'bad-witness-nonstandard')
|
| 1807 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[0], True, True)
|
| 1808 |
p2sh_txs[1].wit.vtxinwit[0].scriptWitness.stack = [pad * 81] * 100 + [scripts[1]]
|
| 1809 |
-
test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[1], True, False, 'bad-witness-nonstandard')
|
| 1810 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[1], True, True)
|
| 1811 |
p2sh_txs[1].wit.vtxinwit[0].scriptWitness.stack = [pad * 80] * 100 + [scripts[1]]
|
| 1812 |
test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[1], True, True)
|
|
@@ -1814,7 +1827,7 @@ class SegWitTest(BitcoinTestFramework):
|
|
| 1814 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[2], True, True)
|
| 1815 |
test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[2], True, True)
|
| 1816 |
p2sh_txs[3].wit.vtxinwit[0].scriptWitness.stack = [pad, pad, pad, scripts[3]]
|
| 1817 |
-
test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[3], True, False, 'bad-witness-nonstandard')
|
| 1818 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[3], True, True)
|
| 1819 |
|
| 1820 |
self.generate(self.nodes[0], 1) # Mine and clean up the mempool of non-standard node
|
|
|
|
| 215 |
self.noban_tx_relay = True
|
| 216 |
# This test tests SegWit both pre and post-activation, so use the normal BIP9 activation.
|
| 217 |
self.extra_args = [
|
| 218 |
+
# Keep Roots' independent data-carrier and script-size policies from masking the
|
| 219 |
+
# SegWit standardness limits exercised by this test.
|
| 220 |
# -par=1 should not affect validation outcome or logging/reported failures. It is kept
|
| 221 |
# here to exercise the code path still (as it is distinct for multithread script
|
| 222 |
# validation).
|
| 223 |
+
[
|
| 224 |
+
"-acceptnonstdtxn=1",
|
| 225 |
+
"-acceptnonstddatacarrier=1",
|
| 226 |
+
f"-testactivationheight=segwit@{SEGWIT_HEIGHT}",
|
| 227 |
+
"-maxscriptsize=100000",
|
| 228 |
+
"-par=1",
|
| 229 |
+
],
|
| 230 |
+
[
|
| 231 |
+
"-acceptnonstdtxn=0",
|
| 232 |
+
"-acceptnonstddatacarrier=1",
|
| 233 |
+
f"-testactivationheight=segwit@{SEGWIT_HEIGHT}",
|
| 234 |
+
"-maxscriptsize=100000",
|
| 235 |
+
],
|
| 236 |
]
|
| 237 |
|
| 238 |
# Helper functions
|
|
|
|
| 1370 |
# First we test this transaction against std_node
|
| 1371 |
# making sure the txid is added to the reject filter
|
| 1372 |
self.std_node.announce_tx_and_wait_for_getdata(tx3)
|
| 1373 |
+
test_transaction_acceptance(self.nodes[1], self.std_node, tx3, with_witness=True, accepted=False, reason="bad-txns-input-witness-unknown")
|
| 1374 |
# Now the node will no longer ask for getdata of this transaction when advertised by same txid
|
| 1375 |
self.std_node.announce_tx_and_wait_for_getdata(tx3, success=False)
|
| 1376 |
|
|
|
|
| 1725 |
tx2.wit.vtxinwit[0].scriptWitness.stack = [b'a' * 400]
|
| 1726 |
# This will be rejected due to a policy check:
|
| 1727 |
# No witness is allowed, since it is not a witness program but a p2sh program
|
| 1728 |
+
test_transaction_acceptance(self.nodes[1], self.std_node, tx2, True, False, 'bad-witness-nonwitness-input')
|
| 1729 |
|
| 1730 |
# If we send without witness, it should be accepted.
|
| 1731 |
test_transaction_acceptance(self.nodes[1], self.std_node, tx2, False, True)
|
|
|
|
| 1790 |
# Testing native P2WSH
|
| 1791 |
# Witness stack size, excluding witnessScript, over 100 is non-standard
|
| 1792 |
p2wsh_txs[0].wit.vtxinwit[0].scriptWitness.stack = [pad] * 101 + [scripts[0]]
|
| 1793 |
+
test_transaction_acceptance(self.nodes[1], self.std_node, p2wsh_txs[0], True, False, 'bad-witness-stackitem-count')
|
| 1794 |
# Non-standard nodes should accept
|
| 1795 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2wsh_txs[0], True, True)
|
| 1796 |
|
| 1797 |
# Stack element size over 80 bytes is non-standard
|
| 1798 |
p2wsh_txs[1].wit.vtxinwit[0].scriptWitness.stack = [pad * 81] * 100 + [scripts[1]]
|
| 1799 |
+
test_transaction_acceptance(self.nodes[1], self.std_node, p2wsh_txs[1], True, False, 'bad-witness-stackitem-size')
|
| 1800 |
# Non-standard nodes should accept
|
| 1801 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2wsh_txs[1], True, True)
|
| 1802 |
# Standard nodes should accept if element size is not over 80 bytes
|
|
|
|
| 1810 |
|
| 1811 |
# witnessScript size at 3601 bytes is non-standard
|
| 1812 |
p2wsh_txs[3].wit.vtxinwit[0].scriptWitness.stack = [pad, pad, pad, scripts[3]]
|
| 1813 |
+
test_transaction_acceptance(self.nodes[1], self.std_node, p2wsh_txs[3], True, False, 'bad-witness-script-size')
|
| 1814 |
# Non-standard nodes should accept
|
| 1815 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2wsh_txs[3], True, True)
|
| 1816 |
|
| 1817 |
# Repeating the same tests with P2SH-P2WSH
|
| 1818 |
p2sh_txs[0].wit.vtxinwit[0].scriptWitness.stack = [pad] * 101 + [scripts[0]]
|
| 1819 |
+
test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[0], True, False, 'bad-witness-stackitem-count')
|
| 1820 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[0], True, True)
|
| 1821 |
p2sh_txs[1].wit.vtxinwit[0].scriptWitness.stack = [pad * 81] * 100 + [scripts[1]]
|
| 1822 |
+
test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[1], True, False, 'bad-witness-stackitem-size')
|
| 1823 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[1], True, True)
|
| 1824 |
p2sh_txs[1].wit.vtxinwit[0].scriptWitness.stack = [pad * 80] * 100 + [scripts[1]]
|
| 1825 |
test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[1], True, True)
|
|
|
|
| 1827 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[2], True, True)
|
| 1828 |
test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[2], True, True)
|
| 1829 |
p2sh_txs[3].wit.vtxinwit[0].scriptWitness.stack = [pad, pad, pad, scripts[3]]
|
| 1830 |
+
test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[3], True, False, 'bad-witness-script-size')
|
| 1831 |
test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[3], True, True)
|
| 1832 |
|
| 1833 |
self.generate(self.nodes[0], 1) # Mine and clean up the mempool of non-standard node
|