Skip to content

Commit

Permalink
feat: e2e test client update after IBC Client Expiration
Browse files Browse the repository at this point in the history
  • Loading branch information
omarsy committed Jan 26, 2025
1 parent b447d34 commit 1b248ee
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 9 deletions.
2 changes: 2 additions & 0 deletions tests/e2e/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
paramsproptypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ibctypes "github.com/cosmos/ibc-go/v7/modules/core/types"

teritoriparams "github.com/TERITORI/teritori-chain/app/params"
)
Expand All @@ -45,6 +46,7 @@ func init() {
cryptocodec.RegisterInterfaces(encodingConfig.InterfaceRegistry)
govv1types.RegisterInterfaces(encodingConfig.InterfaceRegistry)
govv1beta1types.RegisterInterfaces(encodingConfig.InterfaceRegistry)
ibctypes.RegisterInterfaces(encodingConfig.InterfaceRegistry)
paramsproptypes.RegisterInterfaces(encodingConfig.InterfaceRegistry)
paramsproptypes.RegisterLegacyAminoCodec(encodingConfig.Amino)

Expand Down
39 changes: 39 additions & 0 deletions tests/e2e/e2e_ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,27 @@ func (s *IntegrationTestSuite) createChannel() {
s.T().Logf("IBC transfer channel created between chains %s and %s", s.chainA.id, s.chainB.id)
}

func (s *IntegrationTestSuite) createClient(hostChain, referenceChain *chain) {
s.T().Logf("creating IBC Client between chains %s and %s", s.chainA.id, s.chainB.id)

ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
hermesCmd := []string{
hermesBinary,
"--json",
"create",
"client",
"--host-chain", hostChain.id,
"--reference-chain", referenceChain.id,
}

fmt.Printf("hermesCmd %+v", hermesCmd)
_, err := s.executeHermesCommand(ctx, hermesCmd)
s.Require().NoError(err, "failed to create IBC client between chains: %s", err)

s.T().Logf("IBC Client created between chains %s and %s", s.chainA.id, s.chainB.id)
}

// This function will complete the channel handshake in cases when ChanOpenInit was initiated
// by some transaction that was previously executed on the chain. For example,
// ICA MsgRegisterInterchainAccount will perform ChanOpenInit during its execution.
Expand Down Expand Up @@ -275,6 +296,24 @@ func (s *IntegrationTestSuite) testIBCTokenTransfer() {
})
}

func (s *IntegrationTestSuite) testIBCClientUpgrade() {
s.Run("upgrade_client_chainA", func() {
senderAddress, _ := s.chainA.validators[0].keyInfo.GetAddress()
sender := senderAddress.String()
chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp"))

time.Sleep(4 * time.Minute)
s.createClient(s.chainA, s.chainB)
time.Sleep(1 * time.Minute)

proposalCounter++
submitGovFlags := []string{"update-client", "07-tendermint-0", "07-tendermint-1", "--title", "IBCClientUpgrade", "--description", "IBC Client Upgrade", "--deposit", depositAmount.String()}
depositGovFlags := []string{strconv.Itoa(proposalCounter), depositAmount.String()}
voteGovFlags := []string{strconv.Itoa(proposalCounter), "yes"}
s.submitLegacyGovProposal(chainAAPIEndpoint, sender, proposalCounter, "IBCClientUpgrade", submitGovFlags, depositGovFlags, voteGovFlags, "vote", true)
})
}

/*
TestMultihopIBCTokenTransfer tests that sending an IBC transfer using the IBC Packet Forward Middleware accepts a port, channel and account address
Expand Down
69 changes: 63 additions & 6 deletions tests/e2e/e2e_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ const (
numberOfEvidences = 10
slashingShares int64 = 10000

proposalMaxTotalBypassFilename = "proposal_max_total_bypass.json"
proposalCommunitySpendFilename = "proposal_community_spend.json"
proposalLSMParamUpdateFilename = "proposal_lsm_param_update.json"
proposalBlocksPerEpochFilename = "proposal_blocks_per_epoch.json"
proposalFailExpedited = "proposal_fail_expedited.json"
proposalExpeditedSoftwareUpgrade = "proposal_expedited_software_upgrade.json"
proposalMaxTotalBypassFilename = "proposal_max_total_bypass.json"
proposalCommunitySpendFilename = "proposal_community_spend.json"
proposalLSMParamUpdateFilename = "proposal_lsm_param_update.json"
proposalBlocksPerEpochFilename = "proposal_blocks_per_epoch.json"
proposalFailExpedited = "proposal_fail_expedited.json"
proposalExpeditedSoftwareUpgrade = "proposal_expedited_software_upgrade.json"
proposalTendermintClientUpdate = "proposal_tendermint_client_update.json"
proposalTendermintClientMisbehaviour = "proposal_tendermint_client_misbehaviour.json"

// proposalAddConsumerChainFilename = "proposal_add_consumer.json"
// proposalRemoveConsumerChainFilename = "proposal_remove_consumer.json"
Expand Down Expand Up @@ -862,3 +864,58 @@ func configFile(filename string) string {
filepath := filepath.Join(teritoriConfigPath, filename)
return filepath
}

func (s *IntegrationTestSuite) writeGovClientUpdateProposal(c *chain, subjectClientID, substituteClientID string) {
body := `{
"messages": [
{
"@type": "/cosmos.gov.v1.MsgExecLegacyContent",
"content": {
"@type": "/ibc.core.client.v1.ClientUpdateProposal",
"title": "client update proposal",
"description": "This proposal is about udating the IBC Tendermint client %s, which references",
"subject_client_id": "%s",
"substitute_client_id": "%s"
},
"authority": "tori10d07y265gmmuvt4z0w9aw880jnsr700jckyvdr"
}
],
"deposit": "100utori",
"proposer": "sample proposer",
"metadata": "sample metadata",
"title": "client update proposal",
"summary": "client update proposal"
}`

body = fmt.Sprintf(body, subjectClientID, subjectClientID, substituteClientID)

err := writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalTendermintClientUpdate), []byte(body))
s.Require().NoError(err)
}

func (s *IntegrationTestSuite) writeGovClientMisbehaviourProposal(c *chain, clientID string) {
body := `{
"messages": [
{
"@type": "/cosmos.gov.v1.MsgExecLegacyContent",
"content": {
"@type": "/ibc.core.client.v1.MsgSubmitMisbehaviour",
"title": "client misbehaviour proposal",
"description": "This proposal is about submitting misbehaviour for the IBC Tendermint client %s",
"client_id": "%s"
},
"authority": "tori10d07y265gmmuvt4z0w9aw880jnsr700jckyvdr"
}
],
"deposit": "100utori",
"proposer": "sample proposer",
"metadata": "sample metadata",
"title": "client misbehaviour proposal",
"summary": "client misbehaviour proposal"
}`

body = fmt.Sprintf(body, clientID, clientID)

err := writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalTendermintClientMisbehaviour), []byte(body))
s.Require().NoError(err)
}
4 changes: 4 additions & 0 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,7 @@ func (s *IntegrationTestSuite) TestVesting() {
s.testContinuousVestingAccount(chainAAPI)
// s.testPeriodicVestingAccount(chainAAPI) TODO: add back when v0.45 adds the missing CLI command.
}
func (s *IntegrationTestSuite) TestZero() {
s.testIBCClientUpgrade()
s.testIBCTokenTransfer()
}
6 changes: 3 additions & 3 deletions tests/e2e/scripts/hermes_bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ max_gas = 6000000
gas_price = { price = 0.005, denom = 'utori' }
gas_multiplier = 1.5
clock_drift = '1m' # to accommodate docker containers
trusting_period = '14days'
trusting_period = '5m'
trust_threshold = { numerator = '1', denominator = '3' }
dynamic_gas_price = { enabled = true, multiplier = 1.3, max = 0.05 }
EOF
Expand Down Expand Up @@ -126,7 +126,7 @@ max_gas = 6000000
gas_price = { price = 0, denom = 'utori' }
gas_multiplier = 1.5
clock_drift = '1m' # to accommodate docker containers
trusting_period = '14days'
trusting_period = '5m'
trust_threshold = { numerator = '1', denominator = '3' }
dynamic_gas_price = { enabled = true, multiplier = 1.3, max = 0.05 }
Expand All @@ -144,7 +144,7 @@ max_gas = 6000000
gas_price = { price = 0, denom = 'utori' }
gas_multiplier = 1.5
clock_drift = '1m' # to accommodate docker containers
trusting_period = '14days'
trusting_period = '5m'
trust_threshold = { numerator = '1', denominator = '3' }
dynamic_gas_price = { enabled = true, multiplier = 1.3, max = 0.05 }
EOF
Expand Down

0 comments on commit 1b248ee

Please sign in to comment.