Skip to content

Commit e7b0af9

Browse files
committed
tests/opcodes: exponentiation: 0^0==1, 0^1==0.
1 parent 08674f6 commit e7b0af9

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/core/opcodes/test_opcodes.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,32 @@ def test_mul(vm_class, val1, val2, expected):
123123
assert result == expected
124124

125125

126+
@pytest.mark.parametrize(
127+
'vm_class, base, exponent, expected',
128+
(
129+
(ByzantiumVM, 0, 1, 0,),
130+
(ByzantiumVM, 0, 0, 1,),
131+
(SpuriousDragonVM, 0, 1, 0,),
132+
(SpuriousDragonVM, 0, 0, 1,),
133+
(TangerineWhistleVM, 0, 1, 0,),
134+
(TangerineWhistleVM, 0, 0, 1,),
135+
(HomesteadVM, 0, 1, 0,),
136+
(HomesteadVM, 0, 0, 1,),
137+
(FrontierVM, 0, 1, 0,),
138+
(FrontierVM, 0, 0, 1,),
139+
)
140+
)
141+
def test_exp(vm_class, base, exponent, expected):
142+
computation = prepare_computation(vm_class)
143+
computation.stack_push(exponent)
144+
computation.stack_push(base)
145+
computation.opcodes[opcode_values.EXP](computation)
146+
147+
result = computation.stack_pop(type_hint=constants.UINT256)
148+
149+
assert result == expected
150+
151+
126152
@pytest.mark.parametrize(
127153
# Testcases from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-145.md#shl-shift-left
128154
'vm_class, val1, val2, expected',

0 commit comments

Comments
 (0)