mukan-ibc/modules/core/simulation/decoder_test.go
Mukan Erkin Törük 88dd97a9f8
Some checks failed
CodeQL / Analyze (push) Waiting to run
golangci-lint / lint (push) Waiting to run
Tests / Code Coverage / build (amd64) (push) Waiting to run
Tests / Code Coverage / build (arm64) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[additional-args:-tags="test_e2e" name:e2e path:./e2e]) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[name:08-wasm path:./modules/light-clients/08-wasm]) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[name:ibc-go path:.]) (push) Waiting to run
Docker Build & Push Simapp (main) / docker-build (push) Has been cancelled
refactor: replace all github.com upstream refs with git.cw.tr/mukan-network
2026-05-11 03:36:22 +03:00

80 lines
2.3 KiB
Go

package simulation_test
import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
"git.cw.tr/mukan-network/mukan-sdk/types/kv"
clienttypes "git.cw.tr/mukan-network/mukan-ibc/modules/core/02-client/types"
connectiontypes "git.cw.tr/mukan-network/mukan-ibc/modules/core/03-connection/types"
channeltypes "git.cw.tr/mukan-network/mukan-ibc/modules/core/04-channel/types"
host "git.cw.tr/mukan-network/mukan-ibc/modules/core/24-host"
"git.cw.tr/mukan-network/mukan-ibc/modules/core/simulation"
ibctm "git.cw.tr/mukan-network/mukan-ibc/modules/light-clients/07-tendermint"
"git.cw.tr/mukan-network/mukan-ibc/testing/simapp"
)
func TestDecodeStore(t *testing.T) {
app := simapp.Setup(t, false)
dec := simulation.NewDecodeStore(*app.IBCKeeper)
clientID := "clientidone"
connectionID := "connectionidone"
channelID := "channelidone"
portID := "portidone"
clientState := &ibctm.ClientState{
FrozenHeight: clienttypes.NewHeight(0, 10),
}
connection := connectiontypes.ConnectionEnd{
ClientId: "clientidone",
Versions: []*connectiontypes.Version{connectiontypes.NewVersion("1", nil)},
}
channel := channeltypes.Channel{
State: channeltypes.OPEN,
Version: "1.0",
}
kvPairs := kv.Pairs{
Pairs: []kv.Pair{
{
Key: host.FullClientStateKey(clientID),
Value: clienttypes.MustMarshalClientState(app.AppCodec(), clientState),
},
{
Key: host.ConnectionKey(connectionID),
Value: app.IBCKeeper.Codec().MustMarshal(&connection),
},
{
Key: host.ChannelKey(portID, channelID),
Value: app.IBCKeeper.Codec().MustMarshal(&channel),
},
{
Key: []byte{0x99},
Value: []byte{0x99},
},
},
}
tests := []struct {
name string
expectedLog string
}{
{"ClientState", fmt.Sprintf("ClientState A: %v\nClientState B: %v", clientState, clientState)},
{"ConnectionEnd", fmt.Sprintf("ConnectionEnd A: %v\nConnectionEnd B: %v", connection, connection)},
{"Channel", fmt.Sprintf("Channel A: %v\nChannel B: %v", channel, channel)},
{"other", ""},
}
for i, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if i == len(tests)-1 {
require.Panics(t, func() { dec(kvPairs.Pairs[i], kvPairs.Pairs[i]) }, tt.name)
} else {
require.Equal(t, tt.expectedLog, dec(kvPairs.Pairs[i], kvPairs.Pairs[i]), tt.name)
}
})
}
}