linter: (1/2) enable errcheck (#5064)

## Description

partially cleanup in preparation for errcheck

i ignored a bunch of defer errors in tests but with the update to go 1.14 we can use `t.Cleanup(func() { if err := <>; err != nil {..}}` to cover those errors, I will do this in pr number two of enabling errcheck.

ref #5059
This commit is contained in:
Marko
2020-07-01 17:13:11 +02:00
committed by GitHub
parent 8ec8385427
commit 7e2cc1db5e
35 changed files with 289 additions and 200 deletions

View File

@@ -37,7 +37,11 @@ func BenchmarkSigning(b *testing.B, priv crypto.PrivKey) {
message := []byte("Hello, world!")
b.ResetTimer()
for i := 0; i < b.N; i++ {
priv.Sign(message)
_, err := priv.Sign(message)
if err != nil {
b.FailNow()
}
}
}

View File

@@ -5,6 +5,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto/tmhash"
)
@@ -12,13 +13,15 @@ import (
func TestHash(t *testing.T) {
testVector := []byte("abc")
hasher := tmhash.New()
hasher.Write(testVector)
_, err := hasher.Write(testVector)
require.NoError(t, err)
bz := hasher.Sum(nil)
bz2 := tmhash.Sum(testVector)
hasher = sha256.New()
hasher.Write(testVector)
_, err = hasher.Write(testVector)
require.NoError(t, err)
bz3 := hasher.Sum(nil)
assert.Equal(t, bz, bz2)
@@ -28,13 +31,15 @@ func TestHash(t *testing.T) {
func TestHashTruncated(t *testing.T) {
testVector := []byte("abc")
hasher := tmhash.NewTruncated()
hasher.Write(testVector)
_, err := hasher.Write(testVector)
require.NoError(t, err)
bz := hasher.Sum(nil)
bz2 := tmhash.SumTruncated(testVector)
hasher = sha256.New()
hasher.Write(testVector)
_, err = hasher.Write(testVector)
require.NoError(t, err)
bz3 := hasher.Sum(nil)
bz3 = bz3[:tmhash.TruncatedSize]