Skip to content

Commit

Permalink
update error string to be lower case
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerKSI committed Nov 28, 2023
1 parent d604218 commit 1f248df
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion client/grpc/oracle/proof/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func getProofsByKey(
}
}
default:
return nil, &ics23.ExistenceProof{}, &ics23.ExistenceProof{}, fmt.Errorf("Unknown proof ops found")
return nil, &ics23.ExistenceProof{}, &ics23.ExistenceProof{}, fmt.Errorf("unknown proof ops found")
}
}

Expand Down
5 changes: 2 additions & 3 deletions client/grpc/oracle/proof/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/runtime"

"github.com/bandprotocol/chain/v2/x/oracle/types"
oracletypes "github.com/bandprotocol/chain/v2/x/oracle/types"
)

// RegisterProofService registers the node gRPC service on the provided gRPC router.
Expand Down Expand Up @@ -89,7 +88,7 @@ func (s proofServer) Proof(ctx context.Context, req *QueryProofRequest) (*QueryP
}

// Unmarshal the value into a Result object
var rs oracletypes.Result
var rs types.Result
types.ModuleCdc.MustUnmarshal(value, &rs)

// Create an OracleDataProof object with the relevant information
Expand Down Expand Up @@ -195,7 +194,7 @@ func (s proofServer) MultiProof(ctx context.Context, req *QueryMultiProofRequest
}

// Unmarshal the value into a Result object
var rs oracletypes.Result
var rs types.Result
types.ModuleCdc.MustUnmarshal(value, &rs)

// Create an OracleDataProof object with the relevant information
Expand Down
4 changes: 2 additions & 2 deletions client/grpc/oracle/proof/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func recoverETHAddress(msg, sig, signer []byte) ([]byte, uint8, error) {
return crypto.PubkeyToAddress(*pubuc).Bytes(), 27 + i, nil
}
}
return nil, 0, fmt.Errorf("No match address found")
return nil, 0, fmt.Errorf("no match address found")
}

func GetPrefix(t tmproto.SignedMsgType, height int64, round int64) ([]byte, error) {
Expand Down Expand Up @@ -126,7 +126,7 @@ func GetSignaturesAndPrefix(info *types.SignedHeader) ([]TMSignature, CommonEnco
}
}
if len(addrs) == 0 {
return nil, CommonEncodedVotePart{}, fmt.Errorf("No valid precommit")
return nil, CommonEncodedVotePart{}, fmt.Errorf("no valid precommit")
}

signatures := make([]TMSignature, len(addrs))
Expand Down
2 changes: 1 addition & 1 deletion pkg/gzip/gzip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestUncompress(t *testing.T) {
require.NoError(t, err)
require.Equal(t, file1, accFile)

accFile, err = gzip.Uncompress(gzipFile, 2)
_, err = gzip.Uncompress(gzipFile, 2)
require.Error(t, err)

_, err = gzip.Uncompress(file1, 999)
Expand Down
10 changes: 6 additions & 4 deletions testing/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
commitmenttypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types"
ibchost "github.com/cosmos/ibc-go/v7/modules/core/24-host"
"github.com/cosmos/ibc-go/v7/modules/core/exported"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
"github.com/cosmos/ibc-go/v7/testing/mock"
Expand Down Expand Up @@ -325,7 +324,7 @@ func (chain *TestChain) SendReport(

// GetClientState retrieves the client state for the provided clientID. The client is
// expected to exist otherwise testing will fail.
func (chain *TestChain) GetClientState(clientID string) exported.ClientState {
func (chain *TestChain) GetClientState(clientID string) ibcexported.ClientState {
clientState, found := chain.App.GetIBCKeeper().ClientKeeper.GetClientState(chain.GetContext(), clientID)
require.True(chain.t, found)

Expand All @@ -334,7 +333,10 @@ func (chain *TestChain) GetClientState(clientID string) exported.ClientState {

// GetConsensusState retrieves the consensus state for the provided clientID and height.
// It will return a success boolean depending on if consensus state exists or not.
func (chain *TestChain) GetConsensusState(clientID string, height exported.Height) (exported.ConsensusState, bool) {
func (chain *TestChain) GetConsensusState(
clientID string,
height ibcexported.Height,
) (ibcexported.ConsensusState, bool) {
return chain.App.GetIBCKeeper().ClientKeeper.GetClientConsensusState(chain.GetContext(), clientID, height)
}

Expand All @@ -357,7 +359,7 @@ func (chain *TestChain) GetValsAtHeight(height int64) (*tmtypes.ValidatorSet, bo

// GetAcknowledgement retrieves an acknowledgement for the provided packet. If the
// acknowledgement does not exist then testing will fail.
func (chain *TestChain) GetAcknowledgement(packet exported.PacketI) []byte {
func (chain *TestChain) GetAcknowledgement(packet ibcexported.PacketI) []byte {
ack, found := chain.App.GetIBCKeeper().ChannelKeeper.GetPacketAcknowledgement(
chain.GetContext(),
packet.GetDestPort(),
Expand Down
2 changes: 1 addition & 1 deletion x/bank/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (k *WrappedBankKeeper) SetDistrKeeper(dk types.DistributionKeeper) {

// Logger returns a module-specific logger.
func (k WrappedBankKeeper) Logger(ctx sdk.Context) log.Logger {
return ctx.Logger().With("module", fmt.Sprint("x/wrappedbank"))
return ctx.Logger().With("module", "x/wrappedbank")
}

// BurnCoins moves the specified amount of coins from the given module name to
Expand Down
2 changes: 1 addition & 1 deletion x/oracle/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ func (k Querier) RequestVerification(
// Provided signature should be valid, which means this query request should be signed by the provided reporter
pk, err := hex.DecodeString(req.Reporter)
if err != nil || len(pk) != secp256k1.PubKeySize {
return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("unable to get reporter's public key"))
return nil, status.Error(codes.InvalidArgument, "unable to get reporter's public key")
}
reporterPubKey := secp256k1.PubKey(pk[:])

Expand Down
3 changes: 3 additions & 0 deletions x/oracle/keeper/owasm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ func TestPrepareRequestSuccessBasic(t *testing.T) {
sdk.WrapSDKContext(ctx),
authtypes.NewQueryAllBalancesRequest(testapp.FeePayer.Address, &query.PageRequest{}),
)
require.NoError(t, err)
feePayerBalances := balancesRes.Balances

// OracleScript#1: Prepare asks for DS#1,2,3 with ExtID#1,2,3 and calldata "beeb"
Expand Down Expand Up @@ -974,6 +975,7 @@ func TestCollectFeeBasicSuccess(t *testing.T) {
sdk.WrapSDKContext(ctx),
authtypes.NewQueryAllBalancesRequest(testapp.FeePayer.Address, &query.PageRequest{}),
)
require.NoError(t, err)
feePayerBalances := balancesRes.Balances
feePayerBalances[0].Amount = feePayerBalances[0].Amount.Sub(sdk.NewInt(3000000))

Expand Down Expand Up @@ -1006,6 +1008,7 @@ func TestCollectFeeBasicSuccessWithOtherAskCount(t *testing.T) {
sdk.WrapSDKContext(ctx),
authtypes.NewQueryAllBalancesRequest(testapp.FeePayer.Address, &query.PageRequest{}),
)
require.NoError(t, err)
feePayerBalances := balancesRes.Balances
feePayerBalances[0].Amount = feePayerBalances[0].Amount.Sub(sdk.NewInt(12000000))

Expand Down
4 changes: 2 additions & 2 deletions yoda/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ func GetEventValues(log sdk.ABCIMessageLog, evType string, evKey string) (res []
func GetEventValue(log sdk.ABCIMessageLog, evType string, evKey string) (string, error) {
values := GetEventValues(log, evType, evKey)
if len(values) == 0 {
return "", fmt.Errorf("Cannot find event with type: %s, key: %s", evType, evKey)
return "", fmt.Errorf("cannot find event with type: %s, key: %s", evType, evKey)
}
if len(values) > 1 {
return "", fmt.Errorf("Found more than one event with type: %s, key: %s", evType, evKey)
return "", fmt.Errorf("found more than one event with type: %s, key: %s", evType, evKey)
}
return values[0], nil
}
12 changes: 6 additions & 6 deletions yoda/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ func NewExecutor(executor string) (exec Executor, err error) {
case "rest":
exec = NewRestExec(base, timeout)
case "docker":
return nil, fmt.Errorf("Docker executor is currently not supported")
return nil, fmt.Errorf("docker executor is currently not supported")
default:
return nil, fmt.Errorf("Invalid executor name: %s, base: %s", name, base)
return nil, fmt.Errorf("invalid executor name: %s, base: %s", name, base)
}

// TODO: Remove hardcode in test execution
Expand Down Expand Up @@ -72,25 +72,25 @@ func NewExecutor(executor string) (exec Executor, err error) {
func parseExecutor(executorStr string) (name string, base string, timeout time.Duration, err error) {
executor := strings.SplitN(executorStr, ":", 2)
if len(executor) != 2 {
return "", "", 0, fmt.Errorf("Invalid executor, cannot parse executor: %s", executorStr)
return "", "", 0, fmt.Errorf("invalid executor, cannot parse executor: %s", executorStr)
}
u, err := url.Parse(executor[1])
if err != nil {
return "", "", 0, fmt.Errorf("Invalid url, cannot parse %s to url with error: %s", executor[1], err.Error())
return "", "", 0, fmt.Errorf("invalid url, cannot parse %s to url with error: %s", executor[1], err.Error())
}

query := u.Query()
timeoutStr := query.Get(flagQueryTimeout)
if timeoutStr == "" {
return "", "", 0, fmt.Errorf("Invalid timeout, executor requires query timeout")
return "", "", 0, fmt.Errorf("invalid timeout, executor requires query timeout")
}
// Remove timeout from query because we need to return `base`
query.Del(flagQueryTimeout)
u.RawQuery = query.Encode()

timeout, err = time.ParseDuration(timeoutStr)
if err != nil {
return "", "", 0, fmt.Errorf("Invalid timeout, cannot parse duration with error: %s", err.Error())
return "", "", 0, fmt.Errorf("invalid timeout, cannot parse duration with error: %s", err.Error())
}
return executor[0], u.String(), timeout, nil
}
2 changes: 2 additions & 0 deletions yoda/executor/multi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func TestMultiExecOneWorking(t *testing.T) {
exec2 := newMockExec([]byte("output"), 0, nil)
exec3 := newMockExec(nil, 0, errors.New("error3"))
exec, err := NewMultiExec([]Executor{exec1, exec2, exec3}, "round-robin")
require.NoError(t, err)
result, err := exec.Exec(nil, "", nil)
require.NoError(t, err)
require.Equal(t, ExecResult{Output: []byte("output"), Code: 0}, result)
Expand All @@ -96,6 +97,7 @@ func TestMultiExecAllErrors(t *testing.T) {
exec2 := newMockExec(nil, 0, errors.New("error2"))
exec3 := newMockExec(nil, 0, errors.New("error3"))
exec, err := NewMultiExec([]Executor{exec1, exec2, exec3}, "round-robin")
require.NoError(t, err)
_, err = exec.Exec(nil, "", nil)
require.EqualError(t, err, "MultiError: error1, error2, error3")
_, err = exec.Exec(nil, "", nil)
Expand Down
4 changes: 2 additions & 2 deletions yoda/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ func runCmd(c *Context) *cobra.Command {
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
if cfg.ChainID == "" {
return errors.New("Chain ID must not be empty")
return errors.New("chain ID must not be empty")
}
keys, err := kb.List()
if err != nil {
return err
}
if len(keys) == 0 {
return errors.New("No key available")
return errors.New("no key available")
}
c.keys = keys
c.validator, err = sdk.ValAddressFromBech32(cfg.Validator)
Expand Down

0 comments on commit 1f248df

Please sign in to comment.