* Refactor RegisterQueryServices -> RegisterServices * Cleaner proto files * Fix tests * Add MsgServer * Fix lint * Remove MsgServer from configurator for now * Remove useless file * Fix build * typo * Add router * Fix test * WIP * Add router * Remove test helper * Add beginning of test * Move test to simapp? * ServiceMsg implement sdk.Msg * Add handler by MsgServiceRouter * Correct signature * Add full test * use TxEncoder * Update baseapp/msg_service_router.go Co-authored-by: Aaron Craelius <aaron@regen.network> * Push changes * WIP on ServiceMsg unpacking * Make TestMsgService test pass * Fix tests * Tidying up * Tidying up * Tidying up * Add JSON test * Add comments * Tidying * Lint * Register MsgRequest interface * Rename * Fix tests * RegisterCustomTypeURL * Add changelog entries * Put in features * Update baseapp/msg_service_router.go Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * Update baseapp/msg_service_router.go Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * Update baseapp/msg_service_router.go Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * Update baseapp/msg_service_router.go Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * Update baseapp/msg_service_router.go Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * Update baseapp/msg_service_router.go Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * Update baseapp/msg_service_router.go Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * Address review comments * Address nit * Fix lint * Update codec/types/interface_registry.go Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com> * godoc Co-authored-by: Aaron Craelius <aaronc@users.noreply.github.com> Co-authored-by: Aaron Craelius <aaron@regen.network> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>
80 lines
1.8 KiB
Go
80 lines
1.8 KiB
Go
package testdata
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/tendermint/tendermint/crypto"
|
|
|
|
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
)
|
|
|
|
// KeyTestPubAddr generates a new secp256k1 keypair.
|
|
func KeyTestPubAddr() (crypto.PrivKey, crypto.PubKey, sdk.AccAddress) {
|
|
key := secp256k1.GenPrivKey()
|
|
pub := key.PubKey()
|
|
addr := sdk.AccAddress(pub.Address())
|
|
return key, pub, addr
|
|
}
|
|
|
|
// NewTestFeeAmount is a test fee amount.
|
|
func NewTestFeeAmount() sdk.Coins {
|
|
return sdk.NewCoins(sdk.NewInt64Coin("atom", 150))
|
|
}
|
|
|
|
// NewTestGasLimit is a test fee gas limit.
|
|
func NewTestGasLimit() uint64 {
|
|
return 100000
|
|
}
|
|
|
|
// NewTestMsg creates a message for testing with the given signers.
|
|
func NewTestMsg(addrs ...sdk.AccAddress) *TestMsg {
|
|
var accAddresses []string
|
|
|
|
for _, addr := range addrs {
|
|
accAddresses = append(accAddresses, addr.String())
|
|
}
|
|
|
|
return &TestMsg{
|
|
Signers: accAddresses,
|
|
}
|
|
}
|
|
|
|
var _ sdk.Msg = (*TestMsg)(nil)
|
|
|
|
func (msg *TestMsg) Route() string { return "TestMsg" }
|
|
func (msg *TestMsg) Type() string { return "Test message" }
|
|
func (msg *TestMsg) GetSignBytes() []byte {
|
|
bz, err := json.Marshal(msg.Signers)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return sdk.MustSortJSON(bz)
|
|
}
|
|
func (msg *TestMsg) GetSigners() []sdk.AccAddress {
|
|
addrs := make([]sdk.AccAddress, len(msg.Signers))
|
|
for i, in := range msg.Signers {
|
|
addr, err := sdk.AccAddressFromBech32(in)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
addrs[i] = addr
|
|
}
|
|
|
|
return addrs
|
|
}
|
|
func (msg *TestMsg) ValidateBasic() error { return nil }
|
|
|
|
var _ sdk.MsgRequest = &MsgCreateDog{}
|
|
|
|
func (msg *MsgCreateDog) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{} }
|
|
func (msg *MsgCreateDog) ValidateBasic() error { return nil }
|
|
|
|
func NewServiceMsgCreateDog(msg *MsgCreateDog) sdk.Msg {
|
|
return sdk.ServiceMsg{
|
|
MethodName: "/testdata.Msg/CreateDog",
|
|
Request: msg,
|
|
}
|
|
}
|