Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring interchain-security into v7 #857

Merged
merged 8 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions chain/cosmos/chain_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"go.uber.org/zap"
"golang.org/x/sync/errgroup"

ccvclient "github.com/cosmos/interchain-security/v3/x/ccv/provider/client"
"github.com/strangelove-ventures/interchaintest/v7/ibc"
"github.com/strangelove-ventures/interchaintest/v7/internal/blockdb"
"github.com/strangelove-ventures/interchaintest/v7/internal/dockerutil"
Expand Down Expand Up @@ -221,6 +222,25 @@ func (tn *ChainNode) OverwriteGenesisFile(ctx context.Context, content []byte) e
return nil
}

func (tn *ChainNode) privValFileContent(ctx context.Context) ([]byte, error) {
fr := dockerutil.NewFileRetriever(tn.logger(), tn.DockerClient, tn.TestName)
gen, err := fr.SingleFileContent(ctx, tn.VolumeName, "config/priv_validator_key.json")
if err != nil {
return nil, fmt.Errorf("getting priv_validator_key.json content: %w", err)
}

return gen, nil
}

func (tn *ChainNode) overwritePrivValFile(ctx context.Context, content []byte) error {
fw := dockerutil.NewFileWriter(tn.logger(), tn.DockerClient, tn.TestName)
if err := fw.WriteFile(ctx, tn.VolumeName, "config/priv_validator_key.json", content); err != nil {
return fmt.Errorf("overwriting priv_validator_key.json: %w", err)
}

return nil
}

func (tn *ChainNode) copyGentx(ctx context.Context, destVal *ChainNode) error {
nid, err := tn.NodeID(ctx)
if err != nil {
Expand Down Expand Up @@ -1170,6 +1190,27 @@ func (tn *ChainNode) TextProposal(ctx context.Context, keyName string, prop Text
return tn.ExecTx(ctx, keyName, command...)
}

func (tn *ChainNode) ConsumerAdditionProposal(ctx context.Context, keyName string, prop ccvclient.ConsumerAdditionProposalJSON) (string, error) {
propBz, err := json.Marshal(prop)
if err != nil {
return "", err
}

fileName := "proposal_" + dockerutil.RandLowerCaseLetterString(4) + ".json"

fw := dockerutil.NewFileWriter(tn.logger(), tn.DockerClient, tn.TestName)
if err := fw.WriteFile(ctx, tn.VolumeName, fileName, propBz); err != nil {
return "", fmt.Errorf("failure writing proposal json: %w", err)
}

filePath := filepath.Join(tn.HomeDir(), fileName)

return tn.ExecTx(ctx, keyName,
"gov", "submit-legacy-proposal", "consumer-addition", filePath,
"--gas", "auto",
)
}

// ParamChangeProposal submits a param change proposal to the chain, signed by keyName.
func (tn *ChainNode) ParamChangeProposal(ctx context.Context, keyName string, prop *paramsutils.ParamChangeProposalJSON) (string, error) {
content, err := json.Marshal(prop)
Expand Down
2 changes: 2 additions & 0 deletions chain/cosmos/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
transfer "github.com/cosmos/ibc-go/v7/modules/apps/transfer"
ibccore "github.com/cosmos/ibc-go/v7/modules/core"
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
ccvprovider "github.com/cosmos/interchain-security/v3/x/ccv/provider"
ibcwasm "github.com/strangelove-ventures/interchaintest/v7/chain/cosmos/08-wasm-types"
)

Expand Down Expand Up @@ -53,6 +54,7 @@ func DefaultEncoding() testutil.TestEncodingConfig {
ibccore.AppModuleBasic{},
ibctm.AppModuleBasic{},
ibcwasm.AppModuleBasic{},
ccvprovider.AppModuleBasic{},
)
}

Expand Down
Loading
Loading