Skip to content

Commit

Permalink
chore: added integration test for mint msg
Browse files Browse the repository at this point in the history
  • Loading branch information
vishal-kanna committed Sep 20, 2024
1 parent fbb36f0 commit b10b3ab
Show file tree
Hide file tree
Showing 15 changed files with 841 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api/cheqd/did/v2/tx.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ var (
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
didtypes.ModuleName: {authtypes.Burner},
didtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
feemarkettypes.ModuleName: {authtypes.Burner},
feemarkettypes.FeeCollectorName: {authtypes.Minter, authtypes.Burner},
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ replace (

// replace cosmos-sdk v0.47.10
github.com/cosmos/cosmos-sdk => github.com/cheqd/cosmos-sdk v0.47.10-height-mismatch
// github.com/cosmos/cosmos-sdk => /home/vishal/cheqdWork/cosmos-sdk

github.com/cosmos/gogoproto v1.5.0 => github.com/cosmos/gogoproto v1.4.10

Expand All @@ -230,7 +231,6 @@ replace (
// Fix upstream GHSA-h395-qcrw-5vmq vulnerability.
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.0
github.com/skip-mev/feemarket => github.com/cheqd/feemarket v1.0.4-sdk47.0.20240822213759-ad21c7e69228

github.com/skip-mev/feemarket => github.com/cheqd/feemarket v1.0.4-sdk47.0.20240822213759-ad21c7e69228

Expand Down
6 changes: 4 additions & 2 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1989,8 +1989,8 @@ github.com/checkpoint-restore/go-criu/v5 v5.0.0/go.mod h1:cfwC0EG7HMUenopBsUf9d8
github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E=
github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927/go.mod h1:h/aW8ynjgkuj+NQRlZcDbAbM1ORAbXjXX77sX7T289U=
github.com/cheggaaa/pb v1.0.27 h1:wIkZHkNfC7R6GI5w7l/PdAdzXzlrbcI3p8OAlnkTsnc=
github.com/cheqd/feemarket v1.0.4-sdk47.0.20240822213759-ad21c7e69228 h1:FzVQHthWg60/pwyV5jo8tDLEby1fx4oJjVTE/swtpqY=
github.com/cheqd/feemarket v1.0.4-sdk47.0.20240822213759-ad21c7e69228/go.mod h1:BBEQhAfJQtphzT6qG1emUO9h9AfKC52eKy3o9GcPNoc=
github.com/cheqd/cosmos-sdk v0.47.10-height-mismatch h1:zxljvq+y6HwGkx1Pa2sSd3AF5gr03xf0Jz6GYI4JjqM=
github.com/cheqd/cosmos-sdk v0.47.10-height-mismatch/go.mod h1:UWpgWkhcsBIATS68uUC0del7IiBN4hPv/vqg8Zz23uw=
github.com/cheqd/feemarket v1.0.5-0.20240826165017-f1f216e15aa6/go.mod h1:DUa6djUsTeMOrbrcIZqWSVxU9IZNCXp96ruaojyBNpc=
github.com/chigopher/pathlib v0.12.0/go.mod h1:EJ5UtJ/sK8Nt6q3VWN+EwZLZ3g0afJiG8NegYiQQ/gQ=
github.com/chigopher/pathlib v0.19.1/go.mod h1:tzC1dZLW8o33UQpWkNkhvPwL5n4yyFRFm/jL1YGWFvY=
Expand Down Expand Up @@ -2219,6 +2219,8 @@ github.com/cosmos/cosmos-proto v1.0.0-alpha8/go.mod h1:6/p+Bc4O8JKeZqe0VqUGTX31e
github.com/cosmos/cosmos-proto v1.0.0-beta.1/go.mod h1:8k2GNZghi5sDRFw/scPL8gMSowT1vDA+5ouxL8GjaUE=
github.com/cosmos/cosmos-proto v1.0.0-beta.2/go.mod h1:+XRCLJ14pr5HFEHIUcn51IKXD1Fy3rkEQqt4WqmN4V0=
github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I=
github.com/cosmos/cosmos-sdk v0.47.13 h1:9d57rl2ilSgc8a6u1JAulqNX/E5w8lbqbRe3NON3Jb4=
github.com/cosmos/cosmos-sdk v0.47.13/go.mod h1:pYMzhTfKFn9AJB5X64Epwe9NgYk0y3v7XN8Ks5xqWoo=
github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1 h1:6YvzjQtc+cDwCe9XwYPPa8zFCxNG79N7vmCjpK+vGOg=
github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1/go.mod h1:JUMM2MxF9wuwzRWZJjb8BjXsn1BmPmdBd3a75pIct4I=
github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1.0.20220726092710-f848e4300a8a h1:2humuGPw3O5riJVFq/E2FRjF57UrO97W1qJcGVmK+6k=
Expand Down
2 changes: 2 additions & 0 deletions tests/upgrade/integration/v2/cli/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"sync"
"time"

didv2 "github.com/cheqd/cheqd-node/x/did/types"
tmbytes "github.com/cometbft/cometbft/libs/bytes"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
Expand Down Expand Up @@ -216,6 +217,7 @@ func MakeCodecWithExtendedRegistry() codec.Codec {
(*sdk.Msg)(nil),
&upgradetypes.MsgSoftwareUpgrade{},
&govtypesv1.MsgExecLegacyContent{},
&didv2.MsgMint{},
)

return codec.NewProtoCodec(interfaceRegistry)
Expand Down
48 changes: 48 additions & 0 deletions tests/upgrade/integration/v3/cli/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package cli

import (
upgradeV3 "github.com/cheqd/cheqd-node/app/upgrades/v3"
integrationcli "github.com/cheqd/cheqd-node/tests/integration/cli"
integrationnetwork "github.com/cheqd/cheqd-node/tests/integration/network"
)

const (
CliBinaryName = integrationcli.CliBinaryName
Green = integrationcli.Green
Purple = integrationcli.Purple
)

const (
KeyringBackend = integrationcli.KeyringBackend
OutputFormat = integrationcli.OutputFormat
Gas = integrationcli.Gas
GasAdjustment = integrationcli.GasAdjustment
GasPrices = integrationcli.GasPrices

BootstrapPeriod = 20
BootstrapHeight = 1
VotingPeriod int64 = 10
ExpectedBlockSeconds int64 = 1
ExtraBlocks int64 = 10
UpgradeName = upgradeV3.UpgradeName
DepositAmount = "10000000ncheq"
NetworkConfigDir = "network-config"
KeyringDir = "keyring-test"
)

var (
TXParams = []string{
"--keyring-backend", KeyringBackend,
"--chain-id", integrationnetwork.ChainID,
"-y",
}
GasParams = []string{
"--gas", Gas,
"--gas-adjustment", GasAdjustment,
"--gas-prices", GasPrices,
}
QueryParamsConst = []string{
"--chain-id", integrationnetwork.ChainID,
"--output", OutputFormat,
}
)
88 changes: 88 additions & 0 deletions tests/upgrade/integration/v3/cli/docker.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package cli

import (
"fmt"
"os/exec"
"path/filepath"

errorsmod "cosmossdk.io/errors"
)

const (
DockerLocalnetPath = "../../../../docker/localnet"
DockerComposeFile = "docker-compose.yml"
DockerComposeEnvML = "mainnet-latest.env"
DockerComposeEnvBL = "build-latest.env"
Docker = "docker"
DockerCompose = "compose"
DockerHome = "/home/cheqd"
DockerUser = "cheqd"
DockerUserGroup = "cheqd"
Operator0 = "operator-0"
Operator1 = "operator-1"
Operator2 = "operator-2"
Operator3 = "operator-3"
Validator0 = "validator-0"
Validator1 = "validator-1"
Validator2 = "validator-2"
Validator3 = "validator-3"
ValidatorsCount = 4
)

type OperatorAccountType map[string]string

var OperatorAccounts = OperatorAccountType{
Validator0: Operator0,
Validator1: Operator1,
Validator2: Operator2,
Validator3: Operator3,
}

var ValidatorNodes = []string{Validator0, Validator1, Validator2, Validator3}

var (
DockerComposeLatestArgs = []string{
"-f", filepath.Join(DockerLocalnetPath, DockerComposeFile),
"--env-file", filepath.Join(DockerLocalnetPath, DockerComposeEnvML),
}
DockerComposeBuildArgs = []string{
"-f", filepath.Join(DockerLocalnetPath, DockerComposeFile),
"--env-file", filepath.Join(DockerLocalnetPath, DockerComposeEnvBL),
}
)

func LocalnetExec(envArgs []string, args ...string) (string, error) {
args = append(append([]string{DockerCompose}, envArgs...), args...)
cmd := exec.Command(Docker, args...)
out, err := cmd.CombinedOutput()
if err != nil {
return string(out), errorsmod.Wrap(err, string(out))
}
return string(out), err
}

func LocalnetExecExec(container string, args ...string) (string, error) {
args = append([]string{"exec", container}, args...)
return LocalnetExec(DockerComposeLatestArgs, args...)
}

func LocalnetExecUp() (string, error) {
return LocalnetExec(DockerComposeLatestArgs, "up", "--detach", "--no-build")
}

func LocalnetExecDown() (string, error) {
return LocalnetExec(DockerComposeLatestArgs, "down")
}

func LocalnetExecCopyAbsoluteWithPermissions(path string, destination string, container string) (string, error) {
_, err := LocalnetExec(DockerComposeLatestArgs, "cp", path, container+":"+destination)
if err != nil {
fmt.Println("Error copying file to container: ", err)
return "", err
}
return LocalnetExecRestorePermissions(destination, container)
}

func LocalnetExecRestorePermissions(path string, container string) (string, error) {
return LocalnetExec(DockerComposeLatestArgs, "exec", "-it", "--user", "root", container, "chown", "-R", DockerUser+":"+DockerUserGroup, path)
}
34 changes: 34 additions & 0 deletions tests/upgrade/integration/v3/cli/exec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package cli

import (
"os"
"os/exec"

errorsmod "cosmossdk.io/errors"
integrationcli "github.com/cheqd/cheqd-node/tests/integration/cli"
)

func Exec(args ...string) (string, error) {
return integrationcli.Exec(args...)
}

func ExecDirect(args ...string) (string, error) {
cmd := exec.Command(args[0], args[1:]...)
out, err := cmd.CombinedOutput()
if err != nil {
return "", errorsmod.Wrap(err, string(out))
}

return string(out), err
}

func ExecWithEnv(env []string, args ...string) (string, error) {
cmd := exec.Command(args[0], args[1:]...)
cmd.Env = append(os.Environ(), env...)
out, err := cmd.CombinedOutput()
if err != nil {
return "", errorsmod.Wrap(err, string(out))
}

return string(out), err
}
Loading

0 comments on commit b10b3ab

Please sign in to comment.