From ea77c6e754b593013fdd2e8ea723d1b229109627 Mon Sep 17 00:00:00 2001 From: Bernd Mueller Date: Thu, 5 Oct 2023 17:40:04 +0200 Subject: [PATCH] Minor test fixes + lint warnings --- app/consumer/genesis.go | 1 - app/consumer/genesis_test.go | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/consumer/genesis.go b/app/consumer/genesis.go index abd52f4383..e9e9633134 100644 --- a/app/consumer/genesis.go +++ b/app/consumer/genesis.go @@ -40,7 +40,6 @@ type ( // Migration of consumer genesis content as it is exported from a provider version v2 // to a version readable by current consumer (version v3). func migrateFromV2(jsonRaw []byte, ctx client.Context) (json.RawMessage, error) { - // v2 uses deprecated fields of GenesisState type oldConsumerGenesis := consumerTypes.GenesisState{} err := ctx.Codec.UnmarshalJSON(jsonRaw, &oldConsumerGenesis) diff --git a/app/consumer/genesis_test.go b/app/consumer/genesis_test.go index 0eccc6c1d4..339a99f19c 100644 --- a/app/consumer/genesis_test.go +++ b/app/consumer/genesis_test.go @@ -3,18 +3,20 @@ package app_test import ( "bytes" "context" - "fmt" "io/fs" "os" + "path/filepath" "testing" "time" + "github.com/spf13/cobra" + "github.com/stretchr/testify/require" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/x/auth/types" + app "github.com/cosmos/interchain-security/v3/app/consumer" consumerTypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" - "github.com/spf13/cobra" - "github.com/stretchr/testify/require" ) // Testdata mapping consumer genesis exports to a provider module version as @@ -171,11 +173,12 @@ func getGenesisTransformCmd(t *testing.T) *cobra.Command { // consumer genesis json format used by current consumer implementation. func TestConsumerGenesisTransformationV2(t *testing.T) { version := "v2" - filePath := os.TempDir() + "testdata.json" + filePath := filepath.Join(t.TempDir(), "oldConsumerGenesis.json") + err := os.WriteFile( filePath, []byte(consumerGenesisStates[version]), - fs.FileMode(0644)) + fs.FileMode(0o644)) require.NoError(t, err) defer os.Remove(filePath) @@ -191,10 +194,7 @@ func TestConsumerGenesisTransformationV2(t *testing.T) { consumerGenesis := consumerTypes.GenesisState{} bz := output.Bytes() - fmt.Println(string(bz)) - // err = consumerGenesis.Unmarshal(output.Bytes()) ctx := client.GetClientContextFromCmd(cmd) - err = ctx.Codec.UnmarshalJSON(bz, &consumerGenesis) require.NoError(t, err, "Error unmarshalling transformed genesis state :%s", err)