Changeset View
Changeset View
Standalone View
Standalone View
test/functional/data/invalid_txs.py
Show All 15 Lines | Invalid tx cases not covered here can be found by running: | ||||
$ diff \ | $ diff \ | ||||
<(grep -IREho "bad-txns[a-zA-Z-]+" src | sort -u) \ | <(grep -IREho "bad-txns[a-zA-Z-]+" src | sort -u) \ | ||||
<(grep -IEho "bad-txns[a-zA-Z-]+" test/functional/data/invalid_txs.py | sort -u) | <(grep -IEho "bad-txns[a-zA-Z-]+" test/functional/data/invalid_txs.py | sort -u) | ||||
""" | """ | ||||
import abc | import abc | ||||
from test_framework.messages import CTransaction, CTxIn, CTxOut, COutPoint | from test_framework.messages import ( | ||||
COutPoint, | |||||
CTransaction, | |||||
CTxIn, | |||||
CTxOut, | |||||
MAX_MONEY, | |||||
) | |||||
from test_framework import script as sc | from test_framework import script as sc | ||||
from test_framework.blocktools import create_tx_with_script | from test_framework.blocktools import create_tx_with_script | ||||
from test_framework.txtools import pad_tx | from test_framework.txtools import pad_tx | ||||
from test_framework.script import ( | from test_framework.script import ( | ||||
CScript, | CScript, | ||||
OP_INVERT, | OP_INVERT, | ||||
▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | class SpendTooMuch(BadTxTemplate): | ||||
reject_reason = 'bad-txns-in-belowout' | reject_reason = 'bad-txns-in-belowout' | ||||
expect_disconnect = True | expect_disconnect = True | ||||
def get_tx(self): | def get_tx(self): | ||||
return create_tx_with_script( | return create_tx_with_script( | ||||
self.spend_tx, 0, script_pub_key=basic_p2sh, amount=(self.spend_avail + 1)) | self.spend_tx, 0, script_pub_key=basic_p2sh, amount=(self.spend_avail + 1)) | ||||
class SpendNegative(BadTxTemplate): | class CreateNegative(BadTxTemplate): | ||||
reject_reason = 'bad-txns-vout-negative' | reject_reason = 'bad-txns-vout-negative' | ||||
expect_disconnect = True | expect_disconnect = True | ||||
def get_tx(self): | def get_tx(self): | ||||
return create_tx_with_script(self.spend_tx, 0, amount=-1) | return create_tx_with_script(self.spend_tx, 0, amount=-1) | ||||
class CreateTooLarge(BadTxTemplate): | |||||
reject_reason = 'bad-txns-vout-toolarge' | |||||
expect_disconnect = True | |||||
def get_tx(self): | |||||
return create_tx_with_script(self.spend_tx, 0, amount=MAX_MONEY + 1) | |||||
class CreateSumTooLarge(BadTxTemplate): | |||||
reject_reason = 'bad-txns-txouttotal-toolarge' | |||||
expect_disconnect = True | |||||
def get_tx(self): | |||||
tx = create_tx_with_script(self.spend_tx, 0, amount=MAX_MONEY) | |||||
tx.vout = [tx.vout[0]] * 2 | |||||
tx.calc_sha256() | |||||
return tx | |||||
class InvalidOPIFConstruction(BadTxTemplate): | class InvalidOPIFConstruction(BadTxTemplate): | ||||
reject_reason = "mandatory-script-verify-flag-failed (Invalid OP_IF construction)" | reject_reason = "mandatory-script-verify-flag-failed (Invalid OP_IF construction)" | ||||
expect_disconnect = True | expect_disconnect = True | ||||
valid_in_block = True | valid_in_block = True | ||||
def get_tx(self): | def get_tx(self): | ||||
return create_tx_with_script( | return create_tx_with_script( | ||||
self.spend_tx, 0, script_sig=b'\x64' * 35, | self.spend_tx, 0, script_sig=b'\x64' * 35, | ||||
Show All 37 Lines |