Skip to content

Commit

Permalink
test providers
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Dec 20, 2023
1 parent 0865580 commit cbd1472
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
5 changes: 5 additions & 0 deletions integration_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,8 @@ def cluster(request, cronos, geth):
yield cronos_ws
else:
raise NotImplementedError


def pytest_generate_tests(metafunc):
if "provider" in metafunc.fixturenames:
metafunc.parametrize("provider", ["cronos", "geth"])
28 changes: 14 additions & 14 deletions integration_tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
)


def test_basic(cluster):
w3 = cluster.w3
def test_basic(provider, cronos, geth):
w3 = geth.w3 if provider == "geth" else cronos.w3
assert w3.eth.chain_id == 777


def test_send_transaction(cluster):
def test_send_transaction(provider, cronos, geth):
"test eth_sendTransaction api"
w3 = cluster.w3
w3 = geth.w3 if provider == "geth" else cronos.w3
txhash = w3.eth.send_transaction(
{
"from": ADDRS["validator"],
Expand All @@ -53,8 +53,8 @@ def test_send_transaction(cluster):
assert receipt.status == 1


def test_events(cluster, suspend_capture):
w3 = cluster.w3
def test_events(provider, cronos, geth):
w3 = geth.w3 if provider == "geth" else cronos.w3
erc20 = deploy_contract(
w3,
CONTRACTS["TestERC20A"],
Expand Down Expand Up @@ -524,8 +524,8 @@ def assert_receipt_transaction_and_block(w3, futures):
assert transaction["blockNumber"] == block["number"]


def test_exception(cluster):
w3 = cluster.w3
def test_exception(provider, cronos, geth):
w3 = geth.w3 if provider == "geth" else cronos.w3
contract = deploy_contract(
w3,
CONTRACTS["TestRevert"],
Expand All @@ -543,14 +543,14 @@ def test_exception(cluster):
assert 5 * (10**18) == contract.caller.query()


def test_refund_unused_gas_when_contract_tx_reverted(cluster):
def test_refund_unused_gas_when_contract_tx_reverted(provider, cronos, geth):
"""
Call a smart contract method that reverts with very high gas limit
Call tx receipt should be status 0 (fail)
Fee is gasUsed * effectiveGasPrice
"""
w3 = cluster.w3
w3 = geth.w3 if provider == "geth" else cronos.w3
contract = deploy_contract(w3, CONTRACTS["TestRevert"])
more_than_enough_gas = 1000000

Expand Down Expand Up @@ -594,13 +594,13 @@ def test_message_call(cronos):
assert len(receipt.logs) == iterations


def test_suicide(cluster):
def test_suicide(provider, cronos, geth):
"""
test compliance of contract suicide
- within the tx, after contract suicide, the code is still available.
- after the tx, the code is not available.
"""
w3 = cluster.w3
w3 = geth.w3 if provider == "geth" else cronos.w3
destroyee = deploy_contract(
w3,
contract_path("Destroyee", "TestSuicide.sol"),
Expand Down Expand Up @@ -747,11 +747,11 @@ def test_failed_transfer_tx(cronos):
assert receipt.gasUsed == rsp["gas"]


def test_log0(cluster):
def test_log0(provider, cronos, geth):
"""
test compliance of empty topics behavior
"""
w3 = cluster.w3
w3 = geth.w3 if provider == "geth" else cronos.w3
contract = deploy_contract(
w3,
Path(__file__).parent
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 -v -s test_basic.py"

0 comments on commit cbd1472

Please sign in to comment.