Skip to content

Commit

Permalink
tests: enable v50 e2e tests (#1391)
Browse files Browse the repository at this point in the history
* deps:fix: bump versions; fix consumer module

* e2e: enable running tests [tests not fully functional]

* e2e: fix consumer; partially fix Dockerfile [hermes broken]

* e2e: fix hermes config and docker
  • Loading branch information
MSalopek authored Nov 6, 2023
1 parent b2222de commit a356b4f
Show file tree
Hide file tree
Showing 20 changed files with 172 additions and 74 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1


FROM golang:1.20-alpine AS is-builder
FROM golang:1.21-alpine AS is-builder

ENV PACKAGES curl make git libc-dev bash gcc linux-headers
RUN apk add --no-cache $PACKAGES
Expand Down Expand Up @@ -29,7 +29,7 @@ RUN go mod tidy
RUN make install

# Get Hermes build
FROM ghcr.io/informalsystems/hermes:1.4.1 AS hermes-builder
FROM --platform=linux/amd64 ghcr.io/informalsystems/hermes:v1.7.0 AS hermes-builder

# Get CometMock
FROM ghcr.io/informalsystems/cometmock:v0.37.x as cometmock-builder
Expand Down
1 change: 1 addition & 0 deletions app/consumer/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ func New(
paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey,
capabilitytypes.StoreKey, feegrant.StoreKey, authzkeeper.StoreKey,
consensusparamtypes.StoreKey,
ibcconsumertypes.StoreKey,
)
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
Expand Down
10 changes: 8 additions & 2 deletions cmd/interchain-security-cd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/client/pruning"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/server"
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
Expand Down Expand Up @@ -86,10 +87,15 @@ func NewRootCmd() *cobra.Command {
}

initRootCmd(rootCmd, encodingConfig)
if err := tempApp.AutoCliOpts().EnhanceRootCommand(rootCmd); err != nil {
// autocli opts
autoCliOpts := tempApp.AutoCliOpts()
initClientCtx, _ = config.ReadFromClientConfig(initClientCtx)
autoCliOpts.Keyring, _ = keyring.NewAutoCLIKeyring(initClientCtx.Keyring)
autoCliOpts.ClientCtx = initClientCtx

if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil {
panic(err)
}

return rootCmd
}

Expand Down
5 changes: 5 additions & 0 deletions proto/interchain_security/ccv/provider/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ service Msg {
message MsgAssignConsumerKey {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
option (cosmos.msg.v1.signer) = "signer";

// The chain id of the consumer chain to assign a consensus public key to
string chain_id = 1;
// The validator address on the provider
Expand All @@ -28,6 +30,9 @@ message MsgAssignConsumerKey {
// in json string format corresponding to proto-any, ex:
// `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}`
string consumer_key = 3;

// signer address
string signer = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

message MsgAssignConsumerKeyResponse {}
6 changes: 3 additions & 3 deletions tests/e2e/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ func (tr *TestRun) voteGovProposal(

wg.Wait()
// wait for inclusion in a block -> '--broadcast-mode block' is deprecated
tr.waitBlocks(action.chain, 1, 10*time.Second)
tr.waitBlocks(action.chain, 2, 10*time.Second)
tr.WaitTime(time.Duration(tr.chainConfigs[action.chain].votingWaitTime) * time.Second)
}

Expand Down Expand Up @@ -659,7 +659,7 @@ rpc_addr = "%s"
rpc_timeout = "10s"
store_prefix = "ibc"
trusting_period = "14days"
websocket_addr = "%s"
event_source = { mode = "push", url = "%s", batch_delay = "500ms" }
[chains.gas_price]
denom = "stake"
Expand Down Expand Up @@ -1888,7 +1888,7 @@ func (tr TestRun) assignConsumerPubKey(action assignConsumerPubKeyAction, verbos
tr.getValidatorNode(chainID("provi"), action.validator),
gas,
)

fmt.Println(assignKey)
//#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments.
cmd := exec.Command("docker", "exec",
tr.containerConfig.instanceName,
Expand Down
5 changes: 5 additions & 0 deletions tests/e2e/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ func SlashThrottleTestRun() TestRun {
ipPrefix: "7.7.7",
votingWaitTime: 20,
genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " +
".app_state.gov.params.expedited_voting_period = \"10s\" | " +
// Custom slashing parameters for testing validator downtime functionality
// See https://docs.cosmos.network/main/modules/slashing/04_begin_block.html#uptime-tracking
".app_state.slashing.params.signed_blocks_window = \"10\" | " +
Expand Down Expand Up @@ -213,6 +214,7 @@ func DefaultTestRun() TestRun {
ipPrefix: "7.7.7",
votingWaitTime: 20,
genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " +
".app_state.gov.params.expedited_voting_period = \"10s\" | " +
// Custom slashing parameters for testing validator downtime functionality
// See https://docs.cosmos.network/main/modules/slashing/04_begin_block.html#uptime-tracking
".app_state.slashing.params.signed_blocks_window = \"10\" | " +
Expand Down Expand Up @@ -270,6 +272,7 @@ func DemocracyTestRun(allowReward bool) TestRun {
ipPrefix: "7.7.7",
votingWaitTime: 20,
genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " +
".app_state.gov.params.expedited_voting_period = \"10s\" | " +
// Custom slashing parameters for testing validator downtime functionality
// See https://docs.cosmos.network/main/modules/slashing/04_begin_block.html#uptime-tracking
".app_state.slashing.params.signed_blocks_window = \"10\" | " +
Expand Down Expand Up @@ -310,6 +313,7 @@ func MultiConsumerTestRun() TestRun {
ipPrefix: "7.7.7",
votingWaitTime: 20,
genesisChanges: ".app_state.gov.params.voting_period = \"30s\" | " +
".app_state.gov.params.expedited_voting_period = \"10s\" | " +
// Custom slashing parameters for testing validator downtime functionality
// See https://docs.cosmos.network/main/modules/slashing/04_begin_block.html#uptime-tracking
".app_state.slashing.params.signed_blocks_window = \"10\" | " +
Expand Down Expand Up @@ -365,6 +369,7 @@ func ChangeoverTestRun() TestRun {
ipPrefix: "7.7.7",
votingWaitTime: 20,
genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " +
".app_state.gov.params.expedited_voting_period = \"10s\" | " +
// Custom slashing parameters for testing validator downtime functionality
// See https://docs.cosmos.network/main/modules/slashing/04_begin_block.html#uptime-tracking
".app_state.slashing.params.signed_blocks_window = \"10\" | " +
Expand Down
46 changes: 26 additions & 20 deletions tests/e2e/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,14 +384,15 @@ func (tr TestRun) getProposal(chain chainID, proposal uint) Proposal {
log.Fatal(err, "\n", string(bz))
}

propType := gjson.Get(string(bz), `messages.0.content.@type`).String()
deposit := gjson.Get(string(bz), `total_deposit.#(denom=="stake").amount`).Uint()
status := gjson.Get(string(bz), `status`).String()
propType := gjson.Get(string(bz), `proposal.messages.0.value.content.type`).String()
rawContent := gjson.Get(string(bz), `proposal.messages.0.value.content.value`)
deposit := gjson.Get(string(bz), `proposal.total_deposit.#(denom=="stake").amount`).Uint()
status := gjson.Get(string(bz), `proposal.status`).String()

switch propType {
case "/cosmos.gov.v1beta1.TextProposal":
title := gjson.Get(string(bz), `content.title`).String()
description := gjson.Get(string(bz), `content.description`).String()
title := rawContent.Get("title").String()
description := rawContent.Get("description").String()

return TextProposal{
Deposit: uint(deposit),
Expand All @@ -400,8 +401,8 @@ func (tr TestRun) getProposal(chain chainID, proposal uint) Proposal {
Description: description,
}
case "/interchain_security.ccv.provider.v1.ConsumerAdditionProposal":
chainId := gjson.Get(string(bz), `messages.0.content.chain_id`).String()
spawnTime := gjson.Get(string(bz), `messages.0.content.spawn_time`).Time().Sub(tr.containerConfig.now)
chainId := rawContent.Get("chain_id").String()
spawnTime := rawContent.Get("spawn_time").Time().Sub(tr.containerConfig.now)

var chain chainID
for i, conf := range tr.chainConfigs {
Expand All @@ -417,13 +418,13 @@ func (tr TestRun) getProposal(chain chainID, proposal uint) Proposal {
Chain: chain,
SpawnTime: int(spawnTime.Milliseconds()),
InitialHeight: clienttypes.Height{
RevisionNumber: gjson.Get(string(bz), `messages.0.content.initial_height.revision_number`).Uint(),
RevisionHeight: gjson.Get(string(bz), `messages.0.content.initial_height.revision_height`).Uint(),
RevisionNumber: rawContent.Get("initial_height.revision_number").Uint(),
RevisionHeight: rawContent.Get("initial_height.revision_height").Uint(),
},
}
case "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal":
height := gjson.Get(string(bz), `messages.0.content.plan.height`).Uint()
title := gjson.Get(string(bz), `messages.0.content.plan.name`).String()
height := rawContent.Get("plan.height").Uint()
title := rawContent.Get("plan.name").String()
return UpgradeProposal{
Deposit: uint(deposit),
Status: status,
Expand All @@ -432,8 +433,8 @@ func (tr TestRun) getProposal(chain chainID, proposal uint) Proposal {
Type: "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal",
}
case "/interchain_security.ccv.provider.v1.ConsumerRemovalProposal":
chainId := gjson.Get(string(bz), `messages.0.content.chain_id`).String()
stopTime := gjson.Get(string(bz), `messages.0.content.stop_time`).Time().Sub(tr.containerConfig.now)
chainId := rawContent.Get("chain_id").String()
stopTime := rawContent.Get("stop_time").Time().Sub(tr.containerConfig.now)

var chain chainID
for i, conf := range tr.chainConfigs {
Expand All @@ -454,9 +455,9 @@ func (tr TestRun) getProposal(chain chainID, proposal uint) Proposal {
return ParamsProposal{
Deposit: uint(deposit),
Status: status,
Subspace: gjson.Get(string(bz), `messages.0.content.changes.0.subspace`).String(),
Key: gjson.Get(string(bz), `messages.0.content.changes.0.key`).String(),
Value: gjson.Get(string(bz), `messages.0.content.changes.0.value`).String(),
Subspace: rawContent.Get("changes.0.subspace").String(),
Key: rawContent.Get("changes.0.key").String(),
Value: rawContent.Get("changes.0.value").String(),
}
}

Expand All @@ -466,7 +467,11 @@ func (tr TestRun) getProposal(chain chainID, proposal uint) Proposal {
}

type TmValidatorSetYaml struct {
Total string `yaml:"total"`
BlockHeight string `yaml:"block_height"`
Pagination struct {
NextKey string `yaml:"next_key"`
Total string `yaml:"total"`
} `yaml:"pagination"`
Validators []struct {
Address string `yaml:"address"`
VotingPower string `yaml:"voting_power"`
Expand Down Expand Up @@ -501,14 +506,15 @@ func (tr TestRun) getValPower(chain chainID, validator validatorID) uint {
log.Fatalf("yaml.Unmarshal returned an error while unmarshalling validator set: %v, input: %s", err, string(bz))
}

total, err := strconv.Atoi(valset.Total)
total, err := strconv.Atoi(valset.Pagination.Total)
if err != nil {
log.Fatalf("strconv.Atoi returned an error while coonverting total for validator set: %v, input: %s, validator set: %s", err, valset.Total, pretty.Sprint(valset))
log.Fatalf("strconv.Atoi returned an error while coonverting total for validator set: %v, input: %s, validator set: %s", err, valset.Pagination.Total, pretty.Sprint(valset))
}

// this only works on small valsets -> otherwise pagination must be used
if total != len(valset.Validators) {
log.Fatalf("Total number of validators %v does not match number of validators in list %v. Probably a query pagination issue. Validator set: %v",
valset.Total, uint(len(valset.Validators)), pretty.Sprint(valset))
valset.Pagination.Total, uint(len(valset.Validators)), pretty.Sprint(valset))
}

for _, val := range valset.Validators {
Expand Down
8 changes: 7 additions & 1 deletion tests/e2e/steps_democracy.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package main

import (
"strconv"

gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
)

const consumerRewardDenom = "ibc/3C3D7B3BE4ECC85A0E5B52A3AEC3B7DFC2AA9CA47C37821E57020D6807043BE9"

func stepsDemocracy(consumerName string) []Step {
Expand Down Expand Up @@ -80,7 +86,7 @@ func stepsDemocracy(consumerName string) []Step {
Proposals: &map[uint]Proposal{
1: ParamsProposal{
Deposit: 10000001,
Status: "PROPOSAL_STATUS_VOTING_PERIOD",
Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)),
Subspace: "transfer",
Key: "SendEnabled",
Value: "true",
Expand Down
8 changes: 7 additions & 1 deletion tests/e2e/steps_reward_denom.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package main

import (
"strconv"

gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
)

func stepsRewardDenomConsumer(consumerName string) []Step {
return []Step{
{
Expand Down Expand Up @@ -78,7 +84,7 @@ func stepsRewardDenomConsumer(consumerName string) []Step {
Proposals: &map[uint]Proposal{
1: ParamsProposal{
Deposit: 10000001,
Status: "PROPOSAL_STATUS_VOTING_PERIOD",
Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)),
Subspace: "transfer",
Key: "SendEnabled",
Value: "true",
Expand Down
15 changes: 10 additions & 5 deletions tests/e2e/steps_sovereign_changeover.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package main

import clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
import (
"strconv"

gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
)

// this creates new clients on both chains and a connection (connection-0) between them
// connection-0 is used to create a transfer channel between the chains
Expand Down Expand Up @@ -61,7 +66,7 @@ func stepsChangeoverToConsumer(consumerName string) []Step {
Chain: chainID(consumerName),
SpawnTime: 0,
InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 111},
Status: "PROPOSAL_STATUS_VOTING_PERIOD",
Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)),
},
},
},
Expand All @@ -82,7 +87,7 @@ func stepsChangeoverToConsumer(consumerName string) []Step {
Chain: chainID(consumerName),
SpawnTime: 0,
InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 111},
Status: "PROPOSAL_STATUS_PASSED",
Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)),
},
},
ValBalances: &map[validatorID]uint{
Expand Down Expand Up @@ -206,7 +211,7 @@ func stepsUpgradeChain() []Step {
UpgradeHeight: 110,
Type: "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal",
Deposit: 10000000,
Status: "PROPOSAL_STATUS_VOTING_PERIOD",
Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)),
},
},
},
Expand All @@ -227,7 +232,7 @@ func stepsUpgradeChain() []Step {
UpgradeHeight: 110,
Title: "sovereign-changeover",
Type: "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal",
Status: "PROPOSAL_STATUS_PASSED",
Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)),
},
},
},
Expand Down
7 changes: 5 additions & 2 deletions tests/e2e/steps_start_chains.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package main

import (
"strconv"

gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
)

Expand Down Expand Up @@ -51,7 +54,7 @@ func stepsStartConsumerChain(consumerName string, proposalIndex, chainIndex uint
Chain: chainID(consumerName),
SpawnTime: 0,
InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1},
Status: "PROPOSAL_STATUS_VOTING_PERIOD",
Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)),
},
},
},
Expand Down Expand Up @@ -130,7 +133,7 @@ func stepsStartConsumerChain(consumerName string, proposalIndex, chainIndex uint
Chain: chainID(consumerName),
SpawnTime: 0,
InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1},
Status: "PROPOSAL_STATUS_PASSED",
Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)),
},
},
ValBalances: &map[validatorID]uint{
Expand Down
Loading

0 comments on commit a356b4f

Please sign in to comment.