Skip to content

Commit

Permalink
fix: missing transformation for field 'new_chain' in ccv consumer gen…
Browse files Browse the repository at this point in the history
…esis (backport #1509) (#1511)

* fix: missing transformation for field 'new_chain' in ccv consumer genesis (#1509)

Fix missing transformation for field 'new_chain' + testing

(cherry picked from commit f86c61f)

# Conflicts:
#	app/consumer/genesis_test.go

* Fix merge issues on genesis_test.go

* Fix merge issue on genesis_test.go

---------

Co-authored-by: bernd-m <[email protected]>
  • Loading branch information
mergify[bot] and bermuell authored Dec 14, 2023
1 parent 7618827 commit 44e9fc7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/consumer/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func transform(jsonRaw []byte, ctx client.Context) (json.RawMessage, error) {
ConsensusState: oldConsumerGenesis.ProviderConsensusState,
InitialValSet: oldConsumerGenesis.InitialValSet,
},
NewChain: oldConsumerGenesis.NewChain,
}

newJson, err := ctx.Codec.MarshalJSON(&newGenesis)
Expand Down
6 changes: 6 additions & 0 deletions app/consumer/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package app_test
import (
"bytes"
"context"
"encoding/json"
"io/fs"
"os"
"path/filepath"
Expand Down Expand Up @@ -191,6 +192,10 @@ func TestConsumerGenesisTransformationV2(t *testing.T) {
_, err = cmd.ExecuteC()
require.NoError(t, err)

var oldConsumerGenesis map[string]interface{}
err = json.Unmarshal([]byte(consumerGenesisStates[version]), &oldConsumerGenesis)
require.NoError(t, err, "Error parsing old version of ccv genesis content for consumer")

consumerGenesis := consumerTypes.GenesisState{}

bz := output.Bytes()
Expand All @@ -210,4 +215,5 @@ func TestConsumerGenesisTransformationV2(t *testing.T) {

require.Empty(t, consumerGenesis.InitialValSet)
require.NotEmpty(t, consumerGenesis.Provider.InitialValSet)
require.Equal(t, consumerGenesis.NewChain, oldConsumerGenesis["new_chain"])
}

0 comments on commit 44e9fc7

Please sign in to comment.