Merge #14819: Bugfix: test/functional/mempool_accept: Ensure oversize transaction is actually oversize

29aeed1734 Bugfix: test/functional/mempool_accept: Ensure oversize transaction is actually oversize (Luke Dashjr)

Pull request description:

  Simply integer dividing results in an acceptable size if the limit isn't an exact multiple of the input size.
  Use math.ceil to ensure the transaction is always oversize.

  (This issue can be triggered by changing the address style used.)

Tree-SHA512: e45062b0e8a3e9cb08e9dac5275b68d86e4377b460f1b3b995944090a055b0542a6986826312ec0e223369838094e42e20d8614b5c2bab9975b9a6f749295b21
This commit is contained in:
MarcoFalke 2018-11-28 10:40:29 -05:00
commit 9ebfe0e927
No known key found for this signature in database
GPG key ID: D2EA4850E7528B25

View file

@ -5,6 +5,7 @@
"""Test mempool acceptance of raw transactions."""
from io import BytesIO
import math
from test_framework.test_framework import BitcoinTestFramework
from test_framework.messages import (
BIP125_SEQUENCE_NUMBER,
@ -181,7 +182,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
self.log.info('A really large transaction')
tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_reference)))
tx.vin = [tx.vin[0]] * (MAX_BLOCK_BASE_SIZE // len(tx.vin[0].serialize()))
tx.vin = [tx.vin[0]] * math.ceil(MAX_BLOCK_BASE_SIZE / len(tx.vin[0].serialize()))
self.check_mempool_result(
result_expected=[{'txid': tx.rehash(), 'allowed': False, 'reject-reason': '16: bad-txns-oversize'}],
rawtxs=[bytes_to_hex_str(tx.serialize())],