chore: enable errcheck linter (#16406)

This commit is contained in:
ruthishvitwit
2023-07-12 08:58:27 +00:00
committed by GitHub
parent c5df6a355a
commit fd7e549a3c
140 changed files with 1019 additions and 617 deletions
+17 -16
View File
@@ -92,8 +92,8 @@ func (s *addressTestSuite) TestRandBech32AccAddrConsistency() {
pub := &ed25519.PubKey{Key: pubBz}
for i := 0; i < 1000; i++ {
rand.Read(pub.Key)
_, err := rand.Read(pub.Key)
s.Require().NoError(err)
acc := types.AccAddress(pub.Address())
res := types.AccAddress{}
@@ -101,7 +101,7 @@ func (s *addressTestSuite) TestRandBech32AccAddrConsistency() {
s.testMarshal(&acc, &res, acc.Marshal, (&res).Unmarshal)
str := acc.String()
res, err := types.AccAddressFromBech32(str)
res, err = types.AccAddressFromBech32(str)
s.Require().Nil(err)
s.Require().Equal(acc, res)
@@ -133,8 +133,8 @@ func (s *addressTestSuite) TestAddrCache() {
// Use a random key
pubBz := make([]byte, ed25519.PubKeySize)
pub := &ed25519.PubKey{Key: pubBz}
rand.Read(pub.Key)
_, err := rand.Read(pub.Key)
s.Require().NoError(err)
// Set SDK bech32 prefixes to 'osmo'
prefix := "osmo"
conf := types.GetConfig()
@@ -170,8 +170,8 @@ func (s *addressTestSuite) TestAddrCacheDisabled() {
// Use a random key
pubBz := make([]byte, ed25519.PubKeySize)
pub := &ed25519.PubKey{Key: pubBz}
rand.Read(pub.Key)
_, err := rand.Read(pub.Key)
s.Require().NoError(err)
// Set SDK bech32 prefixes to 'osmo'
prefix := "osmo"
conf := types.GetConfig()
@@ -202,8 +202,8 @@ func (s *addressTestSuite) TestValAddr() {
pub := &ed25519.PubKey{Key: pubBz}
for i := 0; i < 20; i++ {
rand.Read(pub.Key)
_, err := rand.Read(pub.Key)
s.Require().NoError(err)
acc := types.ValAddress(pub.Address())
res := types.ValAddress{}
@@ -211,7 +211,7 @@ func (s *addressTestSuite) TestValAddr() {
s.testMarshal(&acc, &res, acc.Marshal, (&res).Unmarshal)
str := acc.String()
res, err := types.ValAddressFromBech32(str)
res, err = types.ValAddressFromBech32(str)
s.Require().Nil(err)
s.Require().Equal(acc, res)
@@ -243,8 +243,8 @@ func (s *addressTestSuite) TestConsAddress() {
pub := &ed25519.PubKey{Key: pubBz}
for i := 0; i < 20; i++ {
rand.Read(pub.Key[:])
_, err := rand.Read(pub.Key[:])
s.Require().NoError(err)
acc := types.ConsAddress(pub.Address())
res := types.ConsAddress{}
@@ -252,7 +252,7 @@ func (s *addressTestSuite) TestConsAddress() {
s.testMarshal(&acc, &res, acc.Marshal, (&res).Unmarshal)
str := acc.String()
res, err := types.ConsAddressFromBech32(str)
res, err = types.ConsAddressFromBech32(str)
s.Require().Nil(err)
s.Require().Equal(acc, res)
@@ -293,7 +293,8 @@ func (s *addressTestSuite) TestConfiguredPrefix() {
pub := &ed25519.PubKey{Key: pubBz}
for length := 1; length < 10; length++ {
for times := 1; times < 20; times++ {
rand.Read(pub.Key[:])
_, err := rand.Read(pub.Key[:])
s.Require().NoError(err)
// Test if randomly generated prefix of a given length works
prefix := RandString(length)
@@ -347,8 +348,8 @@ func (s *addressTestSuite) TestConfiguredPrefix() {
func (s *addressTestSuite) TestAddressInterface() {
pubBz := make([]byte, ed25519.PubKeySize)
pub := &ed25519.PubKey{Key: pubBz}
rand.Read(pub.Key)
_, err := rand.Read(pub.Key)
s.Require().NoError(err)
addrs := []types.Address{
types.ConsAddress(pub.Address()),
types.ValAddress(pub.Address()),
+14 -3
View File
@@ -219,7 +219,12 @@ func TestManager_RegisterQueryServices(t *testing.T) {
mockAppModule1.EXPECT().RegisterServices(cfg).Times(1)
mockAppModule2.EXPECT().RegisterServices(cfg).Times(1)
require.NotPanics(t, func() { mm.RegisterServices(cfg) })
require.NotPanics(t, func() {
err := mm.RegisterServices(cfg)
if err != nil {
panic(err)
}
})
}
func TestManager_InitGenesis(t *testing.T) {
@@ -575,7 +580,10 @@ func (MockCoreAppModule) DefaultGenesis(target appmodule.GenesisTarget) error {
if err != nil {
return err
}
someFieldWriter.Write([]byte(`"someKey"`))
_, err = someFieldWriter.Write([]byte(`"someKey"`))
if err != nil {
return err
}
return someFieldWriter.Close()
}
@@ -602,7 +610,10 @@ func (MockCoreAppModule) ExportGenesis(ctx context.Context, target appmodule.Gen
if err != nil {
return err
}
wrt.Write([]byte(`"someKey"`))
_, err = wrt.Write([]byte(`"someKey"`))
if err != nil {
return err
}
return wrt.Close()
}