Skip to content

Commit

Permalink
Merge pull request filecoin-project#11 from filecoin-project/revert/m…
Browse files Browse the repository at this point in the history
…arshal-nil-address

Only marshal null
  • Loading branch information
Stebalien authored Aug 11, 2020
2 parents 088d2a0 + 4d2035e commit 4490824
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
12 changes: 0 additions & 12 deletions address.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,18 +380,6 @@ func (a *Address) MarshalCBOR(w io.Writer) error {
func (a *Address) UnmarshalCBOR(r io.Reader) error {
br := cbg.GetPeeker(r)

pb, err := br.ReadByte()
if err != nil {
return err
}
if pb == cbg.CborNull[0] {
return nil
}
err = br.UnreadByte()
if err != nil {
return err
}

maj, extra, err := cbg.CborReadHeader(br)
if err != nil {
return err
Expand Down
10 changes: 3 additions & 7 deletions address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/stretchr/testify/assert"

"github.com/filecoin-project/go-crypto"
cbg "github.com/whyrusleeping/cbor-gen"
)

func init() {
Expand Down Expand Up @@ -466,13 +467,8 @@ func TestCborMarshalNilAddress(t *testing.T) {
t.Fatal(err)
}

var out *Address
if err := out.UnmarshalCBOR(buf); err != nil {
t.Fatal(err)
}

if out != nil {
t.Fatalf("failed to roundtrip nil address")
if string(cbg.CborNull) != buf.String() {
t.Fatal("expected null")
}
}

Expand Down

0 comments on commit 4490824

Please sign in to comment.