Skip to content

Commit

Permalink
do not remove preCCV from consumer genesis state
Browse files Browse the repository at this point in the history
  • Loading branch information
mpoke committed Jan 7, 2025
1 parent 530b52d commit 36515a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/consumer/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ func transformGenesis(targetVersion IcsVersion, jsonRaw []byte) (json.RawMessage
if err != nil {
break
}
genState, err = removeFieldsFromGenesisState(genState, []string{"preCCV", "connection_id"})
genState, err = removeFieldsFromGenesisState(genState, []string{"connection_id"})
case v4_5_x, v6_x_x:
genState, err = removeFieldsFromGenesisState(genState, []string{"preCCV", "connection_id"})
genState, err = removeFieldsFromGenesisState(genState, []string{"connection_id"})
default:
err = fmt.Errorf("unsupported target version '%s'. Run %s --help",
targetVersion, version.AppName)
Expand Down
14 changes: 4 additions & 10 deletions app/consumer/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,9 @@ func CheckGenesisTransform(t *testing.T, sourceVersion string, targetVersion str
_, consumerIdFound := params["consumer_id"]
require.Equal(t, shouldContainConsumerId(targetVersion), consumerIdFound)

// Check for preCCV
_, found = resultRaw["preCCV"]
require.Equal(t, shouldContainPreCCVAndConnectionId(targetVersion), found)
// Check for no connection_id
_, found = resultRaw["connection_id"]
require.Equal(t, shouldContainPreCCVAndConnectionId(targetVersion), found)
require.Equal(t, shouldContainConnectionId(targetVersion), found)

// Iterate over all fields of ConsumerParams and check:
// - that they match between source and result genesis
Expand All @@ -427,10 +424,7 @@ func CheckGenesisTransform(t *testing.T, sourceVersion string, targetVersion str
if fieldName == "ConsumerId" && !shouldContainConsumerId(targetVersion) {
// ConsumerId is not present in v5.x => expect empty string when unmarshalled to v6
require.EqualValues(t, "", resultField, "Field %s does not match", fieldName)
} else if fieldName == "PreCCV" && !shouldContainPreCCVAndConnectionId(targetVersion) {
// PreCCV is not present in <v6.4.x => expect false when unmarshalled it
require.EqualValues(t, false, resultField, "Field %s does not match", fieldName)
} else if fieldName == "ConnectionId" && !shouldContainPreCCVAndConnectionId(targetVersion) {
} else if fieldName == "ConnectionId" && !shouldContainConnectionId(targetVersion) {
// ConnectionId is not present in <v6.4.x => expect empty string when unmarshalled it
require.EqualValues(t, "", resultField, "Field %s does not match", fieldName)
} else {
Expand All @@ -448,7 +442,7 @@ func CheckGenesisTransform(t *testing.T, sourceVersion string, targetVersion str
for i := 0; i < srcParams.NumField(); i++ {
fieldName := srcType.Field(i).Name
// Skip Params field as it was checked above
if fieldName == "Params" || fieldName == "PreCCV" || fieldName == "ConnectionId" {
if fieldName == "Params" || fieldName == "ConnectionId" {
continue
}
srcField := srcParams.Field(i).Interface()
Expand All @@ -469,7 +463,7 @@ func shouldContainConsumerId(version string) bool {
return false
}

func shouldContainPreCCVAndConnectionId(version string) bool {
func shouldContainConnectionId(version string) bool {
switch version {
case Consumer_v4_x_x, Consumer_v4_5_x, Consumer_v5_x_x, Consumer_v6_x_x:
return false
Expand Down

0 comments on commit 36515a2

Please sign in to comment.