Skip to content

Commit

Permalink
Need to register Raw codec to support cid.Raw (#92)
Browse files Browse the repository at this point in the history
* Need to register Raw codec to support cid.Raw
* Add unit test to check for registered Codec
  • Loading branch information
gammazero authored Jul 26, 2023
1 parent 4afec9f commit 6990b32
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions ingest/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/ipfs/go-cid"
"github.com/ipld/go-ipld-prime"
_ "github.com/ipld/go-ipld-prime/codec/dagjson"
_ "github.com/ipld/go-ipld-prime/codec/raw"
cidlink "github.com/ipld/go-ipld-prime/linking/cid"
"github.com/ipld/go-ipld-prime/node/bindnode"
"github.com/ipld/go-ipld-prime/schema"
Expand Down
10 changes: 10 additions & 0 deletions ingest/schema/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,16 @@ func Test_MismatchingNodeIsError(t *testing.T) {
require.True(t, strings.HasPrefix(err.Error(), "faild to convert node prototype"))
}

func Test_LinkLoadNoEntries(t *testing.T) {
ls := cidlink.DefaultLinkSystem()
store := &memstore.Store{}
ls.SetReadStorage(store)
ls.SetWriteStorage(store)

_, err := ls.Load(ipld.LinkContext{}, stischema.NoEntries, stischema.AdvertisementPrototype)
require.Equal(t, "404", err.Error())
}

func generateAdvertisement() *stischema.Advertisement {
mhs := test.RandomMultihashes(7)
prev := ipld.Link(cidlink.Link{Cid: cid.NewCidV1(cid.Raw, mhs[0])})
Expand Down

0 comments on commit 6990b32

Please sign in to comment.