Skip to content

Commit

Permalink
Fix issue with consumer v2.x compatibility e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bermuell committed Jan 3, 2024
1 parent becfdca commit 505a77f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/consumer/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"regexp"
"strings"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -218,7 +219,7 @@ func transformToV2(jsonRaw []byte, ctx client.Context) (json.RawMessage, error)
}

// patch .provider_client_state from provider.client_state if needed
if srcConGen.Provider.ConsensusState != nil {
if srcConGen.Provider.ClientState != nil {
clientState, exists := providerMap["client_state"]
if !exists {
return nil, fmt.Errorf("'client_state' not found in provider data")
Expand All @@ -237,6 +238,11 @@ func transformToV2(jsonRaw []byte, ctx client.Context) (json.RawMessage, error)
if err != nil {
return nil, fmt.Errorf("marshalling transformation result failed: %v", err)
}

// remove all `prehash_key_before_comparison` entries not supported in v2.x (see ics23)
re := regexp.MustCompile(`,\s*"prehash_key_before_comparison"\s*:\s*(false|true)`)
result = re.ReplaceAll(result, []byte{})

return result, nil
}

Expand All @@ -247,7 +253,8 @@ func transformGenesis(ctx client.Context, targetVersion IcsVersion, jsonRaw []by
var err error = nil

switch targetVersion {
case v2_x, v3_0_x, v3_1_x:
// v2.x, v3.0-v3.2 share same consumer genesis type
case v2_x, v3_0_x, v3_1_x, v3_2_x:
newConsumerGenesis, err = transformToV2(jsonRaw, ctx)
case v3_3_x:
newConsumerGenesis, err = transformToV33(jsonRaw, ctx)
Expand Down

0 comments on commit 505a77f

Please sign in to comment.