-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaound LlamaNodes.com issues (#152)
* Deal with custom LllamaNode replies
- Loading branch information
Showing
6 changed files
with
78 additions
and
13 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
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,23 @@ | ||
"""Fixes for quirks and features on LlamaNodes. | ||
- `LlamaNodes <https://llamanodes.com/>`__ runs RPC services at ``llamarpc.com`` | ||
- Their RPC nodes have some compatibility issues we address in this module | ||
See also :py:mod:`eth_defi.provider.broken_provider`. | ||
""" | ||
from requests import Response | ||
|
||
|
||
def is_llama_bad_grapql_reply(resp: Response): | ||
"""Is the web server response fake 404 response from llamarpc.com | ||
llamarpc.com web server does not know how to use HTTP 404 status code. | ||
See :py:func:`eth_defi.chain.has_graphql_support`. | ||
""" | ||
try: | ||
content = resp.json() | ||
return content.get("error").get("message") == "UserKey was not a ULID or UUID" | ||
except Exception: | ||
return 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,19 @@ | ||
"""LlamaNodes specific tests""" | ||
|
||
import os | ||
|
||
import pytest | ||
from web3 import Web3, HTTPProvider | ||
|
||
from eth_defi.chain import has_graphql_support | ||
|
||
JSON_RPC_LLAMA = os.environ.get("JSON_RPC_LLAMA") | ||
pytestmark = pytest.mark.skipif(not JSON_RPC_LLAMA, reason="This test needs LlamaNodes come node via JSON_RPC_LLAMA") | ||
|
||
|
||
def test_llama_is_bad(): | ||
"""Work around fake 404 response from llamarpc.com""" | ||
provider = HTTPProvider(JSON_RPC_LLAMA) | ||
web3 = Web3(provider) | ||
assert not has_graphql_support(provider) | ||
assert web3.eth.block_number > 1 |