-
Notifications
You must be signed in to change notification settings - Fork 618
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: adding msg_server.go tests & codec wiring
- Loading branch information
Showing
7 changed files
with
94 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"github.com/cosmos/ibc-go/modules/apps/29-fee/types" | ||
) | ||
|
||
func (suite *KeeperTestSuite) TestRegisterCounterpartyAddress() { | ||
validAddr := suite.chainA.SenderAccount.GetAddress().String() | ||
validAddr2 := suite.chainB.SenderAccount.GetAddress().String() | ||
|
||
testCases := []struct { | ||
msg *types.MsgRegisterCounterpartyAddress | ||
expPass bool | ||
}{ | ||
{ | ||
types.NewMsgRegisterCounterpartyAddress(validAddr, validAddr2), | ||
true, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
suite.SetupTest() | ||
_, err := suite.chainA.SendMsgs(tc.msg) | ||
|
||
if tc.expPass { | ||
suite.Require().NoError(err) // message committed | ||
} else { | ||
suite.Require().Error(err) | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,42 @@ | ||
package types | ||
|
||
/* | ||
import ( | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/msgservice" | ||
) | ||
|
||
// RegisterLegacyAminoCodec registers the necessary x/ibc 29-fee interfaces and concrete types | ||
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization. | ||
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { | ||
cdc.RegisterConcrete(&MsgRegisterCounterpartyAddress{}, "cosmos-sdk/MsgRegisterCounterpartyAddress", nil) | ||
cdc.RegisterConcrete(&MsgEscrowPacketFee{}, "cosmos-sdk/MsgEscrowPacketFee", nil) | ||
} | ||
|
||
// RegisterInterfaces register the 29-fee module interfaces to protobuf | ||
// Any. | ||
func RegisterInterfaces(registry codectypes.InterfaceRegistry) { | ||
// registry.RegisterImplementations((*sdk.Msg)(nil), &Msg{}) | ||
registry.RegisterImplementations((*sdk.Msg)(nil), &MsgRegisterCounterpartyAddress{}) | ||
registry.RegisterImplementations((*sdk.Msg)(nil), &MsgEscrowPacketFee{}) | ||
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) | ||
} | ||
*/ | ||
|
||
var ( | ||
amino = codec.NewLegacyAmino() | ||
|
||
// ModuleCdc references the global x/ibc-transfer module codec. Note, the codec | ||
// should ONLY be used in certain instances of tests and for JSON encoding. | ||
// | ||
// The actual codec used for serialization should be provided to x/ibc transfer and | ||
// defined at the application level. | ||
ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) | ||
|
||
// AminoCdc is a amino codec created to support amino json compatible msgs. | ||
AminoCdc = codec.NewAminoCodec(amino) | ||
) | ||
|
||
func init() { | ||
RegisterLegacyAminoCodec(amino) | ||
amino.Seal() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters