From 496d4681c2d0167713effc34b4a580ae267cee28 Mon Sep 17 00:00:00 2001 From: Christopher Goes Date: Fri, 8 Jun 2018 02:05:34 +0200 Subject: [PATCH] Add MsgUnrevoke.GetSignBytes() testcase, remove unused functions --- types/account.go | 36 ------------------------------------ x/slashing/msg_test.go | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 36 deletions(-) create mode 100644 x/slashing/msg_test.go diff --git a/types/account.go b/types/account.go index 2c35ca77d2..381fb7af8a 100644 --- a/types/account.go +++ b/types/account.go @@ -98,15 +98,6 @@ func GetAccAddressBech32(address string) (addr Address, err error) { return Address(bz), nil } -// must create an Address from a string -func MustGetAccAddressBech32(address string) Address { - addr, err := GetAccAddressBech32(address) - if err != nil { - panic(err) - } - return addr -} - // create a Pubkey from a string func GetAccPubKeyBech32(address string) (pk crypto.PubKey, err error) { bz, err := getFromBech32(address, Bech32PrefixAccPub) @@ -122,15 +113,6 @@ func GetAccPubKeyBech32(address string) (pk crypto.PubKey, err error) { return pk, nil } -// must create a Pubkey from a string -func MustGetAccPubkeyBec32(address string) crypto.PubKey { - pk, err := GetAccPubKeyBech32(address) - if err != nil { - panic(err) - } - return pk -} - // create an Address from a hex string func GetValAddressHex(address string) (addr Address, err error) { if len(address) == 0 { @@ -152,15 +134,6 @@ func GetValAddressBech32(address string) (addr Address, err error) { return Address(bz), nil } -// must create an Address from a bech32 string -func MustGetValAddressBech32(address string) Address { - addr, err := GetValAddressBech32(address) - if err != nil { - panic(err) - } - return addr -} - // decode a validator public key into a PubKey func GetValPubKeyBech32(pubkey string) (pk crypto.PubKey, err error) { bz, err := getFromBech32(pubkey, Bech32PrefixValPub) @@ -176,15 +149,6 @@ func GetValPubKeyBech32(pubkey string) (pk crypto.PubKey, err error) { return pk, nil } -// must decode a validator public key into a PubKey -func MustGetValPubKeyBech32(pubkey string) crypto.PubKey { - pk, err := GetValPubKeyBech32(pubkey) - if err != nil { - panic(err) - } - return pk -} - func getFromBech32(bech32str, prefix string) ([]byte, error) { if len(bech32str) == 0 { return nil, errors.New("must provide non-empty string") diff --git a/x/slashing/msg_test.go b/x/slashing/msg_test.go new file mode 100644 index 0000000000..be7797107e --- /dev/null +++ b/x/slashing/msg_test.go @@ -0,0 +1,16 @@ +package slashing + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func TestMsgUnrevokeGetSignBytes(t *testing.T) { + addr := sdk.Address("abcd") + msg := NewMsgUnrevoke(addr) + bytes := msg.GetSignBytes() + assert.Equal(t, string(bytes), `{"address":"cosmosvaladdr1v93xxeqamr0mv"}`) +}