Skip to content

Commit

Permalink
rename "cid format --codec" to "cid format --mc"
Browse files Browse the repository at this point in the history
  • Loading branch information
guseggert committed Jun 3, 2022
1 parent be04b86 commit eb1eaa8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ Below is an outline of all that is in this release, so you get a sense of all th
- `ipfs cid codecs --supported` can be passed to only show codecs supported in various go-ipfs commands.

#### `ipfs cid format` command
- CidV0 Now correctly requires the `dag-pb` codec, instead of the `protobuf` codec.
- `--codec` was removed and replaced with `--mc` to ensure existing users are aware of the following changes:
- `--mc protobuf` now correctly points to code `0x50` (was `0x70`, which is `dab-pg`)
- `--mc cbor` now correctly points to code `0x51` (was `0x71`, which is `dag-cbor`)

#### `Swarm` configuration
- Daemon will refuse to start if long-deprecated RelayV1 config key `Swarm.EnableAutoRelay` or `Swarm.DisableRelay` is set to `true`.
Expand Down
2 changes: 1 addition & 1 deletion core/commands/cid.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var CidCmd = &cmds.Command{
const (
cidFormatOptionName = "f"
cidVerisonOptionName = "v"
cidCodecOptionName = "codec"
cidCodecOptionName = "mc"
cidMultibaseOptionName = "b"
)

Expand Down
22 changes: 19 additions & 3 deletions test/sharness/t0290-cid.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CIDb32="bafybeibxm2nsadl3fnxv2sxcxmxaco2jl53wpeorjdzidjwf5aqdg7wa6u"
CIDbase="QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6"
CIDb32pb="bafybeievd6mwe6vcwnkwo3eizs3h7w3a34opszbyfxziqdxguhjw7imdve"
CIDb32raw="bafkreievd6mwe6vcwnkwo3eizs3h7w3a34opszbyfxziqdxguhjw7imdve"
CIDb32dagcbor="bafyreievd6mwe6vcwnkwo3eizs3h7w3a34opszbyfxziqdxguhjw7imdve"

test_expect_success "cid base32 works" '
echo $CIDb32 > expected &&
Expand Down Expand Up @@ -284,13 +285,28 @@ test_expect_success "cid hashes --numeric" '

test_expect_success "cid format -c raw" '
echo $CIDb32raw > expected &&
ipfs cid format --codec raw -b base32 $CIDb32pb > actual &&
ipfs cid format --mc raw -b base32 $CIDb32pb > actual &&
test_cmp actual expected
'

test_expect_success "cid format -c protobuf -v 0" '
test_expect_success "cid format --mc dag-pb -v 0" '
echo $CIDbase > expected &&
ipfs cid format --codec dag-pb -v 0 $CIDb32raw > actual &&
ipfs cid format --mc dag-pb -v 0 $CIDb32raw > actual &&
test_cmp actual expected
'

test_expect_success "cid format --mc dag-cbor" '
echo $CIDb32dagcbor > expected &&
ipfs cid format --mc dag-cbor $CIDb32pb > actual &&
test_cmp actual expected
'

# this was an old flag that we removed, explicitly to force an error
# so the user would read about the new multicodec names introduced
# by https://github.com/ipfs/go-cid/commit/b2064d74a8b098193b316689a715cdf4e4934805
test_expect_success "cid format --codec fails" '
echo "Error: unknown option \"codec\"" > expected &&
test_expect_code 1 ipfs cid format --codec protobuf 2> actual &&
test_cmp actual expected
'

Expand Down

0 comments on commit eb1eaa8

Please sign in to comment.