Skip to content
Bitcoin Roots

v29.4-roots.2 · Commit 8: [PATCH 08/21] ci: restore assurance and isolate Core fixtures

test/functional/p2p_segwit.py

Before: test/functional/p2p_segwit.py · After: test/functional/p2p_segwit.py

File metadata
index 7815d6ea84ecf8b44bcbacf6bde598a7f839bc52..33220956213a2bfd31e8ee76627ea36f492f286c 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
@@ -214,11 +214,24 @@ class SegWitTest(BitcoinTestFramework):
214
  self.noban_tx_relay = True
215
  # This test tests SegWit both pre and post-activation, so use the normal BIP9 activation.
216
  self.extra_args = [
 
 
217
  # -par=1 should not affect validation outcome or logging/reported failures. It is kept
218
  # here to exercise the code path still (as it is distinct for multithread script
219
  # validation).
220
- ["-acceptnonstdtxn=1", f"-testactivationheight=segwit@{SEGWIT_HEIGHT}", "-par=1"],
221
- ["-acceptnonstdtxn=0", f"-testactivationheight=segwit@{SEGWIT_HEIGHT}"],
 
 
 
 
 
 
 
 
 
 
 
222
  ]
223
  self.supports_cli = False
224
 
@@ -1398,7 +1411,7 @@ class SegWitTest(BitcoinTestFramework):
1398
  # First we test this transaction against std_node
1399
  # making sure the txid is added to the reject filter
1400
  self.std_node.announce_tx_and_wait_for_getdata(tx3)
1401
- test_transaction_acceptance(self.nodes[1], self.std_node, tx3, with_witness=True, accepted=False, reason="bad-txns-nonstandard-inputs")
1402
  # Now the node will no longer ask for getdata of this transaction when advertised by same txid
1403
  self.std_node.announce_tx_and_wait_for_getdata(tx3, success=False)
1404
 
@@ -1761,7 +1774,7 @@ class SegWitTest(BitcoinTestFramework):
1761
  tx2.rehash()
1762
  # This will be rejected due to a policy check:
1763
  # No witness is allowed, since it is not a witness program but a p2sh program
1764
- test_transaction_acceptance(self.nodes[1], self.std_node, tx2, True, False, 'bad-witness-nonstandard')
1765
 
1766
  # If we send without witness, it should be accepted.
1767
  test_transaction_acceptance(self.nodes[1], self.std_node, tx2, False, True)
@@ -1830,13 +1843,13 @@ class SegWitTest(BitcoinTestFramework):
1830
  # Testing native P2WSH
1831
  # Witness stack size, excluding witnessScript, over 100 is non-standard
1832
  p2wsh_txs[0].wit.vtxinwit[0].scriptWitness.stack = [pad] * 101 + [scripts[0]]
1833
- test_transaction_acceptance(self.nodes[1], self.std_node, p2wsh_txs[0], True, False, 'bad-witness-nonstandard')
1834
  # Non-standard nodes should accept
1835
  test_transaction_acceptance(self.nodes[0], self.test_node, p2wsh_txs[0], True, True)
1836
 
1837
  # Stack element size over 80 bytes is non-standard
1838
  p2wsh_txs[1].wit.vtxinwit[0].scriptWitness.stack = [pad * 81] * 100 + [scripts[1]]
1839
- test_transaction_acceptance(self.nodes[1], self.std_node, p2wsh_txs[1], True, False, 'bad-witness-nonstandard')
1840
  # Non-standard nodes should accept
1841
  test_transaction_acceptance(self.nodes[0], self.test_node, p2wsh_txs[1], True, True)
1842
  # Standard nodes should accept if element size is not over 80 bytes
@@ -1850,16 +1863,16 @@ class SegWitTest(BitcoinTestFramework):
1850
 
1851
  # witnessScript size at 3601 bytes is non-standard
1852
  p2wsh_txs[3].wit.vtxinwit[0].scriptWitness.stack = [pad, pad, pad, scripts[3]]
1853
- test_transaction_acceptance(self.nodes[1], self.std_node, p2wsh_txs[3], True, False, 'bad-witness-nonstandard')
1854
  # Non-standard nodes should accept
1855
  test_transaction_acceptance(self.nodes[0], self.test_node, p2wsh_txs[3], True, True)
1856
 
1857
  # Repeating the same tests with P2SH-P2WSH
1858
  p2sh_txs[0].wit.vtxinwit[0].scriptWitness.stack = [pad] * 101 + [scripts[0]]
1859
- test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[0], True, False, 'bad-witness-nonstandard')
1860
  test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[0], True, True)
1861
  p2sh_txs[1].wit.vtxinwit[0].scriptWitness.stack = [pad * 81] * 100 + [scripts[1]]
1862
- test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[1], True, False, 'bad-witness-nonstandard')
1863
  test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[1], True, True)
1864
  p2sh_txs[1].wit.vtxinwit[0].scriptWitness.stack = [pad * 80] * 100 + [scripts[1]]
1865
  test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[1], True, True)
@@ -1867,7 +1880,7 @@ class SegWitTest(BitcoinTestFramework):
1867
  test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[2], True, True)
1868
  test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[2], True, True)
1869
  p2sh_txs[3].wit.vtxinwit[0].scriptWitness.stack = [pad, pad, pad, scripts[3]]
1870
- test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[3], True, False, 'bad-witness-nonstandard')
1871
  test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[3], True, True)
1872
 
1873
  self.generate(self.nodes[0], 1) # Mine and clean up the mempool of non-standard node
 
214
  self.noban_tx_relay = True
215
  # This test tests SegWit both pre and post-activation, so use the normal BIP9 activation.
216
  self.extra_args = [
217
+ # Keep Roots' independent data-carrier and script-size policies from masking the
218
+ # SegWit standardness limits exercised by this test.
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
+ [
223
+ "-acceptnonstdtxn=1",
224
+ "-acceptnonstddatacarrier=1",
225
+ f"-testactivationheight=segwit@{SEGWIT_HEIGHT}",
226
+ "-maxscriptsize=100000",
227
+ "-par=1",
228
+ ],
229
+ [
230
+ "-acceptnonstdtxn=0",
231
+ "-acceptnonstddatacarrier=1",
232
+ f"-testactivationheight=segwit@{SEGWIT_HEIGHT}",
233
+ "-maxscriptsize=100000",
234
+ ],
235
  ]
236
  self.supports_cli = False
237
 
 
1411
  # First we test this transaction against std_node
1412
  # making sure the txid is added to the reject filter
1413
  self.std_node.announce_tx_and_wait_for_getdata(tx3)
1414
+ test_transaction_acceptance(self.nodes[1], self.std_node, tx3, with_witness=True, accepted=False, reason="bad-txns-input-witness-unknown")
1415
  # Now the node will no longer ask for getdata of this transaction when advertised by same txid
1416
  self.std_node.announce_tx_and_wait_for_getdata(tx3, success=False)
1417
 
 
1774
  tx2.rehash()
1775
  # This will be rejected due to a policy check:
1776
  # No witness is allowed, since it is not a witness program but a p2sh program
1777
+ test_transaction_acceptance(self.nodes[1], self.std_node, tx2, True, False, 'bad-witness-nonwitness-input')
1778
 
1779
  # If we send without witness, it should be accepted.
1780
  test_transaction_acceptance(self.nodes[1], self.std_node, tx2, False, True)
 
1843
  # Testing native P2WSH
1844
  # Witness stack size, excluding witnessScript, over 100 is non-standard
1845
  p2wsh_txs[0].wit.vtxinwit[0].scriptWitness.stack = [pad] * 101 + [scripts[0]]
1846
+ test_transaction_acceptance(self.nodes[1], self.std_node, p2wsh_txs[0], True, False, 'bad-witness-stackitem-count')
1847
  # Non-standard nodes should accept
1848
  test_transaction_acceptance(self.nodes[0], self.test_node, p2wsh_txs[0], True, True)
1849
 
1850
  # Stack element size over 80 bytes is non-standard
1851
  p2wsh_txs[1].wit.vtxinwit[0].scriptWitness.stack = [pad * 81] * 100 + [scripts[1]]
1852
+ test_transaction_acceptance(self.nodes[1], self.std_node, p2wsh_txs[1], True, False, 'bad-witness-stackitem-size')
1853
  # Non-standard nodes should accept
1854
  test_transaction_acceptance(self.nodes[0], self.test_node, p2wsh_txs[1], True, True)
1855
  # Standard nodes should accept if element size is not over 80 bytes
 
1863
 
1864
  # witnessScript size at 3601 bytes is non-standard
1865
  p2wsh_txs[3].wit.vtxinwit[0].scriptWitness.stack = [pad, pad, pad, scripts[3]]
1866
+ test_transaction_acceptance(self.nodes[1], self.std_node, p2wsh_txs[3], True, False, 'bad-witness-script-size')
1867
  # Non-standard nodes should accept
1868
  test_transaction_acceptance(self.nodes[0], self.test_node, p2wsh_txs[3], True, True)
1869
 
1870
  # Repeating the same tests with P2SH-P2WSH
1871
  p2sh_txs[0].wit.vtxinwit[0].scriptWitness.stack = [pad] * 101 + [scripts[0]]
1872
+ test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[0], True, False, 'bad-witness-stackitem-count')
1873
  test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[0], True, True)
1874
  p2sh_txs[1].wit.vtxinwit[0].scriptWitness.stack = [pad * 81] * 100 + [scripts[1]]
1875
+ test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[1], True, False, 'bad-witness-stackitem-size')
1876
  test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[1], True, True)
1877
  p2sh_txs[1].wit.vtxinwit[0].scriptWitness.stack = [pad * 80] * 100 + [scripts[1]]
1878
  test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[1], True, True)
 
1880
  test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[2], True, True)
1881
  test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[2], True, True)
1882
  p2sh_txs[3].wit.vtxinwit[0].scriptWitness.stack = [pad, pad, pad, scripts[3]]
1883
+ test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[3], True, False, 'bad-witness-script-size')
1884
  test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[3], True, True)
1885
 
1886
  self.generate(self.nodes[0], 1) # Mine and clean up the mempool of non-standard node