resolve: kill off buggy resolve function
This resolve function assumed that all paths were of the same type (ipfs, ipld, etc.). The CoreAPI does a much better job.
Steven Allen committed
Aug 21, 2019 at 19:25 UTC
97bc89d56029f2275f42c9d8564151388c51bec9
2 files changed
-47
namesys/resolve/pathresolver_test.go
deleted
-32
@@ -1,32 +0,0 @@
1
-package resolve_test
2
-
3
-import (
4
- "testing"
5
-
6
- coremock "github.com/ipfs/go-ipfs/core/mock"
7
- "github.com/ipfs/go-ipfs/namesys/resolve"
8
-
9
- path "github.com/ipfs/go-path"
10
-)
11
-
12
-func TestResolveNoComponents(t *testing.T) {
13
- n, err := coremock.NewMockNode()
14
- if n == nil || err != nil {
15
- t.Fatal("Should have constructed a mock node", err)
16
- }
17
-
18
- _, err = resolve.Resolve(n.Context(), n.Namesys, n.Resolver, path.Path("/ipns/"))
19
- if err.Error() != "invalid path \"/ipns/\": ipns path missing IPNS ID" {
20
- t.Error("Should error with no components (/ipns/).", err)
21
- }
22
-
23
- _, err = resolve.Resolve(n.Context(), n.Namesys, n.Resolver, path.Path("/ipfs/"))
24
- if err.Error() != "invalid path \"/ipfs/\": not enough path components" {
25
- t.Error("Should error with no components (/ipfs/).", err)
26
- }
27
-
28
- _, err = resolve.Resolve(n.Context(), n.Namesys, n.Resolver, path.Path("/../.."))
29
- if err.Error() != "invalid path \"/../..\": unknown namespace \"..\"" {
30
- t.Error("Should error with invalid path.", err)
31
- }
32
-}
namesys/resolve/resolve.go
-15
@@ -6,9 +6,7 @@ import (
6
"fmt"
7
"strings"
8
9
- "github.com/ipfs/go-ipld-format"
9
"github.com/ipfs/go-path"
11
- "github.com/ipfs/go-path/resolver"
10
11
"github.com/ipfs/go-ipfs/namesys"
12
)
@@ -52,16 +50,3 @@ func ResolveIPNS(ctx context.Context, nsys namesys.NameSystem, p path.Path) (pat
50
}
51
return p, nil
52
}
55
-
56
-// Resolve resolves the given path by parsing out protocol-specific
57
-// entries (e.g. /ipns/<node-key>) and then going through the /ipfs/
58
-// entries and returning the final node.
59
-func Resolve(ctx context.Context, nsys namesys.NameSystem, r *resolver.Resolver, p path.Path) (format.Node, error) {
60
- p, err := ResolveIPNS(ctx, nsys, p)
61
- if err != nil {
62
- return nil, err
63
- }
64
-
65
- // ok, we have an IPFS path now (or what we'll treat as one)
66
- return r.ResolvePath(ctx, p)
67
-}