Skip to content

Commit

Permalink
Merge pull request #13 from ipfs/feat/cidv1-default-base32
Browse files Browse the repository at this point in the history
default cidv1 to base32
  • Loading branch information
Stebalien authored May 13, 2019
2 parents 7a289d9 + 6927839 commit 8d1606f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cidenc/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Encoder struct {

// Default return a new default encoder
func Default() Encoder {
return Encoder{Base: mbase.MustNewEncoder(mbase.Base58BTC)}
return Encoder{Base: mbase.MustNewEncoder(mbase.Base32)}
}

// Encode encodes the cid using the parameters of the Encoder
Expand Down
8 changes: 8 additions & 0 deletions cidenc/encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,12 @@ func TestCidEncoder(t *testing.T) {
testRecode(enc, cidv0str, cidb32str)
testRecode(enc, cidv1str, cidb32str)
testRecode(enc, cidb32str, cidb32str)

enc = Default()
testEncode(enc, cidv0, cidv0str)
testEncode(enc, cidv1, cidb32str)
testRecode(enc, cidv0str, cidv0str)
testRecode(enc, cidv1str, cidb32str)
testRecode(enc, cidb32str, cidb32str)

}
2 changes: 1 addition & 1 deletion format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ bafybeietjgsrl3eqpqpcabv3g6iubytsifvq24xrrhd3juetskltgq7dja.
offset := 0
for len(buf) > 0 {
_, j, _, cidStr := ScanForCid(buf)
if cidStr != "" && cids[idx] != cidStr {
if cidStr != "" && cids[idx] != cidStr {
t.Fatalf("Scan failed, expected %s, got %s (idx=%d offset=%d)", cids[idx], cidStr, idx, offset)
}
buf = buf[j:]
Expand Down

0 comments on commit 8d1606f

Please sign in to comment.