mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-01 06:17:56 +08:00
commands: return a helpful error when the daemon is offline
fixes #3415 License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
This commit is contained in:
parent
bca91d1ee2
commit
55c232fc72
@ -141,7 +141,7 @@ var findProvidersDhtCmd = &cmds.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
if n.Routing == nil {
|
||||
if !n.OnlineMode() {
|
||||
return ErrNotOnline
|
||||
}
|
||||
|
||||
@ -235,7 +235,7 @@ var provideRefDhtCmd = &cmds.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
if nd.Routing == nil {
|
||||
if !nd.OnlineMode() {
|
||||
return ErrNotOnline
|
||||
}
|
||||
|
||||
@ -364,7 +364,7 @@ var findPeerDhtCmd = &cmds.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
if nd.Routing == nil {
|
||||
if !nd.OnlineMode() {
|
||||
return ErrNotOnline
|
||||
}
|
||||
|
||||
@ -446,7 +446,7 @@ Different key types can specify other 'best' rules.
|
||||
return err
|
||||
}
|
||||
|
||||
if nd.Routing == nil {
|
||||
if !nd.OnlineMode() {
|
||||
return ErrNotOnline
|
||||
}
|
||||
|
||||
@ -538,7 +538,7 @@ NOTE: A value may not exceed 2048 bytes.
|
||||
return err
|
||||
}
|
||||
|
||||
if nd.Routing == nil {
|
||||
if !nd.OnlineMode() {
|
||||
return ErrNotOnline
|
||||
}
|
||||
|
||||
|
||||
@ -91,6 +91,15 @@ test_dht() {
|
||||
test_expect_success 'stop iptb' '
|
||||
iptb stop
|
||||
'
|
||||
|
||||
test_expect_success "dht commands fail when offline" '
|
||||
test_must_fail ipfsi 0 dht findprovs "$HASH" 2>err_findprovs &&
|
||||
test_must_fail ipfsi 0 dht findpeer "$HASH" 2>err_findpeer &&
|
||||
test_must_fail ipfsi 0 dht put "$TEST_DHT_PATH" "$TEST_DHT_VALUE" 2>err_put &&
|
||||
test_should_contain "this command must be run in online mode" err_findprovs &&
|
||||
test_should_contain "this command must be run in online mode" err_findpeer &&
|
||||
test_should_contain "this command must be run in online mode" err_put
|
||||
'
|
||||
}
|
||||
|
||||
test_dht
|
||||
|
||||
Loading…
Reference in New Issue
Block a user