-
Notifications
You must be signed in to change notification settings - Fork 289
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
Add async support #83
Conversation
Undo accidental version bumps
This reverts commit a7ab393.
Codecov Report
@@ Coverage Diff @@
## master #83 +/- ##
==========================================
- Coverage 88.20% 87.41% -0.80%
==========================================
Files 25 32 +7
Lines 1450 1955 +505
==========================================
+ Hits 1279 1709 +430
- Misses 171 246 +75 |
Should be good to run the CI again. By the way, any idea why those two docstrings didn't show up when I ran |
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.
Hey @kevinheavey. Thank you for contributing. This PR looks great.
I think it would be better if we have clearer boundaries between the old synchronous client and the new async client so that this codebase is easier to maintain.
And that if someone decides to implement a client that supports websockets, they should not be cramming into the existing api.py
file nor the existing integration tests.
solana/rpc/api.py
Outdated
return resp | ||
|
||
|
||
class AsyncClient(_ClientCore): # pylint: disable=too-many-public-methods |
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.
Would it be possible to split into three different files?
- solana/rpc/core.py
- solana/rpc/api.cpy (old synchornous client)
- solana/rpc/async_api.py (new async client)
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.
Will do
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.
In the same spirit, I'll give AsyncToken its own file too
solana/rpc/providers/http.py
Outdated
|
||
|
||
class AsyncHTTPProvider(AsyncBaseProvider, _HTTPProviderCore): | ||
"""Async HTTP provider to interact with the http rpc endpoint.""" |
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.
Same here?
|
||
|
||
@pytest.mark.integration | ||
def test_request_air_drop(stubbed_sender, test_http_client): | ||
def test_request_air_drop(stubbed_sender, test_http_clients): |
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.
Can we test the async client separate from the old client? Having both synchronous and async tests in the same method makes maintenance more difficult.
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.
This is possible, but we'll have a lot of duplicated code without a big refactor of the test suite. Plus there are places where we just test that the response the async client received is the same as that of the sync client, and we'll lose that (without more refactoring).
To get this over the line I'll just duplicate all the old pre-async tests and make async versions of them. Your call if that's what you want
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.
Yes. Duplicate tests are fine, it's just less confusing. We can decide to refactor and reduce duplicates later.
Made those changes.
|
Forgot the linters, should work now |
Think pylint should be okay now |
Let's just disable |
Done. Got a good feeling about this one. Pylint is not complaining about anything I touched |
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.
Thanks, @kevinheavey. This is great!
Closes #80
Summary of changes:
AsyncClient
andAsyncToken
classes.test_get_identity
which I noticed wasn't testingget_identity
. Instead it was redundantly testingget_genesis_hash
.