diff --git a/crc16/main_test.go b/crc16/main_test.go new file mode 100644 index 0000000000..a1314a9fa1 --- /dev/null +++ b/crc16/main_test.go @@ -0,0 +1,20 @@ +package crc16 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestChecksum(t *testing.T) { + result := Checksum([]byte{0x12, 0x34, 0x56, 0x78, 0x90}) + assert.Equal(t, []byte{0xe6, 0x48}, result) +} + +func TestValidate(t *testing.T) { + err := Validate([]byte{0x12, 0x34, 0x56, 0x78, 0x90}, []byte{0xe6, 0x48}) + assert.NoError(t, err) + + err = Validate([]byte{0x12, 0x34, 0x56, 0x78, 0x90}, []byte{0xe7, 0x48}) + assert.ErrorIs(t, err, ErrInvalidChecksum) +} diff --git a/go.list b/go.list index a692515e77..12bc77f5f0 100644 --- a/go.list +++ b/go.list @@ -72,8 +72,8 @@ github.com/spf13/viper v0.0.0-20150621231900-db7ff930a189 github.com/stellar/go github.com/stellar/go-xdr v0.0.0-20201028102745-f80a23dac78a github.com/stellar/throttled v2.2.3-0.20190823235211-89d75816f59d+incompatible -github.com/stretchr/objx v0.1.1 -github.com/stretchr/testify v1.6.1 +github.com/stretchr/objx v0.3.0 +github.com/stretchr/testify v1.7.0 github.com/tyler-smith/go-bip39 v0.0.0-20180618194314-52158e4697b8 github.com/valyala/bytebufferpool v1.0.0 github.com/valyala/fasthttp v0.0.0-20170109085056-0a7f0a797cd6 diff --git a/go.mod b/go.mod index 9d9084f1be..15db0c82f5 100644 --- a/go.mod +++ b/go.mod @@ -62,7 +62,8 @@ require ( github.com/spf13/viper v0.0.0-20150621231900-db7ff930a189 github.com/stellar/go-xdr v0.0.0-20201028102745-f80a23dac78a github.com/stellar/throttled v2.2.3-0.20190823235211-89d75816f59d+incompatible - github.com/stretchr/testify v1.6.1 + github.com/stretchr/objx v0.3.0 // indirect + github.com/stretchr/testify v1.7.0 github.com/tyler-smith/go-bip39 v0.0.0-20180618194314-52158e4697b8 github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasthttp v0.0.0-20170109085056-0a7f0a797cd6 // indirect diff --git a/go.sum b/go.sum index abc984b5da..9481c87597 100644 --- a/go.sum +++ b/go.sum @@ -323,13 +323,16 @@ github.com/stellar/go-xdr v0.0.0-20201028102745-f80a23dac78a/go.mod h1:yoxyU/M8n github.com/stellar/throttled v2.2.3-0.20190823235211-89d75816f59d+incompatible h1:jMXXAcz6xTarGDQ4VtVbtERogcmDQw4RaE85Cr9CgoQ= github.com/stellar/throttled v2.2.3-0.20190823235211-89d75816f59d+incompatible/go.mod h1:7CJ23pXirXBJq45DqvO6clzTEGM/l1SfKrgrzLry8b4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.3.0 h1:NGXK3lHquSN08v5vWalVI/L8XU9hdzE/G6xsrze47As= +github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/tyler-smith/go-bip39 v0.0.0-20180618194314-52158e4697b8 h1:g3yQGZK+G6dfF/mw/SOwsTMzUVkpT4hB8pHxpbTXkKw= github.com/tyler-smith/go-bip39 v0.0.0-20180618194314-52158e4697b8/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=