-
Notifications
You must be signed in to change notification settings - Fork 99
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
Showing
11 changed files
with
1,082 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,3 @@ | ||
""" | ||
Scenarios common import | ||
""" |
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,64 @@ | ||
""" | ||
Define Scenario class for test_scenarios test | ||
""" | ||
from dataclasses import dataclass | ||
from enum import Enum | ||
|
||
from ethereum_test_forks import Fork, Frontier | ||
from ethereum_test_tools import Address | ||
|
||
|
||
class ScenarioExpectOpcode(Enum): | ||
"""Opcodes that are replaced to real values computed by the scenario""" | ||
|
||
TX_ORIGIN = 1 | ||
CODE_ADDRESS = 2 | ||
CODE_CALLER = 3 | ||
SELFBALANCE = 4 | ||
|
||
|
||
@dataclass | ||
class ProgramResult: | ||
""" | ||
Describe expected result of a program | ||
Attributes: | ||
result (int | ScenarioExpectOpcode): The result of the program | ||
from_fork (Fork): The result is only valid from this fork (default: Frontier) | ||
""" | ||
|
||
result: int | ScenarioExpectOpcode | ||
|
||
"""The result is only valid from this fork""" | ||
from_fork: Fork = Frontier | ||
|
||
|
||
@dataclass | ||
class ScenarioEnvironment: | ||
""" | ||
Scenario evm environment | ||
Each scenario must define an environment on which program is executed | ||
This is so post state verification could check results of evm opcodes | ||
""" | ||
|
||
code_address: Address # Op.ADDRESS, address scope for program | ||
code_caller: Address # Op.CALLER, caller of the program | ||
selfbalance: int # Op.SELFBALANCE, balance of the environment of the program | ||
|
||
|
||
@dataclass | ||
class Scenario: | ||
""" | ||
Describe test scenario that will be run in test for each program | ||
Attributes: | ||
name (str): Scenario name for the test vector | ||
code (Address): Address that is an entry point for scenario code | ||
env (ScenarioEnvironment): Evm values for ScenarioExpectAddress map | ||
reverting (bool): If scenario reverts program execution, making result 0 (default: False) | ||
""" | ||
|
||
name: str | ||
code: Address | ||
env: ScenarioEnvironment | ||
reverting: bool = False |
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,3 @@ | ||
""" | ||
Scenarios common import | ||
""" |
Oops, something went wrong.