Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/routing put cmd #10205

Merged
merged 3 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions core/commands/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
iface "github.com/ipfs/boxo/coreiface"
"github.com/ipfs/boxo/coreiface/options"
dag "github.com/ipfs/boxo/ipld/merkledag"
"github.com/ipfs/boxo/ipns"
cid "github.com/ipfs/go-cid"
cmds "github.com/ipfs/go-ipfs-cmds"
ipld "github.com/ipfs/go-ipld-format"
Expand Down Expand Up @@ -451,12 +452,12 @@
options.Put.AllowOffline(allowOffline),
}

err = api.Routing().Put(req.Context, req.Arguments[0], data, opts...)
ipnsName, err := ipns.NameFromString(req.Arguments[0])

Check warning on line 455 in core/commands/routing.go

View check run for this annotation

Codecov / codecov/patch

core/commands/routing.go#L455

Added line #L455 was not covered by tests
if err != nil {
return err
}

id, err := api.Key().Self(req.Context)
err = api.Routing().Put(req.Context, req.Arguments[0], data, opts...)

Check warning on line 460 in core/commands/routing.go

View check run for this annotation

Codecov / codecov/patch

core/commands/routing.go#L460

Added line #L460 was not covered by tests
if err != nil {
if err == iface.ErrOffline {
err = errAllowOffline
Expand All @@ -466,7 +467,7 @@

return res.Emit(routing.QueryEvent{
Type: routing.Value,
ID: id.ID(),
ID: ipnsName.Peer(),

Check warning on line 470 in core/commands/routing.go

View check run for this annotation

Codecov / codecov/patch

core/commands/routing.go#L470

Added line #L470 was not covered by tests
})
},
Encoders: cmds.EncoderMap{
Expand Down
2 changes: 1 addition & 1 deletion test/cli/dht_legacy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func TestLegacyDHT(t *testing.T) {
node.WriteBytes("foo", []byte("foo"))
res := node.RunIPFS("dht", "put", "/ipns/"+node.PeerID().String(), "foo")
assert.Equal(t, 1, res.ExitCode())
assert.Contains(t, res.Stderr.String(), "this action must be run in online mode")
assert.Contains(t, res.Stderr.String(), "can't put while offline: pass `--allow-offline` to override")
})
})
}
2 changes: 1 addition & 1 deletion test/cli/routing_dht_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func testRoutingDHT(t *testing.T, enablePubsub bool) {
node.WriteBytes("foo", []byte("foo"))
res := node.RunIPFS("routing", "put", "/ipns/"+node.PeerID().String(), "foo")
assert.Equal(t, 1, res.ExitCode())
assert.Contains(t, res.Stderr.String(), "this action must be run in online mode")
assert.Contains(t, res.Stderr.String(), "can't put while offline: pass `--allow-offline` to override")
})
})
})
Expand Down
Loading