diff --git a/core/commands/keystore.go b/core/commands/keystore.go index a50ee0b4f3ce..2cb48f1f3aeb 100644 --- a/core/commands/keystore.go +++ b/core/commands/keystore.go @@ -77,7 +77,7 @@ var keyGenCmd = &cmds.Command{ Options: []cmds.Option{ cmds.StringOption(keyStoreTypeOptionName, "t", "type of the key to create: rsa, ed25519").WithDefault("rsa"), cmds.IntOption(keyStoreSizeOptionName, "s", "size of the key to generate"), - cmds.StringOption(keyFormatOptionName, "f", "output format: b58mh or b36cid").WithDefault("b58mh"), + cmds.StringOption(keyFormatOptionName, "f", "output format: b58mh or b36cid").WithDefault("b36cid"), }, Arguments: []cmds.Argument{ cmds.StringArg("name", true, false, "name of key to create"), @@ -292,7 +292,7 @@ var keyListCmd = &cmds.Command{ }, Options: []cmds.Option{ cmds.BoolOption("l", "Show extra information about keys."), - cmds.StringOption(keyFormatOptionName, "f", "output format: b58mh or b36cid").WithDefault("b58mh"), + cmds.StringOption(keyFormatOptionName, "f", "output format: b58mh or b36cid").WithDefault("b36cid"), }, Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { if err := verifyIDFormatLabel(req.Options[keyFormatOptionName].(string)); err != nil { diff --git a/core/commands/resolve.go b/core/commands/resolve.go index da11789590fd..63d175048071 100644 --- a/core/commands/resolve.go +++ b/core/commands/resolve.go @@ -82,23 +82,6 @@ Resolve the value of an IPFS DAG path: name := req.Arguments[0] recursive, _ := req.Options[resolveRecursiveOptionName].(bool) - var enc cidenc.Encoder - switch { - case !cmdenv.CidBaseDefined(req): - // Not specified, check the path. - enc, err = cmdenv.CidEncoderFromPath(name) - if err == nil { - break - } - // Nope, fallback on the default. - fallthrough - default: - enc, err = cmdenv.GetCidEncoder(req) - if err != nil { - return err - } - } - // the case when ipns is resolved step by step if strings.HasPrefix(name, "/ipns/") && !recursive { rc, rcok := req.Options[resolveDhtRecordCountOptionName].(uint) @@ -128,6 +111,23 @@ Resolve the value of an IPFS DAG path: return cmds.EmitOnce(res, &ncmd.ResolvedPath{Path: ipfspath.Path(p.String())}) } + var enc cidenc.Encoder + switch { + case !cmdenv.CidBaseDefined(req) && !strings.HasPrefix(name, "/ipns/"): + // Not specified, check the path. + enc, err = cmdenv.CidEncoderFromPath(name) + if err == nil { + break + } + // Nope, fallback on the default. + fallthrough + default: + enc, err = cmdenv.GetCidEncoder(req) + if err != nil { + return err + } + } + // else, ipfs path or ipns with recursive flag rp, err := api.ResolvePath(req.Context, path.New(name)) if err != nil { diff --git a/test/sharness/t0160-resolve.sh b/test/sharness/t0160-resolve.sh index 6f63d6f31b3a..84af288c9e22 100755 --- a/test/sharness/t0160-resolve.sh +++ b/test/sharness/t0160-resolve.sh @@ -22,8 +22,10 @@ test_expect_success "resolve: prepare dag" ' ' test_expect_success "resolve: prepare keys" ' - self_hash=$(ipfs id -f="") && - alt_hash=$(ipfs key gen -f=b58mh -t rsa alt) + self_hash=$(ipfs key list -f=b36cid -l | grep self | cut -d " " -f1) && + alt_hash=$(ipfs key gen -f=b36cid -t rsa alt) + echo self_hash $self_hash + echo $(ipfs id -f="") ' test_resolve_setup_name() { @@ -60,6 +62,7 @@ test_resolve() { } test_resolve_cmd() { + echo '-- starting test_resolve_cmd' test_resolve "/ipfs/$a_hash" "/ipfs/$a_hash" test_resolve "/ipfs/$a_hash/b" "/ipfs/$b_hash" test_resolve "/ipfs/$a_hash/b/c" "/ipfs/$c_hash" @@ -96,6 +99,7 @@ test_resolve_cmd() { } test_resolve_cmd_b32() { + echo '-- starting test_resolve_cmd_b32' # no flags needed, base should be preserved test_resolve "/ipfs/$a_hash_b32" "/ipfs/$a_hash_b32"