github.com/Finschia/finschia-sdk@v0.48.1/codec/legacy/amino_msg_test.go (about) 1 package legacy_test 2 3 import ( 4 "strings" 5 "testing" 6 7 "github.com/stretchr/testify/require" 8 9 "github.com/Finschia/finschia-sdk/codec" 10 "github.com/Finschia/finschia-sdk/codec/legacy" 11 "github.com/Finschia/finschia-sdk/testutil/testdata" 12 ) 13 14 func TestRegisterAminoMsg(t *testing.T) { 15 cdc := codec.NewLegacyAmino() 16 17 testCases := map[string]struct { 18 msgName string 19 expPanic bool 20 }{ 21 "all good": { 22 msgName: "cosmos-sdk/Test", 23 }, 24 "msgName too long": { 25 msgName: strings.Repeat("a", 40), 26 expPanic: true, 27 }, 28 } 29 for name, tc := range testCases { 30 t.Run(name, func(t *testing.T) { 31 fn := func() { legacy.RegisterAminoMsg(cdc, &testdata.TestMsg{}, tc.msgName) } 32 if tc.expPanic { 33 require.Panics(t, fn) 34 } else { 35 require.NotPanics(t, fn) 36 } 37 }) 38 } 39 }