From f7319abf1b534a7aa6640d7b742125e4e666bb69 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 3 Feb 2020 20:51:57 -0800 Subject: [PATCH] fix: varints are msb Pull in a fixed varint decoding dep and fix the test. --- go.mod | 2 +- go.sum | 2 ++ multihash_test.go | 7 ++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index b8a16f4..9a825bb 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ require ( github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771 github.com/mr-tron/base58 v1.1.3 - github.com/multiformats/go-varint v0.0.4 + github.com/multiformats/go-varint v0.0.5 github.com/spaolacci/murmur3 v1.1.0 golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8 ) diff --git a/go.sum b/go.sum index a632362..6425497 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,8 @@ github.com/multiformats/go-varint v0.0.3 h1:1OZFaq4XbSNQE6ujqgr6/EIZlgHE7DmojAFs github.com/multiformats/go-varint v0.0.3/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= github.com/multiformats/go-varint v0.0.4 h1:CplQWhUouUgTZ53vNFE8VoWr2VjaKXci+xyrKyyFuSw= github.com/multiformats/go-varint v0.0.4/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= +github.com/multiformats/go-varint v0.0.5 h1:XVZwSo04Cs3j/jS0uAEPpT3JY6DzMcVLLoWOSnCxOjg= +github.com/multiformats/go-varint v0.0.5/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= diff --git a/multihash_test.go b/multihash_test.go index d008bf6..6e0653f 100644 --- a/multihash_test.go +++ b/multihash_test.go @@ -309,7 +309,12 @@ func TestBadVarint(t *testing.T) { t.Error("expected error from cut-off varint, got: ", err) } - _, err = Cast([]byte{128, 1}) + _, err = Cast([]byte{129, 0}) + if err != varint.ErrNotMinimal { + t.Error("expected error non-minimal varint, got: ", err) + } + + _, err = Cast([]byte{128, 0}) if err != varint.ErrNotMinimal { t.Error("expected error non-minimal varint, got: ", err) }