Skip to content

Commit

Permalink
upgrade incentive
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Oct 15, 2024
1 parent 8402c28 commit 5a3e1ea
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 23 deletions.
29 changes: 28 additions & 1 deletion integration_tests/configs/ibc.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ local default = {
name: 'ecosystem',
coins: '200cro',
},
{
name: 'community',
coins: '100cro',
},
{
name: 'signer2',
coins: '2000cro,100000000000ibcfee',
Expand All @@ -39,5 +43,28 @@ local validator = import 'validator.jsonnet';
'ibc-1': default {
validators: [validator { base_port: port } for port in [26750, 26760]],
},
relayer: {},
relayer: {
mode: {
clients: {
enabled: true,
refresh: true,
misbehaviour: true,
},
connections: {
enabled: true,
},
channels: {
enabled: true,
},
packets: {
enabled: true,
tx_confirmation: true,
},
},
rest: {
enabled: true,
host: '127.0.0.1',
port: 3000,
},
},
}
18 changes: 18 additions & 0 deletions integration_tests/ibc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,21 @@ def check_balance_change():
current = chains[1].balance(receiver, "basecro")
assert current == old_amt_receiver_base - fee_amount
return amount, packet_seq


def wait_for_check_channel_ready(cli, connid, channel_id, target="STATE_OPEN"):
print("wait for channel ready", channel_id, target)

def check_channel_ready():
channels = cli.ibc_query_channels(connid)["channels"]
try:
state = next(
channel["state"]
for channel in channels
if channel["channel_id"] == channel_id
)
except StopIteration:
return False
return state == target

wait_for_fn("channel ready", check_channel_ready)
38 changes: 35 additions & 3 deletions integration_tests/test_ibc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
from .ibc_utils import (
ibc_incentivized_transfer,
ibc_transfer_flow,
register_fee_payee,
start_and_wait_relayer,
wait_for_check_channel_ready,
)
from .utils import cluster_fixture
from .utils import approve_proposal, cluster_fixture, module_address

pytestmark = pytest.mark.ibc

Expand All @@ -28,9 +30,39 @@ def cluster(worker_index, pytestconfig, tmp_path_factory):
)


def test_ibc(cluster):
src_channel, dst_channel = start_and_wait_relayer(cluster, incentivized=True)
def test_ibc(cluster, tmp_path):
src_channel, dst_channel = start_and_wait_relayer(cluster)
ibc_transfer_flow(cluster, src_channel, dst_channel)
# upgrade to incentivized
src_chain = cluster["ibc-0"].cosmos_cli()
dst_chain = cluster["ibc-1"].cosmos_cli()
version = {"fee_version": "ics29-1", "app_version": "ics20-1"}
community = "community"
authority = module_address("gov")
connid = "connection-0"
channel_id = "channel-0"
deposit = "0.1cro"
proposal_src = src_chain.ibc_upgrade_channels(
version,
community,
deposit=deposit,
title="channel-upgrade-title",
summary="summary",
port_pattern="transfer",
channel_ids=channel_id,
)
proposal_src["deposit"] = deposit
proposal_src["messages"][0]["signer"] = authority
proposal = tmp_path / "proposal.json"
proposal.write_text(json.dumps(proposal_src))
rsp = src_chain.submit_gov_proposal(proposal, from_=community)
assert rsp["code"] == 0, rsp["raw_log"]
approve_proposal(
cluster["ibc-0"], rsp, msg=",/ibc.core.channel.v1.MsgChannelUpgradeInit"
)
wait_for_check_channel_ready(src_chain, connid, channel_id, "STATE_FLUSHCOMPLETE")
wait_for_check_channel_ready(src_chain, connid, channel_id)
register_fee_payee(src_chain, dst_chain)
ibc_incentivized_transfer(cluster)


Expand Down
20 changes: 1 addition & 19 deletions integration_tests/test_ica.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import requests
from pystarport import cluster as c

from .ibc_utils import search_target, wait_relayer_ready
from .ibc_utils import search_target, wait_for_check_channel_ready, wait_relayer_ready
from .utils import (
approve_proposal,
cluster_fixture,
Expand All @@ -28,24 +28,6 @@ def cluster(worker_index, pytestconfig, tmp_path_factory):
)


def wait_for_check_channel_ready(cli, connid, channel_id, target="STATE_OPEN"):
print("wait for channel ready", channel_id, target)

def check_channel_ready():
channels = cli.ibc_query_channels(connid)["channels"]
try:
state = next(
channel["state"]
for channel in channels
if channel["channel_id"] == channel_id
)
except StopIteration:
return False
return state == target

wait_for_fn("channel ready", check_channel_ready)


def assert_channel_open_init(rsp):
assert rsp["code"] == 0, rsp["raw_log"]
port_id, channel_id = next(
Expand Down

0 comments on commit 5a3e1ea

Please sign in to comment.