Prathamesh Musale
d346b95234
- Add E2E tests following pattern suggested in cosmos-sdk docs: https://docs.cosmos.network/v0.50/build/building-modules/testing#end-to-end-tests - Tests for gRPC requests - Tests for manually configured CLI commands - Add a CI workflow to run these E2E tests Reviewed-on: deep-stack/laconic2d#13 Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
93 lines
2.3 KiB
Go
93 lines
2.3 KiB
Go
package registry
|
|
|
|
import (
|
|
errorsmod "cosmossdk.io/errors"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
)
|
|
|
|
// NewMsgSetRecord is the constructor function for MsgSetRecord.
|
|
func NewMsgSetRecord(payload Payload, bondId string, signer sdk.AccAddress) *MsgSetRecord {
|
|
return &MsgSetRecord{
|
|
Payload: payload,
|
|
BondId: bondId,
|
|
Signer: signer.String(),
|
|
}
|
|
}
|
|
|
|
func (msg MsgSetRecord) ValidateBasic() error {
|
|
if len(msg.Signer) == 0 {
|
|
return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, msg.Signer)
|
|
}
|
|
|
|
owners := msg.Payload.Record.Owners
|
|
for _, owner := range owners {
|
|
if owner == "" {
|
|
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Record owner not set.")
|
|
}
|
|
}
|
|
|
|
if len(msg.BondId) == 0 {
|
|
return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Bond Id is required.")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// NewMsgReserveAuthority is the constructor function for MsgReserveName.
|
|
func NewMsgReserveAuthority(name string, signer sdk.AccAddress, owner sdk.AccAddress) MsgReserveAuthority {
|
|
return MsgReserveAuthority{
|
|
Name: name,
|
|
Owner: owner.String(),
|
|
Signer: signer.String(),
|
|
}
|
|
}
|
|
|
|
// ValidateBasic Implements Msg.
|
|
func (msg MsgReserveAuthority) ValidateBasic() error {
|
|
if len(msg.Name) == 0 {
|
|
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "name is required.")
|
|
}
|
|
|
|
if len(msg.Signer) == 0 {
|
|
return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// NewMsgSetAuthorityBond is the constructor function for MsgSetAuthorityBond.
|
|
func NewMsgSetAuthorityBond(name string, bondID string, signer sdk.AccAddress) MsgSetAuthorityBond {
|
|
return MsgSetAuthorityBond{
|
|
Name: name,
|
|
Signer: signer.String(),
|
|
BondId: bondID,
|
|
}
|
|
}
|
|
|
|
// NewMsgSetName is the constructor function for MsgSetName.
|
|
func NewMsgSetName(lrn string, cid string, signer sdk.AccAddress) *MsgSetName {
|
|
return &MsgSetName{
|
|
Lrn: lrn,
|
|
Cid: cid,
|
|
Signer: signer.String(),
|
|
}
|
|
}
|
|
|
|
// ValidateBasic Implements Msg.
|
|
func (msg MsgSetName) ValidateBasic() error {
|
|
if msg.Lrn == "" {
|
|
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "LRN is required.")
|
|
}
|
|
|
|
if msg.Cid == "" {
|
|
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "CID is required.")
|
|
}
|
|
|
|
if len(msg.Signer) == 0 {
|
|
return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer")
|
|
}
|
|
|
|
return nil
|
|
}
|