Skip to content

Commit

Permalink
chore: use errors.New to replace fmt.Errorf with no parameters (#3359)
Browse files Browse the repository at this point in the history
If you don't need to format the string, it is recommended to use
error.New()

---------

Co-authored-by: Andi <andi@1024.tt>
  • Loading branch information
ChengenH and Andi authored Apr 20, 2024
1 parent 4c15c1c commit 0c2cf97
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions test/txsim/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func NewAccountManager(
}

if len(records) == 0 {
return nil, fmt.Errorf("no accounts found in keyring")
return nil, errors.New("no accounts found in keyring")
}

am := &AccountManager{
Expand Down Expand Up @@ -118,7 +118,7 @@ func (am *AccountManager) findWealthiestAccount(ctx context.Context) (string, er
}

if wealthiestAddress == "" {
return "", fmt.Errorf("no suitable master account found")
return "", errors.New("no suitable master account found")
}

return wealthiestAddress, nil
Expand Down
11 changes: 6 additions & 5 deletions test/util/genesis/accounts.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package genesis

import (
"errors"
"fmt"
mrand "math/rand"
"time"
Expand Down Expand Up @@ -40,10 +41,10 @@ func NewKeyringAccounts(initBal int64, names ...string) []KeyringAccount {

func (ga *KeyringAccount) ValidateBasic() error {
if ga.Name == "" {
return fmt.Errorf("name cannot be empty")
return errors.New("name cannot be empty")
}
if ga.InitialTokens <= 0 {
return fmt.Errorf("initial tokens must be positive")
return errors.New("initial tokens must be positive")
}
return nil
}
Expand Down Expand Up @@ -76,13 +77,13 @@ func (v *Validator) ValidateBasic() error {
return err
}
if v.Stake <= 0 {
return fmt.Errorf("stake must be positive")
return errors.New("stake must be positive")
}
if v.ConsensusKey == nil {
return fmt.Errorf("consensus key cannot be empty")
return errors.New("consensus key cannot be empty")
}
if v.Stake > v.InitialTokens {
return fmt.Errorf("stake cannot be greater than initial tokens")
return errors.New("stake cannot be greater than initial tokens")
}
return nil
}
Expand Down

0 comments on commit 0c2cf97

Please sign in to comment.