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

tests: make integration test more stable #1488

Merged
merged 41 commits into from
Dec 23, 2022
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
d0e290f
wait new blk right before send tx
mmsqe Nov 22, 2022
bf43d11
larger timeout_commit for priority test
mmsqe Nov 22, 2022
017c443
larger timeout_commit for mempool related test
mmsqe Nov 23, 2022
4769ba2
mv chain id test to cluster used test
mmsqe Nov 23, 2022
468ea2d
keep cluster in module scope
mmsqe Nov 23, 2022
4629205
sync gomod2nix
mmsqe Nov 24, 2022
4b8a4e6
adjust timeout_commit
mmsqe Nov 24, 2022
3515a3d
rm prune all in indexer config
mmsqe Nov 28, 2022
1509f32
add missing min_gas_multiplier
mmsqe Nov 28, 2022
5d5b761
wait 1 more blk in upgrade
mmsqe Nov 28, 2022
df0ecc9
only keep 2 validators
mmsqe Nov 28, 2022
c02f04b
add retry for grpc_eth_call
mmsqe Nov 28, 2022
ac41f32
wait 1 block before stop
mmsqe Nov 28, 2022
30b0c61
fix lint
mmsqe Nov 28, 2022
f4a106d
disable recheck
mmsqe Nov 30, 2022
ad876a0
bump up upgrade
mmsqe Nov 30, 2022
9bda14d
Merge branch 'main' into stable_test
mmsqe Nov 30, 2022
6ffe847
sync gomod2nix
mmsqe Nov 30, 2022
ba3bfc8
Apply suggestions from code review
mmsqe Nov 30, 2022
91bc698
Apply suggestions from code review
mmsqe Nov 30, 2022
3c16925
Merge branch 'main' into stable_test
mmsqe Nov 30, 2022
60c4328
append node log
mmsqe Dec 1, 2022
c3ad838
Merge branch 'main' into stable_test
mmsqe Dec 1, 2022
5a625fd
fix lint
mmsqe Dec 1, 2022
77e9990
expect less gas after ecd76396eb55dc44535842018c5f13f234af7da3
mmsqe Dec 1, 2022
9a40293
Merge branch 'main' into stable_test
fedekunze Dec 2, 2022
5a7283a
Merge branch 'main' into stable_test
fedekunze Dec 5, 2022
12385ea
allow retry continue on empty rsp
mmsqe Dec 5, 2022
a8d8d5e
Merge branch 'main' into stable_test
mmsqe Dec 5, 2022
e49f98c
update gomod2nix
facs95 Dec 8, 2022
58d3add
fix flake
facs95 Dec 8, 2022
02e611f
Merge branch 'main' into stable_test
facs95 Dec 8, 2022
89f92ea
mod tidy
mmsqe Dec 9, 2022
86eb2c3
keep grpc only test
mmsqe Dec 9, 2022
fc91abe
Merge branch 'main' into stable_test
mmsqe Dec 9, 2022
b1c72e2
Merge branch 'main' into stable_test
mmsqe Dec 16, 2022
fa34ce9
Merge branch 'main' into stable_test
mmsqe Dec 19, 2022
71472c2
Merge branch 'main' into stable_test
facs95 Dec 22, 2022
6e45dc0
tests(integration): enable recheck tx mode
GAtom22 Dec 22, 2022
7845edf
Merge pull request #5 from GAtom22/add-recheck
mmsqe Dec 23, 2022
673093d
update gomod2nix
facs95 Dec 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ schema = 3
version = "v1.0.0-beta.7"
hash = "sha256-XblGvIx6Wvvq6wggXjp+KbeJGXoe7AZH7hXEdauCezU="
[mod."cosmossdk.io/math"]
version = "v1.0.0-beta.3"
hash = "sha256-lTQ27ZlL+kWlc+S//sJmyiOwaf9qS+YLv61I4OXi9XE="
version = "v1.0.0-beta.4"
hash = "sha256-UYdq/46EubyjxkldGike8FlwJLWGCB576VB7th285ao="
[mod."filippo.io/edwards25519"]
version = "v1.0.0-rc.1"
hash = "sha256-3DboBqby2ejRU33FG96Z8JF5AJ8HP2rC/v++VyoQ2LQ="
Expand Down
5 changes: 3 additions & 2 deletions tests/integration_tests/configs/cosmovisor.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ local config = import 'default.jsonnet';

config {
'ethermint_9000-1'+: {
'app-config'+: {
'minimum-gas-prices': '100000000000aphoton',
},
genesis+: {
app_state+: {
feemarket+: {
params+: {
no_base_fee: false,
base_fee:: super.base_fee,
initial_base_fee: super.base_fee,
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
},
},
},
Expand Down
5 changes: 1 addition & 4 deletions tests/integration_tests/configs/default.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
cmd: 'ethermintd',
'start-flags': '--trace',
config: {
consensus: {
// larger timeout for more stable mempool tests
timeout_commit: '2s',
},
mempool: {
// use v1 mempool to enable tx prioritization
version: 'v1',
recheck: false,
mmsqe marked this conversation as resolved.
Show resolved Hide resolved
mmsqe marked this conversation as resolved.
Show resolved Hide resolved
},
},
'app-config': {
Expand Down
13 changes: 9 additions & 4 deletions tests/integration_tests/configs/enable-indexer.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@ config {
},
},
'app-config'+: {
pruning: 'everything',
'state-sync'+: {
'snapshot-interval': 0,
},
'json-rpc'+: {
'enable-indexer': true,
},
},
genesis+: {
app_state+: {
feemarket+: {
params+: {
min_gas_multiplier: '0',
},
},
},
},
},
}
11 changes: 11 additions & 0 deletions tests/integration_tests/configs/long_timeout_commit.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
local default = import 'default.jsonnet';

default {
'ethermint_9000-1'+: {
config+: {
consensus+: {
timeout_commit: '5s',
},
},
},
}
9 changes: 9 additions & 0 deletions tests/integration_tests/configs/pruned_node.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,14 @@ config {
'snapshot-interval': 0,
},
},
genesis+: {
app_state+: {
feemarket+: {
params+: {
min_gas_multiplier: '0',
},
},
},
},
},
}
2 changes: 1 addition & 1 deletion tests/integration_tests/configs/rollback-test.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local config = import 'default.jsonnet';

config {
'ethermint_9000-1'+: {
validators: super.validators + [{
validators: super.validators[0:1] + [{
name: 'fullnode',
}],
},
Expand Down
4 changes: 2 additions & 2 deletions tests/integration_tests/configs/upgrade-test-package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ let
released = pkgs.buildGo118Module rec {
name = "ethermintd";
# the commit before https://github.com/evmos/ethermint/pull/943
src = fetchEthermint "f21592ebfe74da7590eb42ed926dae970b2a9a3f";
src = fetchEthermint "8866ae0ffd67a104e9d1cf4e50fba8391dda6c45";
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
subPackages = [ "cmd/ethermintd" ];
vendorSha256 = "sha256-ABm5t6R/u2S6pThGrgdsqe8n3fH5tIWw7a57kxJPbYw=";
vendorSha256 = "sha256-oDtMamNlwe/393fZd+RNtRy6ipWpusbco8Xg1ZuKWYw=";
doCheck = false;
};
current = pkgs.callPackage ../../../. { };
Expand Down
34 changes: 1 addition & 33 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,42 +9,12 @@ def ethermint(tmp_path_factory):
yield from setup_ethermint(path, 26650)


@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, ethermint_indexer, geth):
"""
run on both ethermint and geth
"""
provider = request.param
if provider == "ethermint":
yield ethermint
elif provider == "geth":
yield geth
elif provider == "ethermint-ws":
ethermint_ws = ethermint.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
10 changes: 7 additions & 3 deletions tests/integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from pystarport.utils import build_cli_args_safe, interact

DEFAULT_GAS_PRICE = "5000000000000aphoton"
DEFAULT_GAS = "250000"


class ChainCommand:
Expand Down Expand Up @@ -636,16 +637,19 @@ def edit_validator(
)

def gov_propose(self, proposer, kind, proposal, **kwargs):
method = "submit-legacy-proposal"
kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE)
kwargs.setdefault("gas", DEFAULT_GAS)
if kind == "software-upgrade":
return json.loads(
self.raw(
"tx",
"gov",
"submit-proposal",
method,
kind,
proposal["name"],
"-y",
"--no-validate",
from_=proposer,
# content
title=proposal.get("title"),
Expand All @@ -664,7 +668,7 @@ def gov_propose(self, proposer, kind, proposal, **kwargs):
self.raw(
"tx",
"gov",
"submit-proposal",
method,
kind,
"-y",
from_=proposer,
Expand All @@ -685,7 +689,7 @@ def gov_propose(self, proposer, kind, proposal, **kwargs):
self.raw(
"tx",
"gov",
"submit-proposal",
method,
kind,
fp.name,
"-y",
Expand Down
8 changes: 6 additions & 2 deletions tests/integration_tests/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ def __init__(self, w3):
self.w3 = w3


def setup_ethermint(path, base_port):
cfg = Path(__file__).parent / "configs/default.jsonnet"
def setup_ethermint(path, base_port, long_timeout_commit=False):
cfg = Path(__file__).parent / (
"configs/default.jsonnet"
if long_timeout_commit
else "configs/long_timeout_commit.jsonnet"
)
yield from setup_custom_ethermint(path, base_port, cfg)


Expand Down
3 changes: 0 additions & 3 deletions tests/integration_tests/test_basic.py

This file was deleted.

46 changes: 46 additions & 0 deletions tests/integration_tests/test_filters.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,58 @@
from pathlib import Path

import pytest
from web3 import Web3

from .network import setup_custom_ethermint, setup_ethermint
from .utils import (
ADDRS,
CONTRACTS,
deploy_contract,
send_successful_transaction,
send_transaction,
w3_wait_for_new_blocks,
)


@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):
mmsqe marked this conversation as resolved.
Show resolved Hide resolved
"""
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


def test_pending_transaction_filter(cluster):
Expand All @@ -17,6 +62,7 @@ def test_pending_transaction_filter(cluster):
# without tx
assert flt.get_new_entries() == [] # GetFilterChanges

w3_wait_for_new_blocks(w3, 1, sleep=0.1)
# with tx
txhash = send_successful_transaction(w3)
assert txhash in flt.get_new_entries()
Expand Down
37 changes: 24 additions & 13 deletions tests/integration_tests/test_grpc_only.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import base64
import json
import subprocess
import time
from pathlib import Path

import pytest
Expand All @@ -13,6 +14,7 @@
decode_bech32,
deploy_contract,
supervisorctl,
wait_for_block,
wait_for_port,
)

Expand Down Expand Up @@ -58,33 +60,43 @@ def test_grpc_mode(custom_ethermint):
"to": contract.address,
"data": contract.encodeABI(fn_name="currentChainID"),
}
api_port = ports.api_port(custom_ethermint.base_port(2))
api_port = ports.api_port(custom_ethermint.base_port(1))
# in normal mode, grpc query works even if we don't pass chain_id explicitly
rsp = grpc_eth_call(api_port, msg)
print(rsp)
assert "code" not in rsp, str(rsp)
assert 9000 == int.from_bytes(base64.b64decode(rsp["ret"].encode()), "big")

success = False
for i in range(3):
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
rsp = grpc_eth_call(api_port, msg)
print(i, rsp)
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
assert "code" not in rsp, str(rsp)
ret = rsp["ret"]
valid = ret is not None
if valid and 9000 == int.from_bytes(base64.b64decode(ret.encode()), "big"):
success = True
break
time.sleep(1)
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
assert success
# wait 1 block before stop
for i in range(2):
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
wait_for_block(custom_ethermint.cosmos_cli(i), 1)
supervisorctl(
custom_ethermint.base_dir / "../tasks.ini", "stop", "ethermint_9000-1-node2"
custom_ethermint.base_dir / "../tasks.ini", "stop", "ethermint_9000-1-node1"
)

# run grpc-only mode directly with existing chain state
with (custom_ethermint.base_dir / "node2.log").open("w") as logfile:
with (custom_ethermint.base_dir / "node1-new.log").open("w") as logfile:
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
proc = subprocess.Popen(
[
"ethermintd",
"start",
"--grpc-only",
"--home",
custom_ethermint.base_dir / "node2",
custom_ethermint.base_dir / "node1",
],
stdout=logfile,
stderr=subprocess.STDOUT,
)
try:
# wait for grpc and rest api ports
grpc_port = ports.grpc_port(custom_ethermint.base_port(2))
grpc_port = ports.grpc_port(custom_ethermint.base_port(1))
wait_for_port(grpc_port)
wait_for_port(api_port)

Expand All @@ -99,9 +111,8 @@ def test_grpc_mode(custom_ethermint):
assert "validator does not exist" in rsp["message"]

# pass the first validator's consensus address to grpc query
cons_addr = decode_bech32(
custom_ethermint.cosmos_cli(0).consensus_address()
)
addr = custom_ethermint.cosmos_cli(0).consensus_address()
cons_addr = decode_bech32(addr)

# should work with both chain_id and proposer_address set
rsp = grpc_eth_call(
Expand Down
Loading