|
11 | 11 | from hexbytes import HexBytes |
12 | 12 | from pystarport import cluster, ports |
13 | 13 |
|
14 | | -from .cosmoscli import CosmosCLI, module_address |
| 14 | +from .cosmoscli import DEFAULT_GAS_PRICE, CosmosCLI, module_address |
15 | 15 | from .network import Geth |
16 | 16 | from .utils import ( |
17 | 17 | ADDRS, |
@@ -946,6 +946,52 @@ def test_submit_send_enabled(cronos, tmp_path): |
946 | 946 | assert cli.query_bank_send(*denoms) == send_enable |
947 | 947 |
|
948 | 948 |
|
| 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 | + |
949 | 995 | def test_block_stm_delete(cronos): |
950 | 996 | """ |
951 | 997 | this test case revealed a bug in block-stm, |
|
0 commit comments