Some checks failed
CodeQL / Analyze (push) Waiting to run
Docker Build & Push Simapp (main) / docker-build (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
Deploy to GitHub Pages / Deploy to GitHub Pages (push) Has been cancelled
Buf-Push / push (push) Has been cancelled
62 lines
1.3 KiB
Go
62 lines
1.3 KiB
Go
package solomachine_test
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
|
|
|
solomachine "github.com/cosmos/ibc-go/v10/modules/light-clients/06-solomachine"
|
|
)
|
|
|
|
func TestCodecTypeRegistration(t *testing.T) {
|
|
testCases := []struct {
|
|
name string
|
|
typeURL string
|
|
expError error
|
|
}{
|
|
{
|
|
"success: ClientState",
|
|
sdk.MsgTypeURL(&solomachine.ClientState{}),
|
|
nil,
|
|
},
|
|
{
|
|
"success: ConsensusState",
|
|
sdk.MsgTypeURL(&solomachine.ConsensusState{}),
|
|
nil,
|
|
},
|
|
{
|
|
"success: Header",
|
|
sdk.MsgTypeURL(&solomachine.Header{}),
|
|
nil,
|
|
},
|
|
{
|
|
"success: Misbehaviour",
|
|
sdk.MsgTypeURL(&solomachine.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(solomachine.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())
|
|
}
|
|
})
|
|
}
|
|
}
|