diff --git a/pinner/pinmgr.go b/pinner/pinmgr.go index 9bc6a2e0..b193b0fb 100644 --- a/pinner/pinmgr.go +++ b/pinner/pinmgr.go @@ -378,7 +378,9 @@ func encode_msgpack(po *PinningOperation) ([]byte, error) { serialPeers = append(serialPeers, newpeer) } savedObject := PinningOperationSerialize{Po: *po, Peers: serialPeers} - return msgpack.Marshal(&savedObject) + bytes, err := msgpack.Marshal(&savedObject) + po.Peers = peers + return bytes, err } func decode_msgpack(po_bytes []byte) (*PinningOperation, error) { var next *PinningOperationSerialize diff --git a/pinner/pinmgr_test.go b/pinner/pinmgr_test.go index 5b18c9ee..e0149cca 100644 --- a/pinner/pinmgr_test.go +++ b/pinner/pinmgr_test.go @@ -119,10 +119,14 @@ func TestEncodeDecode(t *testing.T) { if err != nil { fmt.Println(err) } - po, err = decode_msgpack(bytes) + newpo, err := decode_msgpack(bytes) if err != nil { fmt.Println(err) } + assert.Equal(t, newpo.Name, po.Name, "name doesnt match") + assert.Equal(t, newpo.Peers[0].Addrs[0].String(), po.Peers[0].Addrs[0].String(), "addr doesnt match") + assert.Equal(t, newpo.Peers[0].ID, po.Peers[0].ID, "ID doesnt match") + }) } func newPinData(name string, userid int, contid int) PinningOperation {