Skip to content

Commit 47f6160

Browse files
committed
EIP-96: Add overflow tests for argument check
1 parent a03bcc1 commit 47f6160

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

EIPS/eip-96/tests/test_blockhash_contract.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,35 @@ def test_first256th_slot(state):
150150
state.block.number = n
151151

152152

153+
def test_overflow(state):
154+
n = state.block.number
155+
state.block.number = 1
156+
157+
arg = utils.zpad(utils.coerce_to_bytes(2**256 - 256), 32)
158+
out = state.profile(sender=tester.k1, to=BLOCKHASH_ADDR, value=0,
159+
evmdata=arg)
160+
assert out['output'] == NULL_HASH
161+
assert out['gas'] == 79
162+
163+
state.block.number = n
164+
165+
153166
def test_fake_state_setup(fake_state):
154167
for i in range(3 * 256):
155168
assert fake_state.get_slot(i) == fake_slot(i)
156169
assert fake_state.get_slot(3 * 256) == NULL_HASH
157170

158171

172+
def test_overflow2(fake_state):
173+
fake_state.block.number = 255
174+
175+
arg = '\xff' * 31
176+
out = fake_state.profile(sender=tester.k1, to=BLOCKHASH_ADDR, value=0,
177+
evmdata=arg)
178+
assert out['output'] == NULL_HASH
179+
assert out['gas'] == 79
180+
181+
159182
def test_blockhash_last256(fake_state):
160183
start_block = fake_state.block.number - 256
161184
for n in range(start_block, fake_state.block.number):

0 commit comments

Comments
 (0)