Skip to content

Commit

Permalink
Bugfix: test/functional/mempool_accept: Ensure oversize transaction i…
Browse files Browse the repository at this point in the history
…s actually oversize

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.
  • Loading branch information
luke-jr committed Nov 27, 2018
1 parent 8a9ffec commit 29aeed1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/functional/mempool_accept.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -178,7 +179,7 @@ def run_test(self):

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())],
Expand Down

0 comments on commit 29aeed1

Please sign in to comment.