mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-15 14:21:22 +00:00
Support json encode/decode for nil values in S structs
This commit is contained in:
@ -84,5 +84,29 @@ func TestKeyEncodings(t *testing.T) {
|
||||
checkJSON(t, pubKey, &pub3, tc.keyName)
|
||||
assert.EqualValues(t, pubKey, pub3)
|
||||
}
|
||||
}
|
||||
|
||||
func toFromJSON(t *testing.T, in interface{}, recvr interface{}) {
|
||||
js, err := data.ToJSON(in)
|
||||
require.Nil(t, err, "%+v", err)
|
||||
err = data.FromJSON(js, recvr)
|
||||
require.Nil(t, err, "%+v", err)
|
||||
}
|
||||
|
||||
func TestNilEncodings(t *testing.T) {
|
||||
// make sure sigs are okay with nil
|
||||
a, b := SignatureS{}, SignatureS{}
|
||||
toFromJSON(t, a, &b)
|
||||
assert.EqualValues(t, a, b)
|
||||
|
||||
// make sure sigs are okay with nil
|
||||
c, d := PubKeyS{}, PubKeyS{}
|
||||
toFromJSON(t, c, &d)
|
||||
assert.EqualValues(t, c, d)
|
||||
|
||||
// make sure sigs are okay with nil
|
||||
e, f := PrivKeyS{}, PrivKeyS{}
|
||||
toFromJSON(t, e, &f)
|
||||
assert.EqualValues(t, e, f)
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user