Skip to content
This repository was archived by the owner on Jun 19, 2023. It is now read-only.

Commit 6518db1

Browse files
hacdiasJorropo
authored andcommitted
feat!: use path.Path instead of string in routing API
1 parent 2de38ba commit 6518db1

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

routing.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ package iface
22

33
import (
44
"context"
5+
6+
path "github.com/ipfs/interface-go-ipfs-core/path"
57
)
68

79
// RoutingAPI specifies the interface to the routing layer.
810
type RoutingAPI interface {
911
// Get retrieves the best value for a given key
10-
Get(context.Context, string) ([]byte, error)
12+
Get(context.Context, path.Path) ([]byte, error)
1113

1214
// Put sets a value for a given key
13-
Put(ctx context.Context, key string, value []byte) error
15+
Put(context.Context, path.Path, []byte) error
1416
}

tests/routing.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/gogo/protobuf/proto"
99
ipns_pb "github.com/ipfs/go-ipns/pb"
1010
iface "github.com/ipfs/interface-go-ipfs-core"
11+
"github.com/ipfs/interface-go-ipfs-core/path"
1112
)
1213

1314
func (tp *TestSuite) TestRouting(t *testing.T) {
@@ -48,9 +49,10 @@ func (tp *TestSuite) TestRoutingGet(t *testing.T) {
4849

4950
// Node 1: publishes an IPNS name
5051
ipnsEntry := tp.testRoutingPublishKey(t, ctx, apis[0])
52+
ipnsPath := path.Join(path.New("/ipns"), ipnsEntry.Name())
5153

5254
// Node 2: retrieves the best value for the IPNS name.
53-
data, err := apis[1].Routing().Get(ctx, "/ipns/"+ipnsEntry.Name())
55+
data, err := apis[1].Routing().Get(ctx, ipnsPath)
5456
if err != nil {
5557
t.Fatal(err)
5658
}
@@ -77,15 +79,16 @@ func (tp *TestSuite) TestRoutingPut(t *testing.T) {
7779

7880
// Create and publish IPNS entry.
7981
ipnsEntry := tp.testRoutingPublishKey(t, ctx, apis[0])
82+
ipnsPath := path.Join(path.New("/ipns"), ipnsEntry.Name())
8083

8184
// Get valid routing value.
82-
data, err := apis[0].Routing().Get(ctx, "/ipns/"+ipnsEntry.Name())
85+
data, err := apis[0].Routing().Get(ctx, ipnsPath)
8386
if err != nil {
8487
t.Fatal(err)
8588
}
8689

8790
// Put routing value.
88-
err = apis[0].Routing().Put(ctx, "/ipns/"+ipnsEntry.Name(), data)
91+
err = apis[0].Routing().Put(ctx, ipnsPath, data)
8992
if err != nil {
9093
t.Fatal(err)
9194
}

0 commit comments

Comments
 (0)