Skip to content

Commit 074b266

Browse files
authored
deps: update to go-ipld-cbor v0.0.4
1 parent 786e2a5 commit 074b266

File tree

11 files changed

+79
-381
lines changed

11 files changed

+79
-381
lines changed

.gx/lastpubver

Lines changed: 0 additions & 1 deletion
This file was deleted.

Makefile

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
all: deps
1+
all: build
22

3-
gx:
4-
go get github.com/whyrusleeping/gx
5-
go get github.com/whyrusleeping/gx-go
3+
build:
4+
go build ./...
5+
.PHONY: build
66

7-
deps: gx
8-
gx --verbose install --global
9-
gx-go rewrite
7+
test:
8+
go test ./...
9+
.PHONY: test
1010

11-
publish:
12-
gx-go rewrite --undo
11+
benchmark:
12+
go test -bench=./...
13+
.PHONY: benchmark
1314

gen/main.go

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,15 @@
11
package main
22

33
import (
4-
"os"
5-
64
cbg "github.com/whyrusleeping/cbor-gen"
75

86
hamt "github.com/ipfs/go-hamt-ipld"
97
)
108

119
func main() {
12-
fi, err := os.Create("cbor_gen.go")
13-
if err != nil {
14-
panic(err)
15-
}
16-
defer fi.Close()
17-
18-
if err := cbg.PrintHeaderAndUtilityMethods(fi, "hamt"); err != nil {
10+
// FIXME this will not generate the correct code, leave the cbor_gen.go file untouched.
11+
if err := cbg.WriteMapEncodersToFile("cbor_gen.go", "hamt", hamt.Node{}, hamt.KV{}); err != nil {
1912
panic(err)
2013
}
2114

22-
t := []interface{}{
23-
hamt.Node{},
24-
hamt.KV{},
25-
}
26-
27-
for _, t := range t {
28-
if err := cbg.GenTupleEncodersForType(t, fi); err != nil {
29-
panic(err)
30-
}
31-
}
3215
}

go.mod

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ module github.com/ipfs/go-hamt-ipld
33
require (
44
github.com/ipfs/go-block-format v0.0.2
55
github.com/ipfs/go-cid v0.0.3
6-
github.com/ipfs/go-ipld-cbor v0.0.3
7-
github.com/multiformats/go-multihash v0.0.8
8-
github.com/polydawn/refmt v0.0.0-20190221155625-df39d6c2d992
6+
github.com/ipfs/go-ipld-cbor v0.0.4
97
github.com/spaolacci/murmur3 v1.1.0
10-
github.com/whyrusleeping/cbor-gen v0.0.0-20190910031516-c1cbffdb01bb
11-
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7
8+
github.com/whyrusleeping/cbor-gen v0.0.0-20200123233031-1cdf64d27158
9+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
1210
)
1311

1412
go 1.13

go.sum

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
12
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
23
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
34
github.com/gxed/hashland/keccakpg v0.0.1 h1:wrk3uMNaMxbXiHibbPO4S0ymqJMm41WiudyFSs7UnsU=
@@ -7,17 +8,17 @@ github.com/gxed/hashland/murmur3 v0.0.1/go.mod h1:KjXop02n4/ckmZSnY2+HKcLud/tcmv
78
github.com/ipfs/go-block-format v0.0.2 h1:qPDvcP19izTjU8rgo6p7gTXZlkMkF5bz5G3fqIsSCPE=
89
github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY=
910
github.com/ipfs/go-cid v0.0.1/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM=
10-
github.com/ipfs/go-cid v0.0.2/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM=
1111
github.com/ipfs/go-cid v0.0.3 h1:UIAh32wymBpStoe83YCzwVQQ5Oy/H0FdxvUS6DJDzms=
1212
github.com/ipfs/go-cid v0.0.3/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM=
1313
github.com/ipfs/go-ipfs-util v0.0.1 h1:Wz9bL2wB2YBJqggkA4dD7oSmqB4cAnpNbGrlHJulv50=
1414
github.com/ipfs/go-ipfs-util v0.0.1/go.mod h1:spsl5z8KUnrve+73pOhSVZND1SIxPW5RyBCNzQxlJBc=
15-
github.com/ipfs/go-ipld-cbor v0.0.3 h1:ENsxvybwkmke7Z/QJOmeJfoguj6GH3Y0YOaGrfy9Q0I=
16-
github.com/ipfs/go-ipld-cbor v0.0.3/go.mod h1:wTBtrQZA3SoFKMVkp6cn6HMRteIB1VsmHA0AQFOn7Nc=
15+
github.com/ipfs/go-ipld-cbor v0.0.4 h1:Aw3KPOKXjvrm6VjwJvFf1F1ekR/BH3jdof3Bk7OTiSA=
16+
github.com/ipfs/go-ipld-cbor v0.0.4/go.mod h1:BkCduEx3XBCO6t2Sfo5BaHzuok7hbhdMm9Oh8B2Ftq4=
1717
github.com/ipfs/go-ipld-format v0.0.1 h1:HCu4eB/Gh+KD/Q0M8u888RFkorTWNIL3da4oc5dwc80=
1818
github.com/ipfs/go-ipld-format v0.0.1/go.mod h1:kyJtbkDALmFHv3QR6et67i35QzO3S0dCDnkOJhcZkms=
19-
github.com/jtolds/gls v4.2.1+incompatible h1:fSuqC+Gmlu6l/ZYAoZzx2pyucC8Xza35fpRVWLVmUEE=
2019
github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
20+
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
21+
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
2122
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 h1:lYpkrQH5ajf0OXOcUbGjvZxxijuBwbbmlSxLiuofa+g=
2223
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ=
2324
github.com/minio/sha256-simd v0.0.0-20190131020904-2d45a736cd16 h1:5W7KhL8HVF3XCFOweFD3BNESdnO8ewyYTFT2R+/b8FQ=
@@ -34,31 +35,36 @@ github.com/multiformats/go-multibase v0.0.1 h1:PN9/v21eLywrFWdFNsFKaU04kLJzuYzmr
3435
github.com/multiformats/go-multibase v0.0.1/go.mod h1:bja2MqRZ3ggyXtZSEDKpl0uO/gviWFaSteVbWT51qgs=
3536
github.com/multiformats/go-multihash v0.0.1 h1:HHwN1K12I+XllBCrqKnhX949Orn4oawPkegHMu2vDqQ=
3637
github.com/multiformats/go-multihash v0.0.1/go.mod h1:w/5tugSrLEbWqlcgJabL3oHFKTwfvkofsjW2Qa1ct4U=
37-
github.com/multiformats/go-multihash v0.0.8 h1:wrYcW5yxSi3dU07n5jnuS5PrNwyHy0zRHGVoUugWvXg=
38-
github.com/multiformats/go-multihash v0.0.8/go.mod h1:YSLudS+Pi8NHE7o6tb3D8vrpKa63epEDmG8nTduyAew=
38+
github.com/multiformats/go-multihash v0.0.10 h1:lMoNbh2Ssd9PUF74Nz008KGzGPlfeV6wH3rit5IIGCM=
39+
github.com/multiformats/go-multihash v0.0.10/go.mod h1:YSLudS+Pi8NHE7o6tb3D8vrpKa63epEDmG8nTduyAew=
3940
github.com/polydawn/refmt v0.0.0-20190221155625-df39d6c2d992 h1:bzMe+2coZJYHnhGgVlcQKuRy4FSny4ds8dLQjw5P1XE=
4041
github.com/polydawn/refmt v0.0.0-20190221155625-df39d6c2d992/go.mod h1:uIp+gprXxxrWSjjklXD+mN4wed/tMfjMMmN/9+JsA9o=
4142
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
4243
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
43-
github.com/smartystreets/goconvey v0.0.0-20190222223459-a17d461953aa h1:E+gaaifzi2xF65PbDmuKI3PhLWY6G5opMLniFq8vmXA=
4444
github.com/smartystreets/goconvey v0.0.0-20190222223459-a17d461953aa/go.mod h1:2RVY1rIf+2J2o/IM9+vPq9RzmHDSseB7FoXiSNIUsoU=
45+
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
46+
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
4547
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
4648
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
47-
github.com/warpfork/go-wish v0.0.0-20180510122957-5ad1f5abf436 h1:qOpVTI+BrstcjTZLm2Yz/3sOnqkzj3FQoh0g+E5s3Gc=
4849
github.com/warpfork/go-wish v0.0.0-20180510122957-5ad1f5abf436/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw=
49-
github.com/whyrusleeping/cbor-gen v0.0.0-20190910031516-c1cbffdb01bb h1:8yBVx6dgk1GfkiWOQ+RbeDDBLCOZxOtmZ949O2uj5H4=
50-
github.com/whyrusleeping/cbor-gen v0.0.0-20190910031516-c1cbffdb01bb/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY=
50+
github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a h1:G++j5e0OC488te356JvdhaM8YS6nMsjLAYF7JxCv07w=
51+
github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw=
52+
github.com/whyrusleeping/cbor-gen v0.0.0-20200123233031-1cdf64d27158 h1:WXhVOwj2USAXB5oMDwRl3piOux2XMV9TANaYxXHdkoE=
53+
github.com/whyrusleeping/cbor-gen v0.0.0-20200123233031-1cdf64d27158/go.mod h1:Xj/M2wWU+QdTdRbu/L/1dIZY8/Wb2K9pAhtroQuxJJI=
5154
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67 h1:ng3VDlRp5/DHpSWl02R4rM9I+8M2rhmsuLwAMmkLQWE=
5255
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
5356
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
5457
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8 h1:1wopBVtVdWnn03fZelqdXTqk7U7zPQCb+T4rbU9ZEoU=
5558
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
59+
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
60+
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ=
5661
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
5762
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
5863
golang.org/x/sys v0.0.0-20190219092855-153ac476189d h1:Z0Ahzd7HltpJtjAHHxX8QFP3j1yYgiuvjbjRzDj/KH0=
5964
golang.org/x/sys v0.0.0-20190219092855-153ac476189d/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
6065
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
6166
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
6267
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
63-
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc=
64-
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
68+
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
69+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
70+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

hamt.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ type Node struct {
1919
Bitfield *big.Int `refmt:"bf"`
2020
Pointers []*Pointer `refmt:"p"`
2121

22-
// for fetching and storing children
23-
store CborIpldStore
2422
bitWidth int
23+
24+
// for fetching and storing children
25+
store cbor.IpldStore
2526
}
2627

2728
// Option is a function that configures the node
@@ -39,7 +40,7 @@ func UseTreeBitWidth(bitWidth int) Option {
3940

4041
// NewNode creates a new IPLD HAMT Node with the given store and given
4142
// options
42-
func NewNode(cs CborIpldStore, options ...Option) *Node {
43+
func NewNode(cs cbor.IpldStore, options ...Option) *Node {
4344
nd := &Node{
4445
Bitfield: big.NewInt(0),
4546
Pointers: make([]*Pointer, 0),
@@ -123,7 +124,7 @@ func (n *Node) getValue(ctx context.Context, hv *hashBits, k string, cb func(*KV
123124
return ErrNotFound
124125
}
125126

126-
func (p *Pointer) loadChild(ctx context.Context, ns CborIpldStore, bitWidth int) (*Node, error) {
127+
func (p *Pointer) loadChild(ctx context.Context, ns cbor.IpldStore, bitWidth int) (*Node, error) {
127128
if p.cache != nil {
128129
return p.cache, nil
129130
}
@@ -138,7 +139,7 @@ func (p *Pointer) loadChild(ctx context.Context, ns CborIpldStore, bitWidth int)
138139
return out, nil
139140
}
140141

141-
func LoadNode(ctx context.Context, cs CborIpldStore, c cid.Cid, options ...Option) (*Node, error) {
142+
func LoadNode(ctx context.Context, cs cbor.IpldStore, c cid.Cid, options ...Option) (*Node, error) {
142143
var out Node
143144
if err := cs.Get(ctx, c, &out); err != nil {
144145
return nil, err

hamt_bench_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"math/rand"
88
"runtime"
99
"testing"
10+
11+
cbor "github.com/ipfs/go-ipld-cbor"
1012
)
1113

1214
type rander struct {
@@ -28,7 +30,7 @@ func (r *rander) randValue() []byte {
2830
func BenchmarkSerializeNode(b *testing.B) {
2931
r := rander{rand.New(rand.NewSource(1234))}
3032

31-
cs := NewCborStore()
33+
cs := cbor.NewCborStore(newMockBlocks())
3234
n := NewNode(cs)
3335

3436
for i := 0; i < 50; i++ {
@@ -69,7 +71,7 @@ func BenchmarkSet(b *testing.B) {
6971
for _, t := range table {
7072
b.Run(fmt.Sprintf("%d/%d", t.count, t.bitwidth), func(b *testing.B) {
7173
ctx := context.Background()
72-
n := NewNode(NewCborStore(), UseTreeBitWidth(t.bitwidth))
74+
n := NewNode(cbor.NewCborStore(newMockBlocks()), UseTreeBitWidth(t.bitwidth))
7375
b.ResetTimer()
7476
for i := 0; i < b.N; i++ {
7577
for j := 0; j < t.count; j++ {
@@ -95,7 +97,7 @@ func BenchmarkFind(b *testing.B) {
9597
func doBenchmarkEntriesCount(num int, bitWidth int) func(b *testing.B) {
9698
r := rander{rand.New(rand.NewSource(int64(num)))}
9799
return func(b *testing.B) {
98-
cs := NewCborStore()
100+
cs := cbor.NewCborStore(newMockBlocks())
99101
n := NewNode(cs, UseTreeBitWidth(bitWidth))
100102

101103
var keys []string

hamt_test.go

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,32 @@ import (
1010
"testing"
1111
"time"
1212

13+
block "github.com/ipfs/go-block-format"
14+
cid "github.com/ipfs/go-cid"
1315
cbor "github.com/ipfs/go-ipld-cbor"
1416
)
1517

18+
type mockBlocks struct {
19+
data map[cid.Cid]block.Block
20+
}
21+
22+
func newMockBlocks() *mockBlocks {
23+
return &mockBlocks{make(map[cid.Cid]block.Block)}
24+
}
25+
26+
func (mb *mockBlocks) Get(c cid.Cid) (block.Block, error) {
27+
d, ok := mb.data[c]
28+
if ok {
29+
return d, nil
30+
}
31+
return nil, fmt.Errorf("Not Found")
32+
}
33+
34+
func (mb *mockBlocks) Put(b block.Block) error {
35+
mb.data[b.Cid()] = b
36+
return nil
37+
}
38+
1639
func randString() string {
1740
buf := make([]byte, 18)
1841
rand.Read(buf)
@@ -77,7 +100,7 @@ func TestOverflow(t *testing.T) {
77100
keys[i] = strings.Repeat("A", 32) + fmt.Sprintf("%d", i)
78101
}
79102

80-
cs := NewCborStore()
103+
cs := cbor.NewCborStore(newMockBlocks())
81104
n := NewNode(cs)
82105
for _, k := range keys[:3] {
83106
if err := n.Set(context.Background(), k, "foobar"); err != nil {
@@ -110,7 +133,7 @@ func addAndRemoveKeys(t *testing.T, bitWidth int, keys []string, extraKeys []str
110133
vals[s] = randValue()
111134
}
112135

113-
cs := NewCborStore()
136+
cs := cbor.NewCborStore(newMockBlocks())
114137
begn := NewNode(cs, UseTreeBitWidth(bitWidth))
115138
for _, k := range keys {
116139
if err := begn.Set(ctx, k, vals[k]); err != nil {
@@ -236,7 +259,7 @@ func TestHash(t *testing.T) {
236259

237260
func TestBasic(t *testing.T) {
238261
ctx := context.Background()
239-
cs := NewCborStore()
262+
cs := cbor.NewCborStore(newMockBlocks())
240263
begn := NewNode(cs)
241264

242265
val := []byte("cat dog bear")
@@ -275,7 +298,7 @@ func TestBasic(t *testing.T) {
275298

276299
func TestDelete(t *testing.T) {
277300
ctx := context.Background()
278-
cs := NewCborStore()
301+
cs := cbor.NewCborStore(newMockBlocks())
279302
begn := NewNode(cs)
280303

281304
val := []byte("cat dog bear")
@@ -322,7 +345,7 @@ func TestSetGet(t *testing.T) {
322345
keys = append(keys, s)
323346
}
324347

325-
cs := NewCborStore()
348+
cs := cbor.NewCborStore(newMockBlocks())
326349
begn := NewNode(cs)
327350
for _, k := range keys {
328351
if err := begn.Set(ctx, k, vals[k]); err != nil {
@@ -413,7 +436,7 @@ func TestSetGet(t *testing.T) {
413436
}
414437
}
415438

416-
func nodesEqual(t *testing.T, store CborIpldStore, n1, n2 *Node) bool {
439+
func nodesEqual(t *testing.T, store cbor.IpldStore, n1, n2 *Node) bool {
417440
ctx := context.Background()
418441
err := n1.Flush(ctx)
419442
if err != nil {
@@ -436,7 +459,7 @@ func nodesEqual(t *testing.T, store CborIpldStore, n1, n2 *Node) bool {
436459

437460
func TestReloadEmpty(t *testing.T) {
438461
ctx := context.Background()
439-
cs := NewCborStore()
462+
cs := cbor.NewCborStore(newMockBlocks())
440463

441464
n := NewNode(cs)
442465
c, err := cs.Put(ctx, n)
@@ -456,7 +479,7 @@ func TestReloadEmpty(t *testing.T) {
456479

457480
func TestCopy(t *testing.T) {
458481
ctx := context.Background()
459-
cs := NewCborStore()
482+
cs := cbor.NewCborStore(newMockBlocks())
460483

461484
n := NewNode(cs)
462485
nc := n.Copy()
@@ -479,7 +502,7 @@ func TestCopy(t *testing.T) {
479502
}
480503

481504
func TestCopyCopiesNilSlices(t *testing.T) {
482-
cs := NewCborStore()
505+
cs := cbor.NewCborStore(newMockBlocks())
483506

484507
n := NewNode(cs)
485508
pointer := &Pointer{}
@@ -498,7 +521,7 @@ func TestCopyCopiesNilSlices(t *testing.T) {
498521

499522
func TestCopyWithoutFlush(t *testing.T) {
500523
ctx := context.Background()
501-
cs := NewCborStore()
524+
cs := cbor.NewCborStore(newMockBlocks())
502525

503526
count := 200
504527
n := NewNode(cs)
@@ -535,7 +558,7 @@ func TestCopyWithoutFlush(t *testing.T) {
535558

536559
func TestValueLinking(t *testing.T) {
537560
ctx := context.Background()
538-
cs := NewCborStore()
561+
cs := cbor.NewCborStore(newMockBlocks())
539562

540563
thingy1 := map[string]string{"cat": "dog"}
541564
c1, err := cs.Put(ctx, thingy1)
@@ -559,7 +582,7 @@ func TestValueLinking(t *testing.T) {
559582
t.Fatal(err)
560583
}
561584

562-
blk, err := cs.Blocks.GetBlock(ctx, tcid)
585+
blk, err := cs.Blocks.Get(tcid)
563586
if err != nil {
564587
t.Fatal(err)
565588
}

0 commit comments

Comments
 (0)