forked from ethereum/execution-spec-tests
-
Notifications
You must be signed in to change notification settings - Fork 1
feat(fw): Add and integrate consume engine types #30
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
Closed
spencer-tb
wants to merge
1
commit into
danceratopz:feat/pytest/add-a-verify-fixtures-as-a-separate-pytest-command
from
spencer-tb:feat/add-consume-engine-types
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,12 @@ | ||
| """ | ||
| Consume methods and types used for EEST based test runners (consumers). | ||
| """ | ||
|
|
||
| from .engine_rpc import EngineRPC | ||
| from .eth_rpc import BlockNumberType, EthRPC | ||
|
|
||
| __all__ = ( | ||
| "BlockNumberType", | ||
| "EthRPC", | ||
| "EngineRPC", | ||
| ) |
This file contains hidden or 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,48 @@ | ||
| """ | ||
| Base JSON-RPC class and helper functions for EEST based hive simulators. | ||
| """ | ||
|
|
||
| import time | ||
|
|
||
| import jwt | ||
| import requests | ||
|
|
||
| # from jwt import encode | ||
|
|
||
|
|
||
| class BaseRPC: | ||
| """ | ||
| Represents a base RPC class for every RPC call used within EEST based hive simulators. | ||
| """ | ||
|
|
||
| def __init__(self, client): | ||
| self.client = client | ||
| self.url = f"http://{client.ip}:8551" | ||
| self.jwt_secret = ( | ||
| b"secretsecretsecretsecretsecretse" # oh wow, guess its not a secret anymore | ||
| ) | ||
|
|
||
| def generate_jwt_token(self): | ||
| """ | ||
| Generates a JWT token based on the issued at timestamp and JWT secret. | ||
| """ | ||
| iat = int(time.time()) | ||
| return jwt.encode({"iat": iat}, self.jwt_secret, algorithm="HS256") | ||
|
|
||
| def post_request(self, method, params): | ||
| """ | ||
| Sends a JSON-RPC POST request to the client RPC server at port 8551. | ||
| """ | ||
| payload = { | ||
| "jsonrpc": "2.0", | ||
| "method": method, | ||
| "params": params, | ||
| "id": 1, | ||
| } | ||
| headers = { | ||
| "Content-Type": "application/json", | ||
| "Authorization": f"Bearer {self.generate_jwt_token()}", | ||
| } | ||
| response = requests.post(self.url, json=payload, headers=headers) | ||
| response.raise_for_status() | ||
| return response.json().get("result") | ||
Oops, something went wrong.
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.
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.
We need to add
PyJWT==2.8.0(is this the right one?) tosetup.cfg.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.
Nice! This sounds like the move forward - I think currently its this way as we can apply each test case for every consume method.