Skip to content

Commit 9f88ded

Browse files
instagibbssdaftuar
authored andcommitted
test addition of unknown segwit spends to txid reject filter
1 parent 7989901 commit 9f88ded

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

test/functional/p2p_segwit.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,16 +1418,24 @@ def test_segwit_versions(self):
14181418
temp_utxo.pop() # last entry in temp_utxo was the output we just spent
14191419
temp_utxo.append(UTXO(tx2.sha256, 0, tx2.vout[0].nValue))
14201420

1421-
# Spend everything in temp_utxo back to an OP_TRUE output.
1421+
# Spend everything in temp_utxo into an segwit v1 output.
14221422
tx3 = CTransaction()
14231423
total_value = 0
14241424
for i in temp_utxo:
14251425
tx3.vin.append(CTxIn(COutPoint(i.sha256, i.n), b""))
14261426
tx3.wit.vtxinwit.append(CTxInWitness())
14271427
total_value += i.nValue
14281428
tx3.wit.vtxinwit[-1].scriptWitness.stack = [witness_program]
1429-
tx3.vout.append(CTxOut(total_value - 1000, CScript([OP_TRUE])))
1429+
tx3.vout.append(CTxOut(total_value - 1000, script_pubkey))
14301430
tx3.rehash()
1431+
1432+
# First we test this transaction against fRequireStandard=true node
1433+
# making sure the txid is added to the reject filter
1434+
self.std_node.announce_tx_and_wait_for_getdata(tx3)
1435+
test_transaction_acceptance(self.nodes[1], self.std_node, tx3, with_witness=True, accepted=False, reason="bad-txns-nonstandard-inputs")
1436+
# Now the node will no longer ask for getdata of this transaction when advertised by same txid
1437+
self.std_node.announce_tx_and_wait_for_getdata(tx3, timeout=5, success=False)
1438+
14311439
# Spending a higher version witness output is not allowed by policy,
14321440
# even with fRequireStandard=false.
14331441
test_transaction_acceptance(self.nodes[0], self.test_node, tx3, with_witness=True, accepted=False, reason="reserved for soft-fork upgrades")

0 commit comments

Comments
 (0)