Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
keep cluster in module scope
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Nov 24, 2022
1 parent 4769ba2 commit 468ea2d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 43 deletions.
40 changes: 1 addition & 39 deletions tests/integration_tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from pathlib import Path

import pytest

from .network import setup_custom_ethermint, setup_ethermint, setup_geth
from .network import setup_ethermint, setup_geth


@pytest.fixture(scope="session")
Expand All @@ -11,48 +9,12 @@ def ethermint(tmp_path_factory):
yield from setup_ethermint(path, 26650)


@pytest.fixture(scope="session")
def ethermint_long_timeout_commit(tmp_path_factory):
path = tmp_path_factory.mktemp("long_timeout_commit")
yield from setup_ethermint(path, 26200, True)


@pytest.fixture(scope="session")
def ethermint_indexer(tmp_path_factory):
path = tmp_path_factory.mktemp("indexer")
yield from setup_custom_ethermint(
path, 26660, Path(__file__).parent / "configs/enable-indexer.jsonnet"
)


@pytest.fixture(scope="session")
def geth(tmp_path_factory):
path = tmp_path_factory.mktemp("geth")
yield from setup_geth(path, 8545)


@pytest.fixture(
scope="session", params=["ethermint", "geth", "ethermint-ws", "enable-indexer"]
)
def cluster(request, ethermint_long_timeout_commit, ethermint_indexer, geth):
"""
run on both ethermint and geth
"""
provider = request.param
if provider == "ethermint":
yield ethermint_long_timeout_commit
elif provider == "geth":
yield geth
elif provider == "ethermint-ws":
ethermint_ws = ethermint_long_timeout_commit.copy()
ethermint_ws.use_websocket()
yield ethermint_ws
elif provider == "enable-indexer":
yield ethermint_indexer
else:
raise NotImplementedError


@pytest.fixture(
scope="session", params=["ethermint", "ethermint-ws"]
)
Expand Down
39 changes: 39 additions & 0 deletions tests/integration_tests/test_filters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from pathlib import Path

import pytest
from web3 import Web3

from .network import setup_custom_ethermint, setup_ethermint
from .utils import (
ADDRS,
CONTRACTS,
Expand All @@ -11,6 +14,42 @@
)


@pytest.fixture(scope="module")
def custom_ethermint(tmp_path_factory):
path = tmp_path_factory.mktemp("filters")
yield from setup_ethermint(path, 26200, long_timeout_commit=True)


@pytest.fixture(scope="module")
def ethermint_indexer(tmp_path_factory):
path = tmp_path_factory.mktemp("indexer")
yield from setup_custom_ethermint(
path, 26660, Path(__file__).parent / "configs/enable-indexer.jsonnet"
)


@pytest.fixture(
scope="module", params=["ethermint", "geth", "ethermint-ws", "enable-indexer"]
)
def cluster(request, custom_ethermint, ethermint_indexer, geth):
"""
run on both ethermint and geth
"""
provider = request.param
if provider == "ethermint":
yield custom_ethermint
elif provider == "geth":
yield geth
elif provider == "ethermint-ws":
ethermint_ws = custom_ethermint.copy()
ethermint_ws.use_websocket()
yield ethermint_ws
elif provider == "enable-indexer":
yield ethermint_indexer
else:
raise NotImplementedError


def test_basic(cluster):
w3 = cluster.w3
assert w3.eth.chain_id == 9000
Expand Down
7 changes: 3 additions & 4 deletions tests/integration_tests/test_priority.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@


@pytest.fixture(scope="module")
def ethermint(tmp_path_factory):
yield from setup_ethermint(
tmp_path_factory.mktemp("priority"), 26200, long_timeout_commit=True
)
def custom_ethermint(tmp_path_factory):
path = tmp_path_factory.mktemp("priority")
yield from setup_ethermint(path, 26800, long_timeout_commit=True)


def effective_gas_price(tx, base_fee):
Expand Down

0 comments on commit 468ea2d

Please sign in to comment.