sort *all* GetSignBytes:
- call MustSortJSON before return JSON bytes to guarantee alphabetic ordering - moved SortJSON and MustSortJSON to types package to avoid cyclic package dep
This commit is contained in:
@@ -58,7 +58,7 @@ func (msg MsgSetTrend) GetSignBytes() []byte {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return b
|
||||
return sdk.MustSortJSON(b)
|
||||
}
|
||||
|
||||
//_______________________________________________________________________
|
||||
@@ -102,5 +102,5 @@ func (msg MsgQuiz) GetSignBytes() []byte {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return b
|
||||
return sdk.MustSortJSON(b)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ func (msg Msg) GetSignBytes() []byte {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return bz
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
// GetSigners implements sdk.Msg
|
||||
|
||||
@@ -76,5 +76,5 @@ func (msg MsgMine) GetSignBytes() []byte {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return b
|
||||
return sdk.MustSortJSON(b)
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ func TestMsgMineGetSignBytes(t *testing.T) {
|
||||
addr := sdk.Address([]byte("sender"))
|
||||
msg := MsgMine{addr, 1, 1, 1, []byte("abc")}
|
||||
res := msg.GetSignBytes()
|
||||
require.Equal(t, string(res), `{"sender":"73656E646572","difficulty":1,"count":1,"nonce":1,"proof":"YWJj"}`)
|
||||
require.Equal(t, string(res), `{"count":1,"difficulty":1,"nonce":1,"proof":"YWJj","sender":"73656E646572"}`)
|
||||
}
|
||||
|
||||
func TestMsgMineGetSigners(t *testing.T) {
|
||||
|
||||
@@ -48,7 +48,7 @@ func (msg MsgBond) GetSignBytes() []byte {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return bz
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
//_______________________________________________________________
|
||||
|
||||
Reference in New Issue
Block a user