generated from ApeWorX/project-template
-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for
.http_uri
and .ws_uri
in ProviderAPI v0.6.1…
…9 [APE-1381] (#65) Co-authored-by: Juliya Smith <jules@apeworx.io>
- Loading branch information
Showing
8 changed files
with
58 additions
and
39 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
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 |
---|---|---|
@@ -1,32 +1,28 @@ | ||
import pytest | ||
from ape import networks | ||
import websocket # type: ignore | ||
from ape.utils import ZERO_ADDRESS | ||
|
||
from ape_infura.provider import Infura | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"ecosystem,network", | ||
[ | ||
("ethereum", "mainnet"), | ||
("ethereum", "goerli"), | ||
("ethereum", "sepolia"), | ||
("arbitrum", "mainnet"), | ||
("arbitrum", "goerli"), | ||
("optimism", "mainnet"), | ||
("optimism", "goerli"), | ||
("polygon", "mainnet"), | ||
("polygon", "mumbai"), | ||
("linea", "mainnet"), | ||
("linea", "goerli"), | ||
], | ||
) | ||
def test_infura(ecosystem, network): | ||
ecosystem_cls = networks.get_ecosystem(ecosystem) | ||
network_cls = ecosystem_cls.get_network(network) | ||
with network_cls.use_provider("infura") as provider: | ||
assert isinstance(provider, Infura) | ||
assert provider.get_balance(ZERO_ADDRESS) > 0 | ||
assert provider.get_block(0) | ||
ecosystem_uri = "" if ecosystem == "ethereum" else f"{ecosystem}-" | ||
assert f"https://{ecosystem_uri}{network}.infura.io/v3/" in provider.uri | ||
def test_infura_http(provider): | ||
ecosystem = provider.network.ecosystem.name | ||
network = provider.network.name | ||
assert isinstance(provider, Infura) | ||
assert provider.http_uri.startswith("https") | ||
assert provider.get_balance(ZERO_ADDRESS) > 0 | ||
assert provider.get_block(0) | ||
ecosystem_uri = "" if ecosystem == "ethereum" else f"{ecosystem}-" | ||
assert f"https://{ecosystem_uri}{network}.infura.io/v3/" in provider.uri | ||
|
||
|
||
def test_infura_ws(provider): | ||
assert provider.ws_uri.startswith("wss") | ||
|
||
try: | ||
ws = websocket.WebSocket() | ||
ws.connect(provider.ws_uri) | ||
ws.close() | ||
|
||
except Exception as err: | ||
pytest.fail(f"Websocket URI not accessible. Reason: {err}") |