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
62 lines
1.3 KiB
Go
62 lines
1.3 KiB
Go
package tendermint_test
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
sdk "git.cw.tr/mukan-network/mukan-sdk/types"
|
|
moduletestutil "git.cw.tr/mukan-network/mukan-sdk/types/module/testutil"
|
|
|
|
tendermint "git.cw.tr/mukan-network/mukan-ibc/modules/light-clients/07-tendermint"
|
|
)
|
|
|
|
func TestCodecTypeRegistration(t *testing.T) {
|
|
testCases := []struct {
|
|
name string
|
|
typeURL string
|
|
expError error
|
|
}{
|
|
{
|
|
"success: ClientState",
|
|
sdk.MsgTypeURL(&tendermint.ClientState{}),
|
|
nil,
|
|
},
|
|
{
|
|
"success: ConsensusState",
|
|
sdk.MsgTypeURL(&tendermint.ConsensusState{}),
|
|
nil,
|
|
},
|
|
{
|
|
"success: Header",
|
|
sdk.MsgTypeURL(&tendermint.Header{}),
|
|
nil,
|
|
},
|
|
{
|
|
"success: Misbehaviour",
|
|
sdk.MsgTypeURL(&tendermint.Misbehaviour{}),
|
|
nil,
|
|
},
|
|
{
|
|
"type not registered on codec",
|
|
"ibc.invalid.MsgTypeURL",
|
|
errors.New("unable to resolve type URL ibc.invalid.MsgTypeURL"),
|
|
},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
encodingCfg := moduletestutil.MakeTestEncodingConfig(tendermint.AppModuleBasic{})
|
|
msg, err := encodingCfg.Codec.InterfaceRegistry().Resolve(tc.typeURL)
|
|
|
|
if tc.expError == nil {
|
|
require.NotNil(t, msg)
|
|
require.NoError(t, err)
|
|
} else {
|
|
require.Nil(t, msg)
|
|
require.ErrorContains(t, err, tc.expError.Error())
|
|
}
|
|
})
|
|
}
|
|
}
|