@cryptotaxi247 / kubo / commits / 6190be29b

make unrecoverable test errors fatal

Otherwise, we can get random panics form dereferencing nil pointers. This commit was moved from ipfs/interface-go-ipfs-core@6d166d40d8d347faa4a10aec30444999d5d7b85b This commit was moved from ipfs/boxo@35272d3a3b89759460bf3fb96c15e36019036da4

Steven Allen committed Mar 26, 2019 at 18:27 UTC 6190be29b97faebf6537ecf3eedb942d5c9eff08
6 files changed +94 -91
core/coreiface/tests/block.go
+14 -14
@@ -52,7 +52,7 @@ func (tp *provider) TestBlockPutFormat(t *testing.T) {
52 defer cancel()
53 api, err := tp.makeAPI(ctx)
54 if err != nil {
55 - t.Error(err)
55 + t.Fatal(err)
56 }
57
58 res, err := api.Block().Put(ctx, strings.NewReader(`Hello`), opt.Block.Format("cbor"))
@@ -70,7 +70,7 @@ func (tp *provider) TestBlockPutHash(t *testing.T) {
70 defer cancel()
71 api, err := tp.makeAPI(ctx)
72 if err != nil {
73 - t.Error(err)
73 + t.Fatal(err)
74 }
75
76 res, err := api.Block().Put(ctx, strings.NewReader(`Hello`), opt.Block.Hash(mh.KECCAK_512, -1))
@@ -88,7 +88,7 @@ func (tp *provider) TestBlockGet(t *testing.T) {
88 defer cancel()
89 api, err := tp.makeAPI(ctx)
90 if err != nil {
91 - t.Error(err)
91 + t.Fatal(err)
92 }
93
94 res, err := api.Block().Put(ctx, strings.NewReader(`Hello`), opt.Block.Hash(mh.KECCAK_512, -1))
@@ -98,12 +98,12 @@ func (tp *provider) TestBlockGet(t *testing.T) {
98
99 r, err := api.Block().Get(ctx, res.Path())
100 if err != nil {
101 - t.Error(err)
101 + t.Fatal(err)
102 }
103
104 d, err := ioutil.ReadAll(r)
105 if err != nil {
106 - t.Error(err)
106 + t.Fatal(err)
107 }
108
109 if string(d) != "Hello" {
@@ -112,7 +112,7 @@ func (tp *provider) TestBlockGet(t *testing.T) {
112
113 p, err := coreiface.ParsePath("/ipfs/" + res.Path().Cid().String())
114 if err != nil {
115 - t.Error(err)
115 + t.Fatal(err)
116 }
117
118 rp, err := api.ResolvePath(ctx, p)
@@ -129,7 +129,7 @@ func (tp *provider) TestBlockRm(t *testing.T) {
129 defer cancel()
130 api, err := tp.makeAPI(ctx)
131 if err != nil {
132 - t.Error(err)
132 + t.Fatal(err)
133 }
134
135 res, err := api.Block().Put(ctx, strings.NewReader(`Hello`))
@@ -139,12 +139,12 @@ func (tp *provider) TestBlockRm(t *testing.T) {
139
140 r, err := api.Block().Get(ctx, res.Path())
141 if err != nil {
142 - t.Error(err)
142 + t.Fatal(err)
143 }
144
145 d, err := ioutil.ReadAll(r)
146 if err != nil {
147 - t.Error(err)
147 + t.Fatal(err)
148 }
149
150 if string(d) != "Hello" {
@@ -153,7 +153,7 @@ func (tp *provider) TestBlockRm(t *testing.T) {
153
154 err = api.Block().Rm(ctx, res.Path())
155 if err != nil {
156 - t.Error(err)
156 + t.Fatal(err)
157 }
158
159 _, err = api.Block().Get(ctx, res.Path())
@@ -174,7 +174,7 @@ func (tp *provider) TestBlockRm(t *testing.T) {
174
175 err = api.Block().Rm(ctx, res.Path(), opt.Block.Force(true))
176 if err != nil {
177 - t.Error(err)
177 + t.Fatal(err)
178 }
179 }
180
@@ -183,7 +183,7 @@ func (tp *provider) TestBlockStat(t *testing.T) {
183 defer cancel()
184 api, err := tp.makeAPI(ctx)
185 if err != nil {
186 - t.Error(err)
186 + t.Fatal(err)
187 }
188
189 res, err := api.Block().Put(ctx, strings.NewReader(`Hello`))
@@ -193,7 +193,7 @@ func (tp *provider) TestBlockStat(t *testing.T) {
193
194 stat, err := api.Block().Stat(ctx, res.Path())
195 if err != nil {
196 - t.Error(err)
196 + t.Fatal(err)
197 }
198
199 if stat.Path().String() != res.Path().String() {
@@ -210,7 +210,7 @@ func (tp *provider) TestBlockPin(t *testing.T) {
210 defer cancel()
211 api, err := tp.makeAPI(ctx)
212 if err != nil {
213 - t.Error(err)
213 + t.Fatal(err)
214 }
215
216 _, err = api.Block().Put(ctx, strings.NewReader(`Hello`))
core/coreiface/tests/dag.go
+18 -18
@@ -44,12 +44,12 @@ func (tp *provider) TestPut(t *testing.T) {
44 defer cancel()
45 api, err := tp.makeAPI(ctx)
46 if err != nil {
47 - t.Error(err)
47 + t.Fatal(err)
48 }
49
50 nd, err := ipldcbor.FromJSON(strings.NewReader(`"Hello"`), math.MaxUint64, -1)
51 if err != nil {
52 - t.Error(err)
52 + t.Fatal(err)
53 }
54
55 err = api.Dag().Add(ctx, nd)
@@ -67,12 +67,12 @@ func (tp *provider) TestPutWithHash(t *testing.T) {
67 defer cancel()
68 api, err := tp.makeAPI(ctx)
69 if err != nil {
70 - t.Error(err)
70 + t.Fatal(err)
71 }
72
73 nd, err := ipldcbor.FromJSON(strings.NewReader(`"Hello"`), mh.ID, -1)
74 if err != nil {
75 - t.Error(err)
75 + t.Fatal(err)
76 }
77
78 err = api.Dag().Add(ctx, nd)
@@ -90,12 +90,12 @@ func (tp *provider) TestDagPath(t *testing.T) {
90 defer cancel()
91 api, err := tp.makeAPI(ctx)
92 if err != nil {
93 - t.Error(err)
93 + t.Fatal(err)
94 }
95
96 snd, err := ipldcbor.FromJSON(strings.NewReader(`"foo"`), math.MaxUint64, -1)
97 if err != nil {
98 - t.Error(err)
98 + t.Fatal(err)
99 }
100
101 err = api.Dag().Add(ctx, snd)
@@ -105,7 +105,7 @@ func (tp *provider) TestDagPath(t *testing.T) {
105
106 nd, err := ipldcbor.FromJSON(strings.NewReader(`{"lnk": {"/": "`+snd.Cid().String()+`"}}`), math.MaxUint64, -1)
107 if err != nil {
108 - t.Error(err)
108 + t.Fatal(err)
109 }
110
111 err = api.Dag().Add(ctx, nd)
@@ -115,17 +115,17 @@ func (tp *provider) TestDagPath(t *testing.T) {
115
116 p, err := coreiface.ParsePath(path.Join(nd.Cid().String(), "lnk"))
117 if err != nil {
118 - t.Error(err)
118 + t.Fatal(err)
119 }
120
121 rp, err := api.ResolvePath(ctx, p)
122 if err != nil {
123 - t.Error(err)
123 + t.Fatal(err)
124 }
125
126 ndd, err := api.Dag().Get(ctx, rp.Cid())
127 if err != nil {
128 - t.Error(err)
128 + t.Fatal(err)
129 }
130
131 if ndd.Cid().String() != snd.Cid().String() {
@@ -138,12 +138,12 @@ func (tp *provider) TestTree(t *testing.T) {
138 defer cancel()
139 api, err := tp.makeAPI(ctx)
140 if err != nil {
141 - t.Error(err)
141 + t.Fatal(err)
142 }
143
144 nd, err := ipldcbor.FromJSON(strings.NewReader(`{"a": 123, "b": "foo", "c": {"d": 321, "e": 111}}`), math.MaxUint64, -1)
145 if err != nil {
146 - t.Error(err)
146 + t.Fatal(err)
147 }
148
149 err = api.Dag().Add(ctx, nd)
@@ -153,7 +153,7 @@ func (tp *provider) TestTree(t *testing.T) {
153
154 res, err := api.Dag().Get(ctx, nd.Cid())
155 if err != nil {
156 - t.Error(err)
156 + t.Fatal(err)
157 }
158
159 lst := res.Tree("", -1)
@@ -173,12 +173,12 @@ func (tp *provider) TestBatch(t *testing.T) {
173 defer cancel()
174 api, err := tp.makeAPI(ctx)
175 if err != nil {
176 - t.Error(err)
176 + t.Fatal(err)
177 }
178
179 nd, err := ipldcbor.FromJSON(strings.NewReader(`"Hello"`), math.MaxUint64, -1)
180 if err != nil {
181 - t.Error(err)
181 + t.Fatal(err)
182 }
183
184 if nd.Cid().String() != "zdpuAqckYF3ToF3gcJNxPZXmnmGuXd3gxHCXhq81HGxBejEvv" {
@@ -187,15 +187,15 @@ func (tp *provider) TestBatch(t *testing.T) {
187
188 _, err = api.Dag().Get(ctx, nd.Cid())
189 if err == nil || !strings.Contains(err.Error(), "not found") {
190 - t.Error(err)
190 + t.Fatal(err)
191 }
192
193 if err := api.Dag().AddMany(ctx, []ipld.Node{nd}); err != nil {
194 - t.Error(err)
194 + t.Fatal(err)
195 }
196
197 _, err = api.Dag().Get(ctx, nd.Cid())
198 if err != nil {
199 - t.Error(err)
199 + t.Fatal(err)
200 }
201 }
core/coreiface/tests/key.go
+13 -13
@@ -121,7 +121,7 @@ func (tp *provider) TestGenerate(t *testing.T) {
121 defer cancel()
122 api, err := tp.makeAPI(ctx)
123 if err != nil {
124 - t.Error(err)
124 + t.Fatal(err)
125 }
126
127 k, err := api.Key().Generate(ctx, "foo")
@@ -144,7 +144,7 @@ func (tp *provider) TestGenerateSize(t *testing.T) {
144 defer cancel()
145 api, err := tp.makeAPI(ctx)
146 if err != nil {
147 - t.Error(err)
147 + t.Fatal(err)
148 }
149
150 k, err := api.Key().Generate(ctx, "foo", opt.Key.Size(1024))
@@ -169,7 +169,7 @@ func (tp *provider) TestGenerateType(t *testing.T) {
169
170 api, err := tp.makeAPI(ctx)
171 if err != nil {
172 - t.Error(err)
172 + t.Fatal(err)
173 }
174
175 k, err := api.Key().Generate(ctx, "bar", opt.Key.Type(opt.Ed25519Key))
@@ -193,7 +193,7 @@ func (tp *provider) TestGenerateExisting(t *testing.T) {
193 defer cancel()
194 api, err := tp.makeAPI(ctx)
195 if err != nil {
196 - t.Error(err)
196 + t.Fatal(err)
197 }
198
199 _, err = api.Key().Generate(ctx, "foo")
@@ -226,7 +226,7 @@ func (tp *provider) TestList(t *testing.T) {
226 defer cancel()
227 api, err := tp.makeAPI(ctx)
228 if err != nil {
229 - t.Error(err)
229 + t.Fatal(err)
230 }
231
232 _, err = api.Key().Generate(ctx, "foo")
@@ -272,7 +272,7 @@ func (tp *provider) TestRename(t *testing.T) {
272 defer cancel()
273 api, err := tp.makeAPI(ctx)
274 if err != nil {
275 - t.Error(err)
275 + t.Fatal(err)
276 }
277
278 _, err = api.Key().Generate(ctx, "foo")
@@ -301,7 +301,7 @@ func (tp *provider) TestRenameToSelf(t *testing.T) {
301 defer cancel()
302 api, err := tp.makeAPI(ctx)
303 if err != nil {
304 - t.Error(err)
304 + t.Fatal(err)
305 }
306
307 _, err = api.Key().Generate(ctx, "foo")
@@ -325,7 +325,7 @@ func (tp *provider) TestRenameToSelfForce(t *testing.T) {
325 defer cancel()
326 api, err := tp.makeAPI(ctx)
327 if err != nil {
328 - t.Error(err)
328 + t.Fatal(err)
329 }
330
331 _, err = api.Key().Generate(ctx, "foo")
@@ -349,7 +349,7 @@ func (tp *provider) TestRenameOverwriteNoForce(t *testing.T) {
349 defer cancel()
350 api, err := tp.makeAPI(ctx)
351 if err != nil {
352 - t.Error(err)
352 + t.Fatal(err)
353 }
354
355 _, err = api.Key().Generate(ctx, "foo")
@@ -379,7 +379,7 @@ func (tp *provider) TestRenameOverwrite(t *testing.T) {
379 defer cancel()
380 api, err := tp.makeAPI(ctx)
381 if err != nil {
382 - t.Error(err)
382 + t.Fatal(err)
383 }
384
385 kfoo, err := api.Key().Generate(ctx, "foo")
@@ -418,7 +418,7 @@ func (tp *provider) TestRenameSameNameNoForce(t *testing.T) {
418 defer cancel()
419 api, err := tp.makeAPI(ctx)
420 if err != nil {
421 - t.Error(err)
421 + t.Fatal(err)
422 }
423
424 _, err = api.Key().Generate(ctx, "foo")
@@ -447,7 +447,7 @@ func (tp *provider) TestRenameSameName(t *testing.T) {
447 defer cancel()
448 api, err := tp.makeAPI(ctx)
449 if err != nil {
450 - t.Error(err)
450 + t.Fatal(err)
451 }
452
453 _, err = api.Key().Generate(ctx, "foo")
@@ -476,7 +476,7 @@ func (tp *provider) TestRemove(t *testing.T) {
476 defer cancel()
477 api, err := tp.makeAPI(ctx)
478 if err != nil {
479 - t.Error(err)
479 + t.Fatal(err)
480 }
481
482 k, err := api.Key().Generate(ctx, "foo")
core/coreiface/tests/path.go
+9 -9
@@ -68,7 +68,7 @@ func (tp *provider) TestPathRemainder(t *testing.T) {
68
69 nd, err := ipldcbor.FromJSON(strings.NewReader(`{"foo": {"bar": "baz"}}`), math.MaxUint64, -1)
70 if err != nil {
71 - t.Error(err)
71 + t.Fatal(err)
72 }
73
74 if err := api.Dag().Add(ctx, nd); err != nil {
@@ -77,7 +77,7 @@ func (tp *provider) TestPathRemainder(t *testing.T) {
77
78 p1, err := coreiface.ParsePath(nd.String() + "/foo/bar")
79 if err != nil {
80 - t.Error(err)
80 + t.Fatal(err)
81 }
82
83 rp1, err := api.ResolvePath(ctx, p1)
@@ -104,7 +104,7 @@ func (tp *provider) TestEmptyPathRemainder(t *testing.T) {
104
105 nd, err := ipldcbor.FromJSON(strings.NewReader(`{"foo": {"bar": "baz"}}`), math.MaxUint64, -1)
106 if err != nil {
107 - t.Error(err)
107 + t.Fatal(err)
108 }
109
110 if err := api.Dag().Add(ctx, nd); err != nil {
@@ -113,7 +113,7 @@ func (tp *provider) TestEmptyPathRemainder(t *testing.T) {
113
114 p1, err := coreiface.ParsePath(nd.Cid().String())
115 if err != nil {
116 - t.Error(err)
116 + t.Fatal(err)
117 }
118
119 rp1, err := api.ResolvePath(ctx, p1)
@@ -140,7 +140,7 @@ func (tp *provider) TestInvalidPathRemainder(t *testing.T) {
140
141 nd, err := ipldcbor.FromJSON(strings.NewReader(`{"foo": {"bar": "baz"}}`), math.MaxUint64, -1)
142 if err != nil {
143 - t.Error(err)
143 + t.Fatal(err)
144 }
145
146 if err := api.Dag().Add(ctx, nd); err != nil {
@@ -149,7 +149,7 @@ func (tp *provider) TestInvalidPathRemainder(t *testing.T) {
149
150 p1, err := coreiface.ParsePath("/ipld/" + nd.Cid().String() + "/bar/baz")
151 if err != nil {
152 - t.Error(err)
152 + t.Fatal(err)
153 }
154
155 _, err = api.ResolvePath(ctx, p1)
@@ -181,7 +181,7 @@ func (tp *provider) TestPathRoot(t *testing.T) {
181
182 nd, err := ipldcbor.FromJSON(strings.NewReader(`{"foo": {"/": "`+blk.Path().Cid().String()+`"}}`), math.MaxUint64, -1)
183 if err != nil {
184 - t.Error(err)
184 + t.Fatal(err)
185 }
186
187 if err := api.Dag().Add(ctx, nd); err != nil {
@@ -190,7 +190,7 @@ func (tp *provider) TestPathRoot(t *testing.T) {
190
191 p1, err := coreiface.ParsePath("/ipld/" + nd.Cid().String() + "/foo")
192 if err != nil {
193 - t.Error(err)
193 + t.Fatal(err)
194 }
195
196 rp, err := api.ResolvePath(ctx, p1)
@@ -210,7 +210,7 @@ func (tp *provider) TestPathRoot(t *testing.T) {
210 func (tp *provider) TestPathJoin(t *testing.T) {
211 p1, err := coreiface.ParsePath("/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz")
212 if err != nil {
213 - t.Error(err)
213 + t.Fatal(err)
214 }
215
216 if coreiface.Join(p1, "foo").String() != "/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz/foo" {
core/coreiface/tests/pin.go
+13 -13
@@ -31,17 +31,17 @@ func (tp *provider) TestPinAdd(t *testing.T) {
31 defer cancel()
32 api, err := tp.makeAPI(ctx)
33 if err != nil {
34 - t.Error(err)
34 + t.Fatal(err)
35 }
36
37 p, err := api.Unixfs().Add(ctx, strFile("foo")())
38 if err != nil {
39 - t.Error(err)
39 + t.Fatal(err)
40 }
41
42 err = api.Pin().Add(ctx, p)
43 if err != nil {
44 - t.Error(err)
44 + t.Fatal(err)
45 }
46 }
47
@@ -50,17 +50,17 @@ func (tp *provider) TestPinSimple(t *testing.T) {
50 defer cancel()
51 api, err := tp.makeAPI(ctx)
52 if err != nil {
53 - t.Error(err)
53 + t.Fatal(err)
54 }
55
56 p, err := api.Unixfs().Add(ctx, strFile("foo")())
57 if err != nil {
58 - t.Error(err)
58 + t.Fatal(err)
59 }
60
61 err = api.Pin().Add(ctx, p)
62 if err != nil {
63 - t.Error(err)
63 + t.Fatal(err)
64 }
65
66 list, err := api.Pin().Ls(ctx)
@@ -100,27 +100,27 @@ func (tp *provider) TestPinRecursive(t *testing.T) {
100 defer cancel()
101 api, err := tp.makeAPI(ctx)
102 if err != nil {
103 - t.Error(err)
103 + t.Fatal(err)
104 }
105
106 p0, err := api.Unixfs().Add(ctx, strFile("foo")())
107 if err != nil {
108 - t.Error(err)
108 + t.Fatal(err)
109 }
110
111 p1, err := api.Unixfs().Add(ctx, strFile("bar")())
112 if err != nil {
113 - t.Error(err)
113 + t.Fatal(err)
114 }
115
116 nd2, err := ipldcbor.FromJSON(strings.NewReader(`{"lnk": {"/": "`+p0.Cid().String()+`"}}`), math.MaxUint64, -1)
117 if err != nil {
118 - t.Error(err)
118 + t.Fatal(err)
119 }
120
121 nd3, err := ipldcbor.FromJSON(strings.NewReader(`{"lnk": {"/": "`+p1.Cid().String()+`"}}`), math.MaxUint64, -1)
122 if err != nil {
123 - t.Error(err)
123 + t.Fatal(err)
124 }
125
126 if err := api.Dag().AddMany(ctx, []ipld.Node{nd2, nd3}); err != nil {
@@ -129,12 +129,12 @@ func (tp *provider) TestPinRecursive(t *testing.T) {
129
130 err = api.Pin().Add(ctx, iface.IpldPath(nd2.Cid()))
131 if err != nil {
132 - t.Error(err)
132 + t.Fatal(err)
133 }
134
135 err = api.Pin().Add(ctx, iface.IpldPath(nd3.Cid()), opt.Pin.Recursive(false))
136 if err != nil {
137 - t.Error(err)
137 + t.Fatal(err)
138 }
139
140 list, err := api.Pin().Ls(ctx)
core/coreiface/tests/unixfs.go
+27 -24
@@ -98,7 +98,7 @@ func (tp *provider) TestAdd(t *testing.T) {
98 defer cancel()
99 api, err := tp.makeAPI(ctx)
100 if err != nil {
101 - t.Error(err)
101 + t.Fatal(err)
102 }
103
104 p := func(h string) coreiface.ResolvedPath {
@@ -566,15 +566,18 @@ func (tp *provider) TestAddPinned(t *testing.T) {
566 defer cancel()
567 api, err := tp.makeAPI(ctx)
568 if err != nil {
569 - t.Error(err)
569 + t.Fatal(err)
570 }
571
572 _, err = api.Unixfs().Add(ctx, strFile(helloStr)(), options.Unixfs.Pin(true))
573 if err != nil {
574 - t.Error(err)
574 + t.Fatal(err)
575 }
576
577 pins, err := api.Pin().Ls(ctx)
578 + if err != nil {
579 + t.Fatal(err)
580 + }
581 if len(pins) != 1 {
582 t.Fatalf("expected 1 pin, got %d", len(pins))
583 }
@@ -589,12 +592,12 @@ func (tp *provider) TestAddHashOnly(t *testing.T) {
592 defer cancel()
593 api, err := tp.makeAPI(ctx)
594 if err != nil {
592 - t.Error(err)
595 + t.Fatal(err)
596 }
597
598 p, err := api.Unixfs().Add(ctx, strFile(helloStr)(), options.Unixfs.HashOnly(true))
599 if err != nil {
597 - t.Error(err)
600 + t.Fatal(err)
601 }
602
603 if p.String() != hello {
@@ -648,18 +651,18 @@ func (tp *provider) TestGetDir(t *testing.T) {
651 defer cancel()
652 api, err := tp.makeAPI(ctx)
653 if err != nil {
651 - t.Error(err)
654 + t.Fatal(err)
655 }
656 edir := unixfs.EmptyDirNode()
657 err = api.Dag().Add(ctx, edir)
658 if err != nil {
656 - t.Error(err)
659 + t.Fatal(err)
660 }
661 p := coreiface.IpfsPath(edir.Cid())
662
663 emptyDir, err := api.Object().New(ctx, options.Object.Type("unixfs-dir"))
664 if err != nil {
662 - t.Error(err)
665 + t.Fatal(err)
666 }
667
668 if p.String() != coreiface.IpfsPath(emptyDir.Cid()).String() {
@@ -668,7 +671,7 @@ func (tp *provider) TestGetDir(t *testing.T) {
671
672 r, err := api.Unixfs().Get(ctx, coreiface.IpfsPath(emptyDir.Cid()))
673 if err != nil {
671 - t.Error(err)
674 + t.Fatal(err)
675 }
676
677 if _, ok := r.(files.Directory); !ok {
@@ -681,13 +684,13 @@ func (tp *provider) TestGetNonUnixfs(t *testing.T) {
684 defer cancel()
685 api, err := tp.makeAPI(ctx)
686 if err != nil {
684 - t.Error(err)
687 + t.Fatal(err)
688 }
689
690 nd := new(mdag.ProtoNode)
691 err = api.Dag().Add(ctx, nd)
692 if err != nil {
690 - t.Error(err)
693 + t.Fatal(err)
694 }
695
696 _, err = api.Unixfs().Get(ctx, coreiface.IpfsPath(nd.Cid()))
@@ -761,7 +764,7 @@ func (tp *provider) TestEntriesExpired(t *testing.T) {
764 defer cancel()
765 api, err := tp.makeAPI(ctx)
766 if err != nil {
764 - t.Error(err)
767 + t.Fatal(err)
768 }
769
770 r := strings.NewReader("content-of-file")
@@ -769,14 +772,14 @@ func (tp *provider) TestEntriesExpired(t *testing.T) {
772 "name-of-file": files.NewReaderFile(r),
773 }))
774 if err != nil {
772 - t.Error(err)
775 + t.Fatal(err)
776 }
777
778 ctx, cancel = context.WithCancel(ctx)
779
780 nd, err := api.Unixfs().Get(ctx, p)
781 if err != nil {
779 - t.Error(err)
782 + t.Fatal(err)
783 }
784 cancel()
785
@@ -803,22 +806,22 @@ func (tp *provider) TestLsEmptyDir(t *testing.T) {
806 defer cancel()
807 api, err := tp.makeAPI(ctx)
808 if err != nil {
806 - t.Error(err)
809 + t.Fatal(err)
810 }
811
812 _, err = api.Unixfs().Add(ctx, files.NewSliceDirectory([]files.DirEntry{}))
813 if err != nil {
811 - t.Error(err)
814 + t.Fatal(err)
815 }
816
817 emptyDir, err := api.Object().New(ctx, options.Object.Type("unixfs-dir"))
818 if err != nil {
816 - t.Error(err)
819 + t.Fatal(err)
820 }
821
822 links, err := api.Unixfs().Ls(ctx, coreiface.IpfsPath(emptyDir.Cid()))
823 if err != nil {
821 - t.Error(err)
824 + t.Fatal(err)
825 }
826
827 if len(links) != 0 {
@@ -832,7 +835,7 @@ func (tp *provider) TestLsNonUnixfs(t *testing.T) {
835 defer cancel()
836 api, err := tp.makeAPI(ctx)
837 if err != nil {
835 - t.Error(err)
838 + t.Fatal(err)
839 }
840
841 nd, err := cbor.WrapObject(map[string]interface{}{"foo": "bar"}, math.MaxUint64, -1)
@@ -842,12 +845,12 @@ func (tp *provider) TestLsNonUnixfs(t *testing.T) {
845
846 err = api.Dag().Add(ctx, nd)
847 if err != nil {
845 - t.Error(err)
848 + t.Fatal(err)
849 }
850
851 links, err := api.Unixfs().Ls(ctx, coreiface.IpfsPath(nd.Cid()))
852 if err != nil {
850 - t.Error(err)
853 + t.Fatal(err)
854 }
855
856 if len(links) != 0 {
@@ -890,7 +893,7 @@ func (tp *provider) TestAddCloses(t *testing.T) {
893 defer cancel()
894 api, err := tp.makeAPI(ctx)
895 if err != nil {
893 - t.Error(err)
896 + t.Fatal(err)
897 }
898
899 n4 := &closeTestF{files.NewBytesFile([]byte("foo")), false, t}
@@ -907,7 +910,7 @@ func (tp *provider) TestAddCloses(t *testing.T) {
910
911 _, err = api.Unixfs().Add(ctx, d0)
912 if err != nil {
910 - t.Error(err)
913 + t.Fatal(err)
914 }
915
916 d0.Close() // Adder doesn't close top-level file
@@ -930,7 +933,7 @@ func (tp *provider) TestGetSeek(t *testing.T) {
933 defer cancel()
934 api, err := tp.makeAPI(ctx)
935 if err != nil {
933 - t.Error(err)
936 + t.Fatal(err)
937 }
938
939 dataSize := int64(100000)