tests: Add witness commitment if we have a witness transaction in FullBlockTest.update_block()

This commit is contained in:
Chris Stewart
2025-02-07 11:46:34 -06:00
parent e221b25246
commit a7c96f874d
2 changed files with 20 additions and 0 deletions

View File

@@ -26,6 +26,7 @@ from test_framework.messages import (
COutPoint,
CTransaction,
CTxIn,
CTxInWitness,
CTxOut,
MAX_MONEY,
SEQUENCE_FINAL,
@@ -36,6 +37,7 @@ from test_framework.blocktools import (
MAX_STANDARD_TX_SIGOPS,
)
from test_framework.script import (
OP_TRUE,
CScript,
OP_0,
OP_2DIV,
@@ -124,6 +126,20 @@ class SizeTooSmall(BadTxTemplate):
assert MIN_STANDARD_TX_NONWITNESS_SIZE - 1 == 64
return tx
# reject a transaction that contains a witness
# but doesn't spend a segwit output
class ExtraWitness(BadTxTemplate):
reject_reason = "tx-size-small"
block_reject_reason = "block-script-verify-flag-failed (Witness provided for non-witness script)"
def get_tx(self):
tx = CTransaction()
tx.vin.append(self.valid_txin)
tx.vout.append(CTxOut(0, CScript()))
tx.wit.vtxinwit = [CTxInWitness()]
tx.wit.vtxinwit[0].scriptWitness.stack = [CScript([OP_TRUE])]
return tx
class BadInputOutpointIndex(BadTxTemplate):
# Won't be rejected - nonexistent outpoint index is treated as an orphan since the coins