Commit 2bc018ba authored by Kevin Atkinson's avatar Kevin Atkinson

Replace DecodeV2 with ExtractEncoding

parent eb97b6f3
......@@ -69,15 +69,16 @@ outer:
}
}
for _, cidStr := range args[1:] {
base, cid, err := c.DecodeV2(cidStr)
cid, err := c.Decode(cidStr)
if err != nil {
fmt.Fprintf(os.Stdout, "!INVALID_CID!\n")
errorMsg("%s: %v", cidStr, err)
// Don't abort on a bad cid
continue
}
if newBase != -1 {
base = newBase
base := newBase
if newBase == -1 {
base, _ = c.ExtractEncoding(cidStr)
}
if verConv != nil {
cid, err = verConv(cid)
......
......@@ -10,7 +10,7 @@ import (
func TestCidConv(t *testing.T) {
cidv0 := "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn"
cidv1 := "zdj7WbTaiJT1fgatdet9Ei9iDB5hdCxkbVyhyh8YTUnXMiwYi"
_, cid, err := c.DecodeV2(cidv0)
cid, err := c.Decode(cidv0)
if err != nil {
t.Fatal(err)
}
......@@ -34,7 +34,7 @@ func TestCidConv(t *testing.T) {
func TestBadCidConv(t *testing.T) {
// this cid is a raw leaf and should not be able to convert to cidv0
cidv1 := "zb2rhhzX7uSKrtQ2ZZXFAabKiKFYZrJqKY2KE1cJ8yre2GSWZ"
_, cid, err := c.DecodeV2(cidv1)
cid, err := c.Decode(cidv1)
if err != nil {
t.Fatal(err)
}
......
......@@ -55,13 +55,14 @@ func TestFmt(t *testing.T) {
}
func testFmt(t *testing.T, cidStr string, newBase mb.Encoding, fmtStr string, result string) {
base, cid, err := DecodeV2(cidStr)
if newBase != -1 {
base = newBase
}
cid, err := Decode(cidStr)
if err != nil {
t.Fatal(err)
}
base := newBase
if newBase == -1 {
base, _ = ExtractEncoding(cidStr)
}
str, err := Format(fmtStr, base, cid)
if err != nil {
t.Fatal(err)
......@@ -70,4 +71,3 @@ func testFmt(t *testing.T, cidStr string, newBase mb.Encoding, fmtStr string, re
t.Error(fmt.Sprintf("expected: %s; but got: %s", result, str))
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment