Skip to content

Commit

Permalink
test create_validator
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Dec 17, 2024
1 parent 3dbded4 commit eef37b5
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
2 changes: 1 addition & 1 deletion integration_tests/configs/default.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
},
validators: [{
coins: '1000000000000000000stake,10000000000000000000000basetcro',
coins: '2000000000000000000stake,10000000000000000000000basetcro',
staked: '1000000000000000000stake',
mnemonic: '${VALIDATOR1_MNEMONIC}',
client_config: {
Expand Down
48 changes: 47 additions & 1 deletion integration_tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from hexbytes import HexBytes
from pystarport import cluster, ports

from .cosmoscli import CosmosCLI, module_address
from .cosmoscli import DEFAULT_GAS_PRICE, CosmosCLI, module_address
from .network import Geth
from .utils import (
ADDRS,
Expand Down Expand Up @@ -946,6 +946,52 @@ def test_submit_send_enabled(cronos, tmp_path):
assert cli.query_bank_send(*denoms) == send_enable


def test_join_validator(cronos):
chain_id = cronos.config["chain_id"]
data = Path(cronos.base_dir).parent
clustercli = cluster.ClusterCLI(data, cmd="cronosd", chain_id=chain_id)
moniker = "new joined"
i = clustercli.create_node(moniker=moniker)
cli1 = clustercli.cosmos_cli(i)
staked = 1000000000000000000
amt = 50000000000000000
coin = f"{staked}stake,{amt}basetcro"
cli = cronos.cosmos_cli()
addr = cli1.address("validator")
res = cli.transfer(cli.address("validator"), addr, coin)

Check failure on line 961 in integration_tests/test_basic.py

View workflow job for this annotation

GitHub Actions / integration_tests (unmarked)

test_join_validator[True] AssertionError: Error: timed out waiting for transaction 21C2F22AFA2E726D5D5B065605823B4EB5D32F1D1A1FF52005F7F30D0F469B8B to be included in a block: internal logic error Usage: cronosd query wait-tx [hash] [flags] Aliases: wait-tx, event-query-tx-for Examples: By providing the transaction hash: $ cronosd q wait-tx [hash] Or, by piping a "tx" command: $ cronosd tx [flags] | cronosd q wait-tx Flags: --grpc-addr string the gRPC endpoint to use for this chain --grpc-insecure allow gRPC over insecure channels, if not the server must use TLS --height int Use a specific height to query state at (this can error if the node is pruning state) -h, --help help for wait-tx --node string <host>:<port> to CometBFT RPC interface for this chain (default "tcp://localhost:26657") -o, --output string Output format (text|json) (default "text") --timeout duration The maximum time to wait for the transaction to be included in a block (default 15s) Global Flags: --chain-id string Specify Chain ID for sending Tx --home string directory for config and data (default "/home/runner/.cronos") --keyring-backend string Select keyring's backend (default "os") --log_format string The logging format (json|plain) (default "plain") --log_level string The logging level (trace|debug|info|warn|error|fatal|panic|disabled or '*:<level>,<key>:<level>') (default "info") --log_no_color Disable colored logs --trace print out full stack trace on errors (cronosd query event-query-tx-for 21C2F22AFA2E726D5D5B065605823B4EB5D32F1D1A1FF52005F7F30D0F469B8B --home /tmp/pytest-of-runner/pytest-0/indexer0/cronos_777-1/node0)
assert res["code"] == 0
assert cli.balance(addr) == amt
# start the node
clustercli.supervisor.startProcess(f"{chain_id}-node{i}")
wait_for_block(clustercli.cosmos_cli(i), cli.block_height() + 1)
# wait for the new node to sync
wait_for_block(cli1, cli1.block_height())
count1 = len(cli1.validators())
# create validator tx
res = cli1.create_validator(
f"{staked}stake",
{
"moniker": moniker,
},
gas_prices=DEFAULT_GAS_PRICE,
)
assert res["code"] == 0
assert (
len(cli1.validators()) == count1 + 1
), "new validator should joined successfully"
val_addr = cli1.address("validator", bech="val")
val = cli1.validator(val_addr)
assert not val.get("jailed")
assert val["status"] == "BOND_STATUS_BONDED"
assert val["tokens"] == f"{staked}"
assert val["description"]["moniker"] == moniker
assert val["commission"]["commission_rates"] == {
"rate": "100000000000000000",
"max_rate": "200000000000000000",
"max_change_rate": "10000000000000000",
}


def test_block_stm_delete(cronos):
"""
this test case revealed a bug in block-stm,
Expand Down

0 comments on commit eef37b5

Please sign in to comment.