mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-22 14:52:41 +02:00
Merge bitcoin/bitcoin#22408: test: add tests for bad-txns-prevout-null
reject reason
1f449586a9e39bc4fb53cb5c7a31362e47aea19b test: add `bad-txns-prevout-null` test to mempool_accept.py (Sebastian Falbesoner) aa0a5bb70d77739d43d5a9ceae78fb0c6fafd435 test: add `bad-txns-prevout-null` test case to invalid_txs.py (Sebastian Falbesoner) Pull request description: This simple PR adds missing tests for the reject reason `bad-txns-prevout-null`, which is thrown in the function `CheckTransaction()`:a62fc35a15/src/consensus/tx_check.cpp (L52-L54)
Basically this condition is met for non-coinbase transactions (the code snippet above only hits if `!tx.IsCoinBase()`) with coinbase-like outpoints, i.e. hash=0, n=0xffffffff. Can be tested by running the functional tests `feature_block.py`, `p2p_invalid_tx.py` and `mempool_accept.py`. Not sure if the redundancy in the tests is desired (I guess it would make sense if the mempool acceptance test also makes use of the invalid_txs templates?). ACKs for top commit: rajarshimaitra: tACK1f449586a9
brunoerg: tACK 1f449586a9e39bc4fb53cb5c7a31362e47aea19b kristapsk: ACK 1f449586a9e39bc4fb53cb5c7a31362e47aea19b, code looks correct and all tests pass. Tree-SHA512: 2d4f940a6ac8e0d80d2670c9e1111cbf43ae6ac62809a2ccf17cffee9a41d387ea4d889ee300eb4a407c055b13bfa5d37102a32ed59964a9b6950bd907ba7204
This commit is contained in:
commit
df2b5dadfb
@ -151,6 +151,19 @@ class DuplicateInput(BadTxTemplate):
|
||||
return tx
|
||||
|
||||
|
||||
class PrevoutNullInput(BadTxTemplate):
|
||||
reject_reason = 'bad-txns-prevout-null'
|
||||
expect_disconnect = True
|
||||
|
||||
def get_tx(self):
|
||||
tx = CTransaction()
|
||||
tx.vin.append(self.valid_txin)
|
||||
tx.vin.append(CTxIn(COutPoint(hash=0, n=0xffffffff)))
|
||||
tx.vout.append(CTxOut(1, basic_p2sh))
|
||||
tx.calc_sha256()
|
||||
return tx
|
||||
|
||||
|
||||
class NonexistentInput(BadTxTemplate):
|
||||
reject_reason = None # Added as an orphan tx.
|
||||
expect_disconnect = False
|
||||
|
@ -13,6 +13,7 @@ from test_framework.messages import (
|
||||
BIP125_SEQUENCE_NUMBER,
|
||||
COIN,
|
||||
COutPoint,
|
||||
CTxIn,
|
||||
CTxOut,
|
||||
MAX_BLOCK_BASE_SIZE,
|
||||
MAX_MONEY,
|
||||
@ -247,6 +248,14 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
||||
rawtxs=[tx.serialize().hex()],
|
||||
)
|
||||
|
||||
self.log.info('A non-coinbase transaction with coinbase-like outpoint')
|
||||
tx = tx_from_hex(raw_tx_reference)
|
||||
tx.vin.append(CTxIn(COutPoint(hash=0, n=0xffffffff)))
|
||||
self.check_mempool_result(
|
||||
result_expected=[{'txid': tx.rehash(), 'allowed': False, 'reject-reason': 'bad-txns-prevout-null'}],
|
||||
rawtxs=[tx.serialize().hex()],
|
||||
)
|
||||
|
||||
self.log.info('A coinbase transaction')
|
||||
# Pick the input of the first tx we signed, so it has to be a coinbase tx
|
||||
raw_tx_coinbase_spent = node.getrawtransaction(txid=node.decoderawtransaction(hexstring=raw_tx_in_block)['vin'][0]['txid'])
|
||||
|
Loading…
x
Reference in New Issue
Block a user