Merge pull request #610 from filecoin-project/fix/marshal-tipsetkey
Fix Marshaling of TipSetKey
This commit is contained in:
commit
8ff3df3c1c
@ -77,7 +77,7 @@ func (k TipSetKey) Bytes() []byte {
|
||||
return []byte(k.value)
|
||||
}
|
||||
|
||||
func (k *TipSetKey) MarshalJSON() ([]byte, error) {
|
||||
func (k TipSetKey) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(k.Cids())
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
@ -71,12 +72,12 @@ func TestTipSetKey(t *testing.T) {
|
||||
}
|
||||
|
||||
func verifyJson(t *testing.T, expected string, k TipSetKey) {
|
||||
bytes, err := k.MarshalJSON()
|
||||
bytes, err := json.Marshal(k)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, expected, string(bytes))
|
||||
|
||||
var rehydrated TipSetKey
|
||||
err = rehydrated.UnmarshalJSON(bytes)
|
||||
err = json.Unmarshal(bytes, &rehydrated)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, k, rehydrated)
|
||||
}
|
Loading…
Reference in New Issue
Block a user