-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Problem: query with iavl legacy iterator is not tested
- Loading branch information
Showing
6 changed files
with
267 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
local config = import 'default.jsonnet'; | ||
|
||
config { | ||
'cronos_777-1'+: { | ||
'app-config'+: { | ||
'app-db-backend': 'rocksdb', | ||
'iavl-lazy-loading':: super['iavl-lazy-loading'], | ||
}, | ||
validators: [super.validators[0] { | ||
'app-config'+: { | ||
store: { | ||
streamers: ['versiondb'], | ||
memiavl:: super.memiavl, | ||
versiondb:: super.versiondb, | ||
}, | ||
}, | ||
}] + super.validators[1:], | ||
genesis+: { | ||
consensus_params: { | ||
block: { | ||
max_bytes: '1048576', | ||
max_gas: '81500000', | ||
}, | ||
}, | ||
app_state+: { | ||
gov+: { | ||
params+: { | ||
expedited_voting_period:: super['expedited_voting_period'], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
let | ||
pkgs = import ../../nix { }; | ||
fetchFlake = | ||
repo: rev: | ||
(pkgs.flake-compat { | ||
src = { | ||
outPath = builtins.fetchTarball "https://github.com/${repo}/archive/${rev}.tar.gz"; | ||
inherit rev; | ||
shortRev = builtins.substring 0 7 rev; | ||
}; | ||
}).defaultNix; | ||
# release/v1.3.x | ||
releasedGenesis = | ||
(fetchFlake "crypto-org-chain/cronos" "e1d819c862b30f0ce978baf2addb12516568639e").default; | ||
current = pkgs.callPackage ../../. { }; | ||
in | ||
pkgs.linkFarm "upgrade-test-package" [ | ||
{ | ||
name = "genesis"; | ||
path = releasedGenesis; | ||
} | ||
{ | ||
name = "v1.4"; | ||
path = current; | ||
} | ||
] |
17 changes: 17 additions & 0 deletions
17
integration_tests/contracts/contracts/CheckpointOracle.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.4; | ||
|
||
contract CheckpointOracle { | ||
mapping(address => bool) admins; | ||
address[] adminList; | ||
uint64 sectionIndex; | ||
uint height; | ||
bytes32 hash; | ||
uint sectionSize; | ||
uint processConfirms; | ||
uint threshold; | ||
|
||
function VotingThreshold() public view returns (uint) { | ||
return threshold; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import shutil | ||
import stat | ||
import subprocess | ||
from concurrent.futures import ThreadPoolExecutor, as_completed | ||
from contextlib import contextmanager | ||
from pathlib import Path | ||
|
||
import pytest | ||
import requests | ||
from pystarport import ports | ||
|
||
from .network import setup_custom_cronos | ||
from .utils import CONTRACTS, deploy_contract, do_upgrade, post_init | ||
|
||
pytestmark = pytest.mark.upgrade | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def custom_cronos(tmp_path_factory): | ||
yield from setup_cronos_test(tmp_path_factory) | ||
|
||
|
||
def get_txs(base_port, end): | ||
port = ports.rpc_port(base_port) | ||
res = [] | ||
for h in range(1, end): | ||
url = f"http://127.0.0.1:{port}/block_results?height={h}" | ||
res.append(requests.get(url).json().get("result")["txs_results"]) | ||
return res | ||
|
||
|
||
def setup_cronos_test(tmp_path_factory): | ||
path = tmp_path_factory.mktemp("upgrade") | ||
port = 27100 | ||
nix_name = "upgrade-test-package-recent" | ||
cfg_name = "cosmovisor_recent" | ||
configdir = Path(__file__).parent | ||
cmd = [ | ||
"nix-build", | ||
configdir / f"configs/{nix_name}.nix", | ||
] | ||
print(*cmd) | ||
subprocess.run(cmd, check=True) | ||
|
||
# copy the content so the new directory is writable. | ||
upgrades = path / "upgrades" | ||
shutil.copytree("./result", upgrades) | ||
mod = stat.S_IRWXU | ||
upgrades.chmod(mod) | ||
for d in upgrades.iterdir(): | ||
d.chmod(mod) | ||
|
||
# init with genesis binary | ||
with contextmanager(setup_custom_cronos)( | ||
path, | ||
port, | ||
configdir / f"configs/{cfg_name}.jsonnet", | ||
post_init=post_init, | ||
chain_binary=str(upgrades / "genesis/bin/cronosd"), | ||
) as cronos: | ||
yield cronos | ||
|
||
|
||
def call(port, params): | ||
url = f"http://127.0.0.1:{ports.evmrpc_port(port)}" | ||
rsp = requests.post(url, json=params) | ||
assert rsp.status_code == 200 | ||
return rsp.json() | ||
|
||
|
||
def call_check(c, address): | ||
batch = 10 | ||
concurrent = 10 | ||
base_port = c.base_port(0) | ||
param = { | ||
"jsonrpc": "2.0", | ||
"method": "eth_call", | ||
"params": [ | ||
{ | ||
"data": "0x0be5b6ba", | ||
"to": address, | ||
}, | ||
"latest", | ||
], | ||
"id": 1, | ||
} | ||
params = [] | ||
for _ in range(batch): | ||
params.append(param) | ||
with ThreadPoolExecutor(concurrent) as executor: | ||
tasks = [executor.submit(call, base_port, params) for _ in range(0, concurrent)] | ||
results = [future.result() for future in as_completed(tasks)] | ||
assert len(results) == concurrent | ||
|
||
|
||
def test_cosmovisor_upgrade(custom_cronos): | ||
c = custom_cronos | ||
cli = c.cosmos_cli() | ||
cli = do_upgrade(c, "v1.4", cli.block_height() + 15) | ||
res = deploy_contract(c.w3, CONTRACTS["CheckpointOracle"]) | ||
[call_check(c, res.address) for _ in range(10)] |
Oops, something went wrong.