Skip to content

Commit

Permalink
EIP-96: Add overflow tests for argument check
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Aug 11, 2017
1 parent a03bcc1 commit 47f6160
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions EIPS/eip-96/tests/test_blockhash_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 47f6160

Please sign in to comment.