From 47f6160b785fce295936e23592089a323b50c1b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Fri, 11 Aug 2017 12:24:22 +0200 Subject: [PATCH] EIP-96: Add overflow tests for argument check --- EIPS/eip-96/tests/test_blockhash_contract.py | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/EIPS/eip-96/tests/test_blockhash_contract.py b/EIPS/eip-96/tests/test_blockhash_contract.py index 2987956318a53c..93f6db7ed01473 100644 --- a/EIPS/eip-96/tests/test_blockhash_contract.py +++ b/EIPS/eip-96/tests/test_blockhash_contract.py @@ -150,12 +150,35 @@ def test_first256th_slot(state): state.block.number = n +def test_overflow(state): + n = state.block.number + state.block.number = 1 + + arg = utils.zpad(utils.coerce_to_bytes(2**256 - 256), 32) + out = state.profile(sender=tester.k1, to=BLOCKHASH_ADDR, value=0, + evmdata=arg) + assert out['output'] == NULL_HASH + assert out['gas'] == 79 + + state.block.number = n + + def test_fake_state_setup(fake_state): for i in range(3 * 256): assert fake_state.get_slot(i) == fake_slot(i) assert fake_state.get_slot(3 * 256) == NULL_HASH +def test_overflow2(fake_state): + fake_state.block.number = 255 + + arg = '\xff' * 31 + out = fake_state.profile(sender=tester.k1, to=BLOCKHASH_ADDR, value=0, + evmdata=arg) + assert out['output'] == NULL_HASH + assert out['gas'] == 79 + + def test_blockhash_last256(fake_state): start_block = fake_state.block.number - 256 for n in range(start_block, fake_state.block.number):