* migrated channel genesis types to proto * connection genesis types migrated to proto * client proto migration * failing tests due to tendermint part incomplete * add genesis test * x/ibc: ClientState Any * add genesis test * suite NotPanics * comment tests * update export logic * refactor * update test * fix non-determinism * castrepeated * x/ibc: migrate simulations to protobuf * add proto genesis * add UnpackInterfaces func to genclientstate * add unpackinterfaces for consensus states * formatting * fix genesis tests * add modified genesis test * update comments * remove localhost register codec * use app registry * fix bug * Update simapp/app.go * Update x/ibc/02-client/types/genesis.go * unmarshaler interface Co-authored-by: Colin Axner <colinaxner@berkeley.edu> Co-authored-by: Federico Kunze <federico.kunze94@gmail.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
39 lines
1.5 KiB
Go
39 lines
1.5 KiB
Go
package simulation
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
|
|
"github.com/cosmos/cosmos-sdk/types/kv"
|
|
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
|
|
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
|
)
|
|
|
|
// ClientUnmarshaler defines an interface for unmarshaling ICS02 interfaces.
|
|
type ClientUnmarshaler interface {
|
|
MustUnmarshalClientState([]byte) exported.ClientState
|
|
MustUnmarshalConsensusState([]byte) exported.ConsensusState
|
|
}
|
|
|
|
// NewDecodeStore returns a decoder function closure that unmarshals the KVPair's
|
|
// Value to the corresponding client type.
|
|
func NewDecodeStore(cdc ClientUnmarshaler, kvA, kvB kv.Pair) (string, bool) {
|
|
switch {
|
|
case bytes.HasPrefix(kvA.Key, host.KeyClientStorePrefix) && bytes.HasSuffix(kvA.Key, host.KeyClientState()):
|
|
clientStateA := cdc.MustUnmarshalClientState(kvA.Value)
|
|
clientStateB := cdc.MustUnmarshalClientState(kvB.Value)
|
|
return fmt.Sprintf("ClientState A: %v\nClientState B: %v", clientStateA, clientStateB), true
|
|
|
|
case bytes.HasPrefix(kvA.Key, host.KeyClientStorePrefix) && bytes.HasSuffix(kvA.Key, host.KeyClientType()):
|
|
return fmt.Sprintf("Client type A: %s\nClient type B: %s", string(kvA.Value), string(kvB.Value)), true
|
|
|
|
case bytes.HasPrefix(kvA.Key, host.KeyClientStorePrefix) && bytes.Contains(kvA.Key, []byte("consensusState")):
|
|
consensusStateA := cdc.MustUnmarshalConsensusState(kvA.Value)
|
|
consensusStateB := cdc.MustUnmarshalConsensusState(kvB.Value)
|
|
return fmt.Sprintf("ConsensusState A: %v\nConsensusState B: %v", consensusStateA, consensusStateB), true
|
|
|
|
default:
|
|
return "", false
|
|
}
|
|
}
|