Skip to content

Commit

Permalink
Fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Apr 20, 2024
1 parent caeef08 commit c0fd32a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 74 deletions.
3 changes: 1 addition & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
tmos "github.com/cometbft/cometbft/libs/os"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/grpc/node"
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
Expand Down Expand Up @@ -790,7 +789,7 @@ func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig
}

func (app *App) RegisterNodeService(clientCtx client.Context) {
node.RegisterNodeService(clientCtx, app.GRPCQueryRouter())
nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter())
}

// RegisterSwaggerAPI registers swagger route with API Server
Expand Down
44 changes: 2 additions & 42 deletions testutil/network/network_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,9 @@ import (
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
_ "github.com/cosmos/cosmos-sdk/x/auth"
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
_ "github.com/cosmos/cosmos-sdk/x/bank"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
"github.com/cosmos/cosmos-sdk/x/genutil"
_ "github.com/cosmos/cosmos-sdk/x/params"
_ "github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

Expand Down Expand Up @@ -331,12 +325,12 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
clientDir := filepath.Join(network.BaseDir, nodeDirName, "simcli")
gentxsDir := filepath.Join(network.BaseDir, "gentxs")

err := os.MkdirAll(filepath.Join(nodeDir, "config"), 0o755)
err := os.MkdirAll(filepath.Join(nodeDir, "config"), 0o755) // #nosec G301
if err != nil {
return nil, err
}

err = os.MkdirAll(clientDir, 0o755)
err = os.MkdirAll(clientDir, 0o755) // #nosec G301
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -605,40 +599,6 @@ func (n *Network) WaitForHeightWithTimeout(h int64, t time.Duration) (int64, err
}
}

// RetryForBlocks will wait for the next block and execute the function provided.
// It will do this until the function returns a nil error or until the number of
// blocks has been reached.
func (n *Network) RetryForBlocks(retryFunc func() error, blocks int) error {
for i := 0; i < blocks; i++ {
n.WaitForNextBlock()
err := retryFunc()
if err == nil {
return nil
}
// we've reached the last block to wait, return the error
if i == blocks-1 {
return err
}
}
return nil
}

// WaitForNextBlock waits for the next block to be committed, returning an error
// upon failure.
func (n *Network) WaitForNextBlock() error {
lastBlock, err := n.LatestHeight()
if err != nil {
return err
}

_, err = n.WaitForHeight(lastBlock + 1)
if err != nil {
return err
}

return err
}

// Cleanup removes the root testing (temporary) directory and stops both the
// Tendermint and API services. It allows other callers to create and start
// test networks. This method must be called when a test is finished, typically
Expand Down
49 changes: 19 additions & 30 deletions x/crosschain/client/cli/cli_out_tx_tracker_test.go
Original file line number Diff line number Diff line change
@@ -1,36 +1,25 @@
package cli_test

import (
"fmt"
"testing"
// func networkWithOutTxTrackerObjects(t *testing.T, n int) (*network.Network, []types.OutTxTracker) {
// t.Helper()
// cfg := network.DefaultConfig()
// state := types.GenesisState{}
// require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state))

"github.com/stretchr/testify/require"
"github.com/zeta-chain/zetacore/app"
"github.com/zeta-chain/zetacore/testutil/network"
"github.com/zeta-chain/zetacore/testutil/nullify"
"github.com/zeta-chain/zetacore/x/crosschain/types"
)

func networkWithOutTxTrackerObjects(t *testing.T, n int) (*network.Network, []types.OutTxTracker) {
t.Helper()
cfg := network.DefaultConfig()
state := types.GenesisState{}
require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state))

for i := 0; i < n; i++ {
outTxTracker := types.OutTxTracker{
Index: fmt.Sprintf("testchain-%d", i),
}
nullify.Fill(&outTxTracker)
state.OutTxTrackerList = append(state.OutTxTrackerList, outTxTracker)
}
buf, err := cfg.Codec.MarshalJSON(&state)
require.NoError(t, err)
cfg.GenesisState[types.ModuleName] = buf
//cfg.GenesisState = network.SetupZetaGenesisState(t, cfg.GenesisState, cfg.Codec)
net, err := network.New(t, app.NodeDir, cfg)
return net, state.OutTxTrackerList
}
// for i := 0; i < n; i++ {
// outTxTracker := types.OutTxTracker{
// Index: fmt.Sprintf("testchain-%d", i),
// }
// nullify.Fill(&outTxTracker)
// state.OutTxTrackerList = append(state.OutTxTrackerList, outTxTracker)
// }
// buf, err := cfg.Codec.MarshalJSON(&state)
// require.NoError(t, err)
// cfg.GenesisState[types.ModuleName] = buf
// //cfg.GenesisState = network.SetupZetaGenesisState(t, cfg.GenesisState, cfg.Codec)
// net, err := network.New(t, app.NodeDir, cfg)
// return net, state.OutTxTrackerList
// }

//
//func TestShowOutTxTracker(t *testing.T) {
Expand Down

0 comments on commit c0fd32a

Please sign in to comment.