Fix Marshaling of TipSetKey
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
c20aaf3856
commit
9f3b5bfb6e
@ -77,7 +77,7 @@ func (k TipSetKey) Bytes() []byte {
|
|||||||
return []byte(k.value)
|
return []byte(k.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *TipSetKey) MarshalJSON() ([]byte, error) {
|
func (k TipSetKey) MarshalJSON() ([]byte, error) {
|
||||||
return json.Marshal(k.Cids())
|
return json.Marshal(k.Cids())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -71,12 +72,12 @@ func TestTipSetKey(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func verifyJson(t *testing.T, expected string, k TipSetKey) {
|
func verifyJson(t *testing.T, expected string, k TipSetKey) {
|
||||||
bytes, err := k.MarshalJSON()
|
bytes, err := json.Marshal(k)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, expected, string(bytes))
|
assert.Equal(t, expected, string(bytes))
|
||||||
|
|
||||||
var rehydrated TipSetKey
|
var rehydrated TipSetKey
|
||||||
err = rehydrated.UnmarshalJSON(bytes)
|
err = json.Unmarshal(bytes, &rehydrated)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, k, rehydrated)
|
assert.Equal(t, k, rehydrated)
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user