forked from kkrt-labs/kakarot-rpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add EVM serialization (kkrt-labs#995)
Time spent on this PR: 0.5 ## Pull request type Please check the type of change your PR introduces: - [ ] Bugfix - [x] Feature - [ ] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no api changes) - [ ] Build related changes - [ ] Documentation content changes - [ ] Other (please describe): ## What is the current behavior? Not possible to return `model.EVM` from a test Resolves kkrt-labs#940 ## What is the new behavior? Serialize model.EVM + included struct + fix when returning struct and not struct* <!-- Reviewable:start --> - - - This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/kkrt-labs/kakarot/995) <!-- Reviewable:end -->
- Loading branch information
1 parent
5f2d942
commit b0c62ee
Showing
41 changed files
with
581 additions
and
586 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,6 @@ resources/* | |
*.pb.gz | ||
profile*.png | ||
logs | ||
|
||
tests/ef_tests/test_data | ||
!tests/ef_tests/test_data/.gitkeep |
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 |
---|---|---|
|
@@ -59,6 +59,7 @@ lint: | |
- logs* | ||
- lib* | ||
- resources* | ||
- tests/ef_tests/test_data | ||
actions: | ||
disabled: | ||
- trunk-announce | ||
|
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
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,52 @@ | ||
import io | ||
import json | ||
import logging | ||
import os | ||
import shutil | ||
import tarfile | ||
from pathlib import Path | ||
|
||
import requests | ||
|
||
EF_TESTS_TAG = "v12.4" | ||
EF_TESTS_URL = ( | ||
f"https://github.com/ethereum/tests/archive/refs/tags/{EF_TESTS_TAG}.tar.gz" | ||
) | ||
EF_TESTS_DIR = Path("tests") / "ef_tests" / "test_data" / EF_TESTS_TAG | ||
EF_TESTS_PARSED_DIR = Path("tests") / "ef_tests" / "test_data" / "parsed" | ||
|
||
DEFAULT_NETWORK = "Shanghai" | ||
|
||
logging.basicConfig() | ||
logger = logging.getLogger(__name__) | ||
logger.setLevel(logging.INFO) | ||
|
||
|
||
def generate_tests(): | ||
if not EF_TESTS_DIR.exists(): | ||
response = requests.get(EF_TESTS_URL) | ||
with tarfile.open(fileobj=io.BytesIO(response.content), mode="r:gz") as tar: | ||
tar.extractall(EF_TESTS_DIR) | ||
|
||
test_cases = { | ||
f"{os.path.basename(root)}_{name}": content | ||
for (root, _, files) in os.walk(EF_TESTS_DIR) | ||
for file in files | ||
if file.endswith(".json") and "BlockchainTests/GeneralStateTests" in root | ||
for name, content in json.loads((Path(root) / file).read_text()).items() | ||
if content.get("network") == DEFAULT_NETWORK | ||
} | ||
|
||
shutil.rmtree(EF_TESTS_PARSED_DIR, ignore_errors=True) | ||
EF_TESTS_PARSED_DIR.mkdir(parents=True, exist_ok=True) | ||
|
||
for test_name, test_case in test_cases.items(): | ||
json.dump( | ||
test_case, | ||
open(EF_TESTS_PARSED_DIR / f"{test_name}.json", "w"), | ||
indent=4, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
generate_tests() |
File renamed without changes.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
Oops, something went wrong.