Skip to content

Commit eef37b5

Browse files
committed
test create_validator
1 parent 3dbded4 commit eef37b5

2 files changed

Lines changed: 48 additions & 2 deletions

File tree

integration_tests/configs/default.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
},
3232
},
3333
validators: [{
34-
coins: '1000000000000000000stake,10000000000000000000000basetcro',
34+
coins: '2000000000000000000stake,10000000000000000000000basetcro',
3535
staked: '1000000000000000000stake',
3636
mnemonic: '${VALIDATOR1_MNEMONIC}',
3737
client_config: {

integration_tests/test_basic.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from hexbytes import HexBytes
1212
from pystarport import cluster, ports
1313

14-
from .cosmoscli import CosmosCLI, module_address
14+
from .cosmoscli import DEFAULT_GAS_PRICE, CosmosCLI, module_address
1515
from .network import Geth
1616
from .utils import (
1717
ADDRS,
@@ -946,6 +946,52 @@ def test_submit_send_enabled(cronos, tmp_path):
946946
assert cli.query_bank_send(*denoms) == send_enable
947947

948948

949+
def test_join_validator(cronos):
950+
chain_id = cronos.config["chain_id"]
951+
data = Path(cronos.base_dir).parent
952+
clustercli = cluster.ClusterCLI(data, cmd="cronosd", chain_id=chain_id)
953+
moniker = "new joined"
954+
i = clustercli.create_node(moniker=moniker)
955+
cli1 = clustercli.cosmos_cli(i)
956+
staked = 1000000000000000000
957+
amt = 50000000000000000
958+
coin = f"{staked}stake,{amt}basetcro"
959+
cli = cronos.cosmos_cli()
960+
addr = cli1.address("validator")
961+
res = cli.transfer(cli.address("validator"), addr, coin)
962+
assert res["code"] == 0
963+
assert cli.balance(addr) == amt
964+
# start the node
965+
clustercli.supervisor.startProcess(f"{chain_id}-node{i}")
966+
wait_for_block(clustercli.cosmos_cli(i), cli.block_height() + 1)
967+
# wait for the new node to sync
968+
wait_for_block(cli1, cli1.block_height())
969+
count1 = len(cli1.validators())
970+
# create validator tx
971+
res = cli1.create_validator(
972+
f"{staked}stake",
973+
{
974+
"moniker": moniker,
975+
},
976+
gas_prices=DEFAULT_GAS_PRICE,
977+
)
978+
assert res["code"] == 0
979+
assert (
980+
len(cli1.validators()) == count1 + 1
981+
), "new validator should joined successfully"
982+
val_addr = cli1.address("validator", bech="val")
983+
val = cli1.validator(val_addr)
984+
assert not val.get("jailed")
985+
assert val["status"] == "BOND_STATUS_BONDED"
986+
assert val["tokens"] == f"{staked}"
987+
assert val["description"]["moniker"] == moniker
988+
assert val["commission"]["commission_rates"] == {
989+
"rate": "100000000000000000",
990+
"max_rate": "200000000000000000",
991+
"max_change_rate": "10000000000000000",
992+
}
993+
994+
949995
def test_block_stm_delete(cronos):
950996
"""
951997
this test case revealed a bug in block-stm,

0 commit comments

Comments
 (0)