generated from ApeWorX/project-template
-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: default displayable trace in repr and str for CallTreeNode #5
Merged
Conversation
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
antazoey
commented
May 16, 2022
evm_trace/base.py
Outdated
@@ -58,6 +58,15 @@ class CallTreeNode(BaseModel): | |||
def validate_hexbytes(cls, v) -> HexBytes: | |||
return _convert_hexbytes(cls, v) | |||
|
|||
def __str__(self) -> str: | |||
spacing = self.depth * " " | |||
title = f"{spacing} {self.call_type} call {self.address.hex()} gas={self.gas_cost}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tell me any extra useful data you'd like per default node
|
tests/test_trace_frame.py
Outdated
Comment on lines
36
to
23
@pytest.mark.parametrize("test_data", ( | ||
{"stack": ["potato"]}, | ||
{"memory": ["potato"]}, | ||
{"storage": {"piggy": "dippin"}}, | ||
) | ||
|
||
|
||
@pytest.mark.parametrize("test_value", trace_frame_test_cases) | ||
def test_trace_frame_validation_fails(test_value): | ||
trace_frame_structure = deepcopy(TRACE_FRAME_STRUCTURE) | ||
trace_frame_structure.update(test_value) | ||
|
||
)) | ||
def test_trace_frame_validation_fails(test_data): | ||
data = {**TRACE_FRAME_STRUCTURE, **test_data} | ||
with pytest.raises(ValidationError): | ||
TraceFrame(**trace_frame_structure) | ||
TraceFrame(**data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
antazoey
force-pushed
the
feat/jules-decode
branch
from
May 17, 2022 15:29
6c9f4f5
to
b00be08
Compare
default traces be like
|
antazoey
changed the title
feat: default trace print ability
feat: default displayable trace in repr and str for CallTreeNode
May 17, 2022
antazoey
requested review from
NotPeopling2day and
fubuloubu
and removed request for
fubuloubu and
NotPeopling2day
May 20, 2022 19:31
fubuloubu
reviewed
May 20, 2022
3 tasks
fubuloubu
approved these changes
Jun 8, 2022
fubuloubu
reviewed
Jun 8, 2022
antazoey
force-pushed
the
feat/jules-decode
branch
from
June 8, 2022 17:48
36d848f
to
45da160
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What I did
Provide default tree via
__repr__
and__str__
methods.How I did it
Inspired from the answer with 66 updoots: https://stackoverflow.com/questions/9727673/list-directory-tree-structure-in-python
How to verify it
print(tree)
Checklist