mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-29 03:02:33 +01:00
Compare commits
2 Commits
98924bc07e
...
3e063fe4f4
Author | SHA1 | Date | |
---|---|---|---|
|
3e063fe4f4 | ||
|
6109bc529e |
@ -26,12 +26,14 @@ from test_framework.messages import (
|
|||||||
COutPoint,
|
COutPoint,
|
||||||
CTransaction,
|
CTransaction,
|
||||||
CTxIn,
|
CTxIn,
|
||||||
|
CTxInWitness,
|
||||||
CTxOut,
|
CTxOut,
|
||||||
MAX_MONEY,
|
MAX_MONEY,
|
||||||
SEQUENCE_FINAL,
|
SEQUENCE_FINAL,
|
||||||
)
|
)
|
||||||
from test_framework.blocktools import create_tx_with_script, MAX_BLOCK_SIGOPS
|
from test_framework.blocktools import create_tx_with_script, MAX_BLOCK_SIGOPS
|
||||||
from test_framework.script import (
|
from test_framework.script import (
|
||||||
|
OP_TRUE,
|
||||||
CScript,
|
CScript,
|
||||||
OP_0,
|
OP_0,
|
||||||
OP_2DIV,
|
OP_2DIV,
|
||||||
@ -129,6 +131,22 @@ class SizeTooSmall(BadTxTemplate):
|
|||||||
tx.calc_sha256()
|
tx.calc_sha256()
|
||||||
return tx
|
return tx
|
||||||
|
|
||||||
|
# reject a transaction that contains a witness
|
||||||
|
# but doesnt spend a segwit output
|
||||||
|
class ExtraWitness(BadTxTemplate):
|
||||||
|
expect_disconnect = False
|
||||||
|
valid_in_block = False
|
||||||
|
block_reject_reason = "mandatory-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])]
|
||||||
|
tx.calc_sha256()
|
||||||
|
return tx
|
||||||
|
|
||||||
|
|
||||||
class BadInputOutpointIndex(BadTxTemplate):
|
class BadInputOutpointIndex(BadTxTemplate):
|
||||||
# Won't be rejected - nonexistent outpoint index is treated as an orphan since the coins
|
# Won't be rejected - nonexistent outpoint index is treated as an orphan since the coins
|
||||||
|
@ -7,6 +7,7 @@ import copy
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from test_framework.blocktools import (
|
from test_framework.blocktools import (
|
||||||
|
add_witness_commitment,
|
||||||
create_block,
|
create_block,
|
||||||
create_coinbase,
|
create_coinbase,
|
||||||
create_tx_with_script,
|
create_tx_with_script,
|
||||||
@ -1400,6 +1401,9 @@ class FullBlockTest(BitcoinTestFramework):
|
|||||||
self.add_transactions_to_block(block, new_transactions)
|
self.add_transactions_to_block(block, new_transactions)
|
||||||
old_sha256 = block.sha256
|
old_sha256 = block.sha256
|
||||||
block.hashMerkleRoot = block.calc_merkle_root()
|
block.hashMerkleRoot = block.calc_merkle_root()
|
||||||
|
has_witness_tx = any(not tx.wit.is_null() for tx in block.vtx)
|
||||||
|
if has_witness_tx:
|
||||||
|
add_witness_commitment(block)
|
||||||
block.solve()
|
block.solve()
|
||||||
# Update the internal state just like in next_block
|
# Update the internal state just like in next_block
|
||||||
self.tip = block
|
self.tip = block
|
||||||
|
Loading…
x
Reference in New Issue
Block a user