Skip to content

Commit

Permalink
test providers with indirect param
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Dec 20, 2023
1 parent 0865580 commit c673b63
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion integration_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def geth(tmp_path_factory):
yield from setup_geth(path, 8545)


@pytest.fixture(scope="session", params=["cronos", "geth", "cronos-ws"])
@pytest.fixture(scope="session")
def cluster(request, cronos, geth):
"""
run on both cronos and geth
Expand Down
10 changes: 9 additions & 1 deletion integration_tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
ADDRS,
CONTRACTS,
KEYS,
PROVIDERS,
Greeter,
RevertTestContract,
approve_proposal,
Expand All @@ -34,11 +35,13 @@
)


@pytest.mark.parametrize("cluster", PROVIDERS, indirect=True)
def test_basic(cluster):
w3 = cluster.w3
assert w3.eth.chain_id == 777


@pytest.mark.parametrize("cluster", PROVIDERS, indirect=True)
def test_send_transaction(cluster):
"test eth_sendTransaction api"
w3 = cluster.w3
Expand All @@ -53,7 +56,8 @@ def test_send_transaction(cluster):
assert receipt.status == 1


def test_events(cluster, suspend_capture):
@pytest.mark.parametrize("cluster", PROVIDERS, indirect=True)
def test_events(cluster):
w3 = cluster.w3
erc20 = deploy_contract(
w3,
Expand Down Expand Up @@ -524,6 +528,7 @@ def assert_receipt_transaction_and_block(w3, futures):
assert transaction["blockNumber"] == block["number"]


@pytest.mark.parametrize("cluster", PROVIDERS, indirect=True)
def test_exception(cluster):
w3 = cluster.w3
contract = deploy_contract(
Expand All @@ -543,6 +548,7 @@ def test_exception(cluster):
assert 5 * (10**18) == contract.caller.query()


@pytest.mark.parametrize("cluster", PROVIDERS, indirect=True)
def test_refund_unused_gas_when_contract_tx_reverted(cluster):
"""
Call a smart contract method that reverts with very high gas limit
Expand Down Expand Up @@ -594,6 +600,7 @@ def test_message_call(cronos):
assert len(receipt.logs) == iterations


@pytest.mark.parametrize("cluster", PROVIDERS, indirect=True)
def test_suicide(cluster):
"""
test compliance of contract suicide
Expand Down Expand Up @@ -747,6 +754,7 @@ def test_failed_transfer_tx(cronos):
assert receipt.gasUsed == rsp["gas"]


@pytest.mark.parametrize("cluster", PROVIDERS, indirect=True)
def test_log0(cluster):
"""
test compliance of empty topics behavior
Expand Down
3 changes: 3 additions & 0 deletions integration_tests/test_filters.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from web3 import Web3

import pytest
from .utils import (
ADDRS,
CONTRACTS,
PROVIDERS,
deploy_contract,
send_transaction,
wait_for_new_blocks,
)


@pytest.mark.parametrize("cluster", PROVIDERS, indirect=True)
def test_pending_transaction_filter(cluster):
w3: Web3 = cluster.w3
flt = w3.eth.filter("pending")
Expand Down
2 changes: 2 additions & 0 deletions integration_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def contract_path(name, filename):
"IICAModule": Path(__file__).parent.parent / "build/IICAModule.abi",
}

PROVIDERS = ["cronos", "geth", "cronos-ws"]


def wait_for_fn(name, fn, *, timeout=240, interval=1):
for i in range(int(timeout / interval)):
Expand Down
2 changes: 1 addition & 1 deletion scripts/run-integration-tests
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ cd ../integration_tests/contracts
HUSKY_SKIP_INSTALL=1 npm install
npm run typechain
cd ..
nix-shell --run "pytest -n auto -v -s test_basic.py::test_basic"
nix-shell --run "pytest -n 1 -v -s test_basic.py"

0 comments on commit c673b63

Please sign in to comment.