Merge PR #3446: Register x/gov Message Types on init
* register x/gov message types on message codec on init * add TestMsgDepositGetSignBytes
This commit is contained in:
parent
24876aa47b
commit
fd71351541
|
@ -4,9 +4,10 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var msgCdc = codec.New()
|
||||||
|
|
||||||
// Register concrete types on codec codec
|
// Register concrete types on codec codec
|
||||||
func RegisterCodec(cdc *codec.Codec) {
|
func RegisterCodec(cdc *codec.Codec) {
|
||||||
|
|
||||||
cdc.RegisterConcrete(MsgSubmitProposal{}, "cosmos-sdk/MsgSubmitProposal", nil)
|
cdc.RegisterConcrete(MsgSubmitProposal{}, "cosmos-sdk/MsgSubmitProposal", nil)
|
||||||
cdc.RegisterConcrete(MsgDeposit{}, "cosmos-sdk/MsgDeposit", nil)
|
cdc.RegisterConcrete(MsgDeposit{}, "cosmos-sdk/MsgDeposit", nil)
|
||||||
cdc.RegisterConcrete(MsgVote{}, "cosmos-sdk/MsgVote", nil)
|
cdc.RegisterConcrete(MsgVote{}, "cosmos-sdk/MsgVote", nil)
|
||||||
|
@ -15,4 +16,6 @@ func RegisterCodec(cdc *codec.Codec) {
|
||||||
cdc.RegisterConcrete(&TextProposal{}, "gov/TextProposal", nil)
|
cdc.RegisterConcrete(&TextProposal{}, "gov/TextProposal", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
var msgCdc = codec.New()
|
func init() {
|
||||||
|
RegisterCodec(msgCdc)
|
||||||
|
}
|
||||||
|
|
|
@ -55,6 +55,15 @@ func TestMsgSubmitProposal(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMsgDepositGetSignBytes(t *testing.T) {
|
||||||
|
addr := sdk.AccAddress("addr1")
|
||||||
|
msg := NewMsgDeposit(addr, 0, coinsPos)
|
||||||
|
res := msg.GetSignBytes()
|
||||||
|
|
||||||
|
expected := `{"type":"cosmos-sdk/MsgDeposit","value":{"amount":[{"amount":"1000","denom":"stake"}],"depositor":"cosmos1v9jxgu33kfsgr5","proposal_id":"0"}}`
|
||||||
|
require.Equal(t, expected, string(res))
|
||||||
|
}
|
||||||
|
|
||||||
// test ValidateBasic for MsgDeposit
|
// test ValidateBasic for MsgDeposit
|
||||||
func TestMsgDeposit(t *testing.T) {
|
func TestMsgDeposit(t *testing.T) {
|
||||||
_, addrs, _, _ := mock.CreateGenAccounts(1, sdk.Coins{})
|
_, addrs, _, _ := mock.CreateGenAccounts(1, sdk.Coins{})
|
||||||
|
|
Loading…
Reference in New Issue