package keeper_test

import (
	"errors"
	"testing"

	"github.com/stretchr/testify/require"

	sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
	channeltypes "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types"

    "<%= ModulePath %>/x/<%= moduleName %>/keeper"
	"<%= ModulePath %>/x/<%= moduleName %>/types"
)

func TestMsgServerSend<%= packetName.UpperCamel %>(t *testing.T) {
	f := initFixture(t)
	srv := keeper.NewMsgServerImpl(f.keeper)
	<%= MsgSigner.LowerCamel %>, err := f.addressCodec.BytesToString([]byte("signerAddr__________________"))
	require.NoError(t, err)

	tests := []struct {
		name string
		msg  types.MsgSend<%= packetName.UpperCamel %>
		err  error
	}{
		{
			name: "invalid address",
			msg: types.MsgSend<%= packetName.UpperCamel %>{
				<%= MsgSigner.UpperCamel %>: "invalid address",
				Port:             "port",
				ChannelID:        "channel-0",
				TimeoutTimestamp: 100,
			},
			err: sdkerrors.ErrInvalidAddress,
		}, {
			name: "invalid port",
			msg: types.MsgSend<%= packetName.UpperCamel %>{
				<%= MsgSigner.UpperCamel %>: <%= MsgSigner.LowerCamel %>,
				Port:             "",
				ChannelID:        "channel-0",
				TimeoutTimestamp: 100,
			},
			err: sdkerrors.ErrInvalidRequest,
		}, {
			name: "invalid channel",
			msg: types.MsgSend<%= packetName.UpperCamel %>{
				<%= MsgSigner.UpperCamel %>: <%= MsgSigner.LowerCamel %>,
				Port:             "port",
				ChannelID:        "",
				TimeoutTimestamp: 100,
			},
			err: sdkerrors.ErrInvalidRequest,
		}, {
			name: "invalid timeout",
			msg: types.MsgSend<%= packetName.UpperCamel %>{
				<%= MsgSigner.UpperCamel %>: <%= MsgSigner.LowerCamel %>,
				Port:             "port",
				ChannelID:        "channel-0",
				TimeoutTimestamp: 0,
			},
			err: sdkerrors.ErrInvalidRequest,
		}, {
			name: "valid message",
			msg: types.MsgSend<%= packetName.UpperCamel %>{
				<%= MsgSigner.UpperCamel %>: <%= MsgSigner.LowerCamel %>,
				Port:             "port",
				ChannelID:        "channel-0",
				TimeoutTimestamp: 100,
			},
			err: errors.New("channel not found"),
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			_, err = srv.Send<%= packetName.UpperCamel %>(f.ctx, &tt.msg)
			if tt.err != nil {
				require.ErrorContains(t, err, tt.err.Error())
				return
			}
			require.NoError(t, err)
		})
	}
}
