Skip to content

Commit

Permalink
test: integ
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Oct 5, 2023
1 parent a442e6e commit 975b01b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repos:
- id: isort

- repo: https://github.com/psf/black
rev: 23.7.0
rev: 23.9.1
hooks:
- id: black
name: black
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ A pull request represents the start of a discussion, and doesn't necessarily nee
If you are opening a work-in-progress pull request to verify that it passes CI tests, please consider
[marking it as a draft](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests#draft-pull-requests).

Join the Ethereum Python [Discord](https://discord.gg/PcEJ54yX) if you have any questions.
Join the ApeWorX [Discord](https://discord.gg/apeworx) if you have any questions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=51.1.1", "wheel", "setuptools_scm[toml]>=5.0"]
requires = ["setuptools>=51.1.1", "wheel", "setuptools_scm[toml]>=5.0,<8"]

[tool.mypy]
exclude = "build/"
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
"pytest-cov", # Coverage analyzer plugin
"pytest-mock", # For creating mocks
"hypothesis>=6.2.0,<7.0", # Strategy-based fuzzer
"websocket-client", # Used for web socket integration testing
],
"lint": [
"black>=23.7.0,<24", # auto-formatter and linter
"black>=23.9.1,<24", # auto-formatter and linter
"mypy>=1.5.1,<2", # Static type analyzer
"types-requests", # Needed due to mypy typeshed
"types-setuptools", # Needed due to mypy typeshed
Expand Down
50 changes: 26 additions & 24 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
import pytest
import websocket # type: ignore
from ape import networks
from ape.utils import ZERO_ADDRESS

from ape_alchemy import NETWORKS
from ape_alchemy.provider import Alchemy


@pytest.mark.parametrize(
"ecosystem,network",
[
("ethereum", "mainnet"),
("ethereum", "goerli"),
("ethereum", "sepolia"),
("arbitrum", "mainnet"),
("arbitrum", "goerli"),
("base", "mainnet"),
("base", "goerli"),
("optimism", "mainnet"),
("optimism", "goerli"),
("polygon", "mainnet"),
("polygon", "mumbai"),
],
)
def test_alchemy(ecosystem, network):
ecosystem_cls = networks.get_ecosystem(ecosystem)
network_cls = ecosystem_cls.get_network(network)
@pytest.fixture(params=[(name, net) for name, values in NETWORKS.items() for net in values])
def provider(request):
ecosystem_cls = networks.get_ecosystem(request.param[0])
network_cls = ecosystem_cls.get_network(request.param[1])
with network_cls.use_provider("alchemy") as provider:
assert provider.http_uri.startswith("https")
assert provider.ws_uri.startswith("wss")
assert isinstance(provider, Alchemy)
assert provider.get_balance(ZERO_ADDRESS) > 0
assert provider.get_block(0)
yield provider


def test_http(provider):
assert isinstance(provider, Alchemy)
assert provider.http_uri.startswith("https")
assert provider.get_balance(ZERO_ADDRESS) > 0
assert provider.get_block(0)


def test_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}")

0 comments on commit 975b01b

Please sign in to comment.