[#168] refs: Implement binary/JSON encoders/decoders on Checksum

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-13 16:30:35 +03:00 committed by Alex Vanin
parent 4b55b06780
commit 93df2fd765
6 changed files with 112 additions and 6 deletions

View file

@ -81,3 +81,17 @@ func TestSignatureSON(t *testing.T) {
require.Equal(t, s, s2)
}
func TestChecksumJSON(t *testing.T) {
cs := new(refs.Checksum)
cs.SetType(refs.SHA256)
cs.SetSum([]byte{1, 2, 3})
data, err := cs.MarshalJSON()
require.NoError(t, err)
cs2 := new(refs.Checksum)
require.NoError(t, cs2.UnmarshalJSON(data))
require.Equal(t, cs, cs2)
}