mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-29 23:41:11 +02:00
test: properly check for per-tx sigops limit
Currently the per-tx sigops limit standardness check (bounded by `MAX_STANDARD_TX_SIGOPS_COST`, throwing "bad-txns-too-many-sigops" if exceeded) is only indirectly tested with the much higher per-block consensus limit (`MAX_BLOCK_SIGOPS_COST`), i.e. an increase in the limit would still pass all tests. Refine that by splitting up the invalid tx template `TooManySigops` in a per-block and a per-tx one. The involved functional tests taking use of these templates are `feature_block.py` and `p2p_invalid_txs.py`.
This commit is contained in:
@@ -30,7 +30,11 @@ from test_framework.messages import (
|
|||||||
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,
|
||||||
|
MAX_STANDARD_TX_SIGOPS,
|
||||||
|
)
|
||||||
from test_framework.script import (
|
from test_framework.script import (
|
||||||
CScript,
|
CScript,
|
||||||
OP_0,
|
OP_0,
|
||||||
@@ -233,7 +237,7 @@ class InvalidOPIFConstruction(BadTxTemplate):
|
|||||||
amount=(self.spend_avail // 2))
|
amount=(self.spend_avail // 2))
|
||||||
|
|
||||||
|
|
||||||
class TooManySigops(BadTxTemplate):
|
class TooManySigopsPerBlock(BadTxTemplate):
|
||||||
reject_reason = "bad-txns-too-many-sigops"
|
reject_reason = "bad-txns-too-many-sigops"
|
||||||
block_reject_reason = "bad-blk-sigops, out-of-bounds SigOpCount"
|
block_reject_reason = "bad-blk-sigops, out-of-bounds SigOpCount"
|
||||||
expect_disconnect = False
|
expect_disconnect = False
|
||||||
@@ -245,6 +249,20 @@ class TooManySigops(BadTxTemplate):
|
|||||||
output_script=lotsa_checksigs,
|
output_script=lotsa_checksigs,
|
||||||
amount=1)
|
amount=1)
|
||||||
|
|
||||||
|
|
||||||
|
class TooManySigopsPerTransaction(BadTxTemplate):
|
||||||
|
reject_reason = "bad-txns-too-many-sigops"
|
||||||
|
expect_disconnect = False
|
||||||
|
valid_in_block = True
|
||||||
|
|
||||||
|
def get_tx(self):
|
||||||
|
lotsa_checksigs = CScript([OP_CHECKSIG] * (MAX_STANDARD_TX_SIGOPS + 1))
|
||||||
|
return create_tx_with_script(
|
||||||
|
self.spend_tx, 0,
|
||||||
|
output_script=lotsa_checksigs,
|
||||||
|
amount=1)
|
||||||
|
|
||||||
|
|
||||||
def getDisabledOpcodeTemplate(opcode):
|
def getDisabledOpcodeTemplate(opcode):
|
||||||
""" Creates disabled opcode tx template class"""
|
""" Creates disabled opcode tx template class"""
|
||||||
def get_tx(self):
|
def get_tx(self):
|
||||||
|
@@ -49,6 +49,7 @@ from .util import assert_equal
|
|||||||
|
|
||||||
MAX_BLOCK_SIGOPS = 20000
|
MAX_BLOCK_SIGOPS = 20000
|
||||||
MAX_BLOCK_SIGOPS_WEIGHT = MAX_BLOCK_SIGOPS * WITNESS_SCALE_FACTOR
|
MAX_BLOCK_SIGOPS_WEIGHT = MAX_BLOCK_SIGOPS * WITNESS_SCALE_FACTOR
|
||||||
|
MAX_STANDARD_TX_SIGOPS = 4000
|
||||||
MAX_STANDARD_TX_WEIGHT = 400000
|
MAX_STANDARD_TX_WEIGHT = 400000
|
||||||
|
|
||||||
# Genesis block time (regtest)
|
# Genesis block time (regtest)
|
||||||
|
Reference in New Issue
Block a user