-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4709534
commit b05f2dc
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
%lang starknet | ||
|
||
// Starkware dependencies | ||
from starkware.cairo.common.alloc import alloc | ||
from starkware.cairo.common.bool import TRUE, FALSE | ||
from starkware.cairo.common.cairo_builtins import HashBuiltin, BitwiseBuiltin | ||
|
||
// Local dependencies | ||
from utils.utils import Helpers | ||
from kakarot.model import model | ||
from kakarot.instructions import EVMInstructions | ||
from tests.utils.utils import TestHelpers | ||
|
||
@external | ||
func test__unknown_opcode{ | ||
syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr, bitwise_ptr: BitwiseBuiltin* | ||
}() { | ||
alloc_locals; | ||
let (bytecode) = alloc(); | ||
let ctx: model.ExecutionContext* = TestHelpers.init_context(0, bytecode); | ||
EVMInstructions.unknown_opcode(ctx); | ||
|
||
return (); | ||
} | ||
|
||
@external | ||
func test__not_implemented_opcode{ | ||
syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr, bitwise_ptr: BitwiseBuiltin* | ||
}() { | ||
alloc_locals; | ||
let (bytecode) = alloc(); | ||
let ctx: model.ExecutionContext* = TestHelpers.init_context(0, bytecode); | ||
EVMInstructions.not_implemented_opcode(ctx); | ||
|
||
return (); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import re | ||
|
||
import pytest | ||
import pytest_asyncio | ||
from starkware.starknet.testing.starknet import Starknet | ||
|
||
|
||
@pytest_asyncio.fixture(scope="module") | ||
async def instructions(starknet: Starknet): | ||
return await starknet.deploy( | ||
source="./tests/cairo_files/test_instructions.cairo", | ||
cairo_path=["src"], | ||
disable_hint_validation=False, | ||
) | ||
|
||
|
||
@pytest.mark.asyncio | ||
class TestInstructions: | ||
async def test__unknown_opcode(self, instructions): | ||
with pytest.raises(Exception) as e: | ||
await instructions.test__unknown_opcode().call() | ||
message = re.search(r"Error message: (.*)", e.value.message)[1] # type: ignore | ||
assert message == "Kakarot: UnknownOpcode" | ||
|
||
async def test__not_implemented_opcode(self, instructions): | ||
with pytest.raises(Exception) as e: | ||
await instructions.test__not_implemented_opcode().call() | ||
message = re.search(r"Error message: (.*)", e.value.message)[1] # type: ignore | ||
assert message == "Kakarot: NotImplementedOpcode" |