diff --git a/common/coin.go b/common/coin.go index b85fd4a2d6..4c875d97bb 100644 --- a/common/coin.go +++ b/common/coin.go @@ -1,11 +1,18 @@ package common -import "strconv" +import ( + "fmt" + "strconv" +) func GetCoinType(coin string) (CoinType, error) { coinInt, err := strconv.ParseInt(coin, 10, 32) if err != nil { return CoinType_Cmd, err } + if coinInt < 0 || coinInt > 3 { + return CoinType_Cmd, fmt.Errorf("invalid coin type %d", coinInt) + } + // #nosec G701 always in range return CoinType(coinInt), nil } diff --git a/x/crosschain/client/querytests/in_tx_tracker.go b/x/crosschain/client/querytests/in_tx_tracker.go index 97a581d91f..15c34b3bda 100644 --- a/x/crosschain/client/querytests/in_tx_tracker.go +++ b/x/crosschain/client/querytests/in_tx_tracker.go @@ -49,6 +49,7 @@ func (s *CliTestSuite) TestListInTxTrackersByChain() { s.Run("ByOffset", func() { step := 2 for i := 0; i < len(objs); i += step { + // #nosec G701 always positive args := request(nil, uint64(i), uint64(step), false, 5) out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListInTxTrackerByChain(), args) s.Require().NoError(err) @@ -64,6 +65,7 @@ func (s *CliTestSuite) TestListInTxTrackersByChain() { step := 2 var next []byte for i := 0; i < len(objs); i += step { + // #nosec G701 always positive args := request(next, 0, uint64(step), false, 5) out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListInTxTrackerByChain(), args) s.Require().NoError(err) @@ -84,7 +86,7 @@ func (s *CliTestSuite) TestListInTxTrackersByChain() { var resp types.QueryAllInTxTrackerByChainResponse s.Require().NoError(s.network.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) s.Require().NoError(err) - s.Require().Equal(len(objs), int(resp.Pagination.Total)) + s.Require().Equal(uint64(len(objs)), resp.Pagination.Total) s.Require().ElementsMatch(nullify.Fill(objs), nullify.Fill(resp.InTxTracker), ) @@ -96,6 +98,6 @@ func (s *CliTestSuite) TestListInTxTrackersByChain() { var resp types.QueryAllInTxTrackerByChainResponse s.Require().NoError(s.network.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) s.Require().NoError(err) - s.Require().Equal(0, int(resp.Pagination.Total)) + s.Require().Equal(uint64(0), resp.Pagination.Total) }) } diff --git a/zetaclient/inbound_tracker.go b/zetaclient/inbound_tracker.go index 802ef0ad45..8e6c7c01d2 100644 --- a/zetaclient/inbound_tracker.go +++ b/zetaclient/inbound_tracker.go @@ -89,6 +89,7 @@ func (ob *BitcoinChainClient) CheckReceiptForBtcTxHash(txHash string, vote bool) if err != nil { return "", err } + // #nosec G701 always positive event, err := GetBtcEvent(*tx, tss, uint64(block.Height), &ob.logger.WatchInTx) if err != nil { return "", err