diff options
author | Ava Chow <github@achow101.com> | 2024-06-20 13:36:55 -0400 |
---|---|---|
committer | Ava Chow <github@achow101.com> | 2024-06-20 13:36:55 -0400 |
commit | 21656e99b5f489c881f9fe90b28edc4aac870ab0 (patch) | |
tree | 0018d6d97ec952b3cc88397e3ea7775e3fbd082d /test/functional | |
parent | a52837b9e9692e7e1e8f3a5fd510aca8ef8a5ac4 (diff) | |
parent | 969e047cfbab86e5819a2c9056e8d2dab17513a8 (diff) |
Merge bitcoin/bitcoin#29862: test: Validate oversized transactions or without inputs
969e047cfbab86e5819a2c9056e8d2dab17513a8 Replace hard-coded constant in test (Lőrinc)
327a31d1a4f0e9c7b22063bc725bbd160092c552 Validate oversized transaction (Lőrinc)
1984187840972a455f4c210f0cb576633ef5bddb Validate transaction without inputs (Lőrinc)
c3a884318981c7ebabd0b8e8023a14519e26c72b Use SCRIPT_VERIFY_NONE instead of hard-coded 0 in transaction_tests (Lőrinc)
Pull request description:
Based on https://maflcko.github.io/b-c-cov/test_bitcoin.coverage/src/consensus/tx_check.cpp.gcov.html empty inputs and oversized transactions weren't covered by Boost unit tests (though they're covered by [python](https://github.com/bitcoin/bitcoin/blob/master/test/functional/mempool_accept.py#L231) [tests](https://github.com/bitcoin/bitcoin/blob/master/test/functional/data/invalid_txs.py#L102)).
<img alt="image" src="https://github.com/bitcoin/bitcoin/assets/1841944/57a74ff5-5466-401f-a4fe-d79e36964adf">
I have tried including the empty transaction into [tx_invalid.json](https://github.com/bitcoin/bitcoin/blob/master/src/test/data/tx_invalid.json#L34-L36), but it failed for another reason, so I added a separate test case for it in the end.
The oversized tx data is on the failure threshold now (lower threshold fails for a different reason, but I guess that's fine, we're testing the boundary here).
ACKs for top commit:
achow101:
ACK 969e047cfbab86e5819a2c9056e8d2dab17513a8
tdb3:
ACK 969e047cfbab86e5819a2c9056e8d2dab17513a8 pending `MSan, depends` CI failure.
glozow:
utACK 969e047cfbab86e5819a2c9056e8d2dab17513a8
Tree-SHA512: 2a472690eabfdacc276b7e0414d3a4ebc75c227405b202c9fe3c8befad875f6e4d9b40c056fb05971ad3ae479c8f53edebb2eeeb700088856caf5cf58bfca0c1
Diffstat (limited to 'test/functional')
-rwxr-xr-x | test/functional/mempool_accept.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/test/functional/mempool_accept.py b/test/functional/mempool_accept.py index 3d205ffa62..e1cee46839 100755 --- a/test/functional/mempool_accept.py +++ b/test/functional/mempool_accept.py @@ -18,6 +18,7 @@ from test_framework.messages import ( CTxInWitness, CTxOut, MAX_BLOCK_WEIGHT, + WITNESS_SCALE_FACTOR, MAX_MONEY, SEQUENCE_FINAL, tx_from_hex, @@ -228,7 +229,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework): self.log.info('A really large transaction') tx = tx_from_hex(raw_tx_reference) - tx.vin = [tx.vin[0]] * math.ceil(MAX_BLOCK_WEIGHT // 4 / len(tx.vin[0].serialize())) + tx.vin = [tx.vin[0]] * math.ceil((MAX_BLOCK_WEIGHT // WITNESS_SCALE_FACTOR) / len(tx.vin[0].serialize())) self.check_mempool_result( result_expected=[{'txid': tx.rehash(), 'allowed': False, 'reject-reason': 'bad-txns-oversize'}], rawtxs=[tx.serialize().hex()], |