chore: update go-multibase 🚀

This add supports for base256emoji.
This commit is contained in:
Jorropo 2022-07-07 21:51:19 +02:00
parent 92c4dc61a8
commit cbb9aeec49
5 changed files with 62 additions and 47 deletions

View File

@ -291,11 +291,11 @@ var basesCmd = &cmds.Command{
}
switch {
case prefixes && numeric:
fmt.Fprintf(w, "%c %5d %s\n", code, v.Code, v.Name)
fmt.Fprintf(w, "%c %7d %s\n", code, v.Code, v.Name)
case prefixes:
fmt.Fprintf(w, "%c %s\n", code, v.Name)
case numeric:
fmt.Fprintf(w, "%5d %s\n", v.Code, v.Name)
fmt.Fprintf(w, "%7d %s\n", v.Code, v.Name)
default:
fmt.Fprintf(w, "%s\n", v.Name)
}

2
go.mod
View File

@ -86,7 +86,7 @@ require (
github.com/mitchellh/go-homedir v1.1.0
github.com/multiformats/go-multiaddr v0.5.0
github.com/multiformats/go-multiaddr-dns v0.3.1
github.com/multiformats/go-multibase v0.0.3
github.com/multiformats/go-multibase v0.1.0
github.com/multiformats/go-multicodec v0.5.0
github.com/multiformats/go-multihash v0.2.0
github.com/opentracing/opentracing-go v1.2.0

3
go.sum
View File

@ -1253,8 +1253,9 @@ github.com/multiformats/go-multiaddr-net v0.1.4/go.mod h1:ilNnaM9HbmVFqsb/qcNysj
github.com/multiformats/go-multiaddr-net v0.1.5/go.mod h1:ilNnaM9HbmVFqsb/qcNysjCu4PVONlrBZpHIrw/qQuA=
github.com/multiformats/go-multiaddr-net v0.2.0/go.mod h1:gGdH3UXny6U3cKKYCvpXI5rnK7YaOIEOPVDI9tsJbEA=
github.com/multiformats/go-multibase v0.0.1/go.mod h1:bja2MqRZ3ggyXtZSEDKpl0uO/gviWFaSteVbWT51qgs=
github.com/multiformats/go-multibase v0.0.3 h1:l/B6bJDQjvQ5G52jw4QGSYeOTZoAwIO77RblWplfIqk=
github.com/multiformats/go-multibase v0.0.3/go.mod h1:5+1R4eQrT3PkYZ24C3W2Ue2tPwIdYQD509ZjSb5y9Oc=
github.com/multiformats/go-multibase v0.1.0 h1:+cr9718eEwFIUxPP7sQmixYYhD4sRrU9aMXqYb+0diE=
github.com/multiformats/go-multibase v0.1.0/go.mod h1:ZEjHE+IsUrgp5mhlEAYjMtZwK1k4haNkcaPg9aoe1a8=
github.com/multiformats/go-multicodec v0.2.0/go.mod h1:/y4YVwkfMyry5kFbMTbLJKErhycTIftytRV+llXdyS4=
github.com/multiformats/go-multicodec v0.3.0/go.mod h1:qGGaQmioCDh+TeFOnxrbU0DaIPw8yFgAZgFG0V7p1qQ=
github.com/multiformats/go-multicodec v0.3.1-0.20210902112759-1539a079fd61/go.mod h1:1Hj/eHRaVWSXiSNNfcEPcwZleTmdNP81xlxDLnWU9GQ=

View File

@ -81,26 +81,27 @@ test_expect_success "cid format -v 1 -b base58btc works from stdin" '
'
cat <<EOF > bases_expect
0 identity
0 48 base2
b 98 base32
B 66 base32upper
c 99 base32pad
C 67 base32padupper
f 102 base16
F 70 base16upper
k 107 base36
K 75 base36upper
m 109 base64
M 77 base64pad
t 116 base32hexpad
T 84 base32hexpadupper
u 117 base64url
U 85 base64urlpad
v 118 base32hex
V 86 base32hexupper
z 122 base58btc
Z 90 base58flickr
0 identity
0 48 base2
b 98 base32
B 66 base32upper
c 99 base32pad
C 67 base32padupper
f 102 base16
F 70 base16upper
k 107 base36
K 75 base36upper
m 109 base64
M 77 base64pad
t 116 base32hexpad
T 84 base32hexpadupper
u 117 base64url
U 85 base64urlpad
v 118 base32hex
V 86 base32hexupper
z 122 base58btc
Z 90 base58flickr
128640 base256emoji
EOF
cat <<EOF > codecs_expect
@ -234,13 +235,13 @@ cat <<EOF > hashes_expect
EOF
test_expect_success "cid bases" '
cut -c 10- bases_expect > expect &&
cut -c 12- bases_expect > expect &&
ipfs cid bases > actual &&
test_cmp expect actual
'
test_expect_success "cid bases --prefix" '
cut -c 1-3,10- bases_expect > expect &&
cut -c 1-3,12- bases_expect > expect &&
ipfs cid bases --prefix > actual &&
test_cmp expect actual
'
@ -310,5 +311,17 @@ test_expect_success "cid format --codec fails" '
test_cmp actual expected
'
test_expect_success "cid format -b base256emoji <base32>" '
echo "🚀🪐⭐💻😅❓💎🌈🌸🌚💰💍🌒😵🐶💁🤐🌎👼🙃🙅☺🌚😞🤤⭐🚀😃✈🌕😚🍻💜🐷⚽✌😊" > expected &&
ipfs cid format -b base256emoji bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi > actual &&
test_cmp actual expected
'
test_expect_success "cid format -b base32 <base256emoji>" '
echo "bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi" > expected &&
ipfs cid format -b base32 🚀🪐⭐💻😅❓💎🌈🌸🌚💰💍🌒😵🐶💁🤐🌎👼🙃🙅☺🌚😞🤤⭐🚀😃✈🌕😚🍻💜🐷⚽✌😊 > actual &&
test_cmp actual expected
'
test_done

View File

@ -7,31 +7,32 @@ test_description="Test multibase commands"
# note: all "ipfs multibase" commands should work without requiring a repo
cat <<EOF > bases_expect
0 identity
0 48 base2
b 98 base32
B 66 base32upper
c 99 base32pad
C 67 base32padupper
f 102 base16
F 70 base16upper
k 107 base36
K 75 base36upper
m 109 base64
M 77 base64pad
t 116 base32hexpad
T 84 base32hexpadupper
u 117 base64url
U 85 base64urlpad
v 118 base32hex
V 86 base32hexupper
z 122 base58btc
Z 90 base58flickr
0 identity
0 48 base2
b 98 base32
B 66 base32upper
c 99 base32pad
C 67 base32padupper
f 102 base16
F 70 base16upper
k 107 base36
K 75 base36upper
m 109 base64
M 77 base64pad
t 116 base32hexpad
T 84 base32hexpadupper
u 117 base64url
U 85 base64urlpad
v 118 base32hex
V 86 base32hexupper
z 122 base58btc
Z 90 base58flickr
128640 base256emoji
EOF
# TODO: expose same cmd under multibase?
test_expect_success "multibase list" '
cut -c 10- bases_expect > expect &&
cut -c 12- bases_expect > expect &&
ipfs multibase list > actual &&
test_cmp expect actual
'