chore: run modernize (#24356)
This commit is contained in:
+2
-2
@@ -14,7 +14,7 @@ import (
|
||||
// Takes a network, wait for two blocks and fetch the transaction from its hash
|
||||
func CheckTxCode(network *network.Network, clientCtx client.Context, txHash string, expectedCode uint32) error {
|
||||
// wait for 2 blocks
|
||||
for i := 0; i < 2; i++ {
|
||||
for range 2 {
|
||||
if err := network.WaitForNextBlock(); err != nil {
|
||||
return fmt.Errorf("failed to wait for next block: %w", err)
|
||||
}
|
||||
@@ -42,7 +42,7 @@ func CheckTxCode(network *network.Network, clientCtx client.Context, txHash stri
|
||||
// Takes a network, wait for two blocks and fetch the transaction from its hash
|
||||
func GetTxResponse(network *network.Network, clientCtx client.Context, txHash string) (sdk.TxResponse, error) {
|
||||
// wait for 2 blocks
|
||||
for i := 0; i < 2; i++ {
|
||||
for range 2 {
|
||||
if err := network.WaitForNextBlock(); err != nil {
|
||||
return sdk.TxResponse{}, fmt.Errorf("failed to wait for next block: %w", err)
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
// RequireProtoDeepEqual fails the test t if p1 and p2 are not equivalent protobuf messages.
|
||||
// Where p1 and p2 are proto.Message or slices of proto.Message.
|
||||
func RequireProtoDeepEqual(t *testing.T, p1, p2 interface{}) {
|
||||
func RequireProtoDeepEqual(t *testing.T, p1, p2 any) {
|
||||
t.Helper()
|
||||
require.Empty(t, cmp.Diff(p1, p2, protocmp.Transform()))
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ func (m *MockAnteDecorator) AnteHandle(ctx types.Context, tx types.Tx, simulate
|
||||
}
|
||||
|
||||
// AnteHandle indicates an expected call of AnteHandle.
|
||||
func (mr *MockAnteDecoratorMockRecorder) AnteHandle(ctx, tx, simulate, next interface{}) *gomock.Call {
|
||||
func (mr *MockAnteDecoratorMockRecorder) AnteHandle(ctx, tx, simulate, next any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AnteHandle", reflect.TypeOf((*MockAnteDecorator)(nil).AnteHandle), ctx, tx, simulate, next)
|
||||
}
|
||||
@@ -84,7 +84,7 @@ func (m *MockPostDecorator) PostHandle(ctx types.Context, tx types.Tx, simulate,
|
||||
}
|
||||
|
||||
// PostHandle indicates an expected call of PostHandle.
|
||||
func (mr *MockPostDecoratorMockRecorder) PostHandle(ctx, tx, simulate, success, next interface{}) *gomock.Call {
|
||||
func (mr *MockPostDecoratorMockRecorder) PostHandle(ctx, tx, simulate, success, next any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PostHandle", reflect.TypeOf((*MockPostDecorator)(nil).PostHandle), ctx, tx, simulate, success, next)
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ var (
|
||||
|
||||
func init() {
|
||||
closeFns := []func() error{}
|
||||
for i := 0; i < 200; i++ {
|
||||
for range 200 {
|
||||
_, port, closeFn, err := FreeTCPAddr()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -304,8 +304,8 @@ type (
|
||||
// Logger is a network logger interface that exposes testnet-level Log() methods for an in-process testing network
|
||||
// This is not to be confused with logging that may happen at an individual node or validator level
|
||||
Logger interface {
|
||||
Log(args ...interface{})
|
||||
Logf(format string, args ...interface{})
|
||||
Log(args ...any)
|
||||
Logf(format string, args ...any)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -329,12 +329,12 @@ type CLILogger struct {
|
||||
}
|
||||
|
||||
// Log logs given args.
|
||||
func (s CLILogger) Log(args ...interface{}) {
|
||||
func (s CLILogger) Log(args ...any) {
|
||||
s.cmd.Println(args...)
|
||||
}
|
||||
|
||||
// Logf logs given args according to a format specifier.
|
||||
func (s CLILogger) Logf(format string, args ...interface{}) {
|
||||
func (s CLILogger) Logf(format string, args ...any) {
|
||||
s.cmd.Printf(format, args...)
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
|
||||
buf := bufio.NewReader(os.Stdin)
|
||||
|
||||
// generate private keys, node IDs, and initial transactions
|
||||
for i := 0; i < cfg.NumValidators; i++ {
|
||||
for i := range cfg.NumValidators {
|
||||
appCfg := srvconfig.DefaultConfig()
|
||||
appCfg.Pruning = cfg.PruningStrategy
|
||||
appCfg.MinGasPrices = cfg.MinGasPrices
|
||||
@@ -757,7 +757,7 @@ func (n *Network) WaitForHeightWithTimeout(h int64, t time.Duration) (int64, err
|
||||
// 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++ {
|
||||
for i := range blocks {
|
||||
_ = n.WaitForNextBlock() // ignore the error as we use the retry for validation
|
||||
err := retryFunc()
|
||||
if err == nil {
|
||||
|
||||
@@ -128,7 +128,7 @@ func startInProcess(cfg Config, val *Validator) error {
|
||||
func collectGenFiles(cfg Config, vals []*Validator, outputDir string) error {
|
||||
genTime := cmttime.Now()
|
||||
|
||||
for i := 0; i < cfg.NumValidators; i++ {
|
||||
for i := range cfg.NumValidators {
|
||||
cmtCfg := vals[i].Ctx.Config
|
||||
|
||||
nodeDir := filepath.Join(outputDir, vals[i].Moniker, "simd")
|
||||
@@ -194,7 +194,7 @@ func initGenFiles(cfg Config, genAccounts []authtypes.GenesisAccount, genBalance
|
||||
}
|
||||
|
||||
// generate empty genesis files for each validator and save
|
||||
for i := 0; i < cfg.NumValidators; i++ {
|
||||
for i := range cfg.NumValidators {
|
||||
if err := appGenesis.SaveAs(genFiles[i]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ func CreateIncrementalAccounts(accNum int) []sdk.AccAddress {
|
||||
// CreateRandomAccounts is a strategy used by addTestAddrs() in order to generated addresses in random order.
|
||||
func CreateRandomAccounts(accNum int) []sdk.AccAddress {
|
||||
testAddrs := make([]sdk.AccAddress, accNum)
|
||||
for i := 0; i < accNum; i++ {
|
||||
for i := range accNum {
|
||||
pk := ed25519.GenPrivKey().PubKey()
|
||||
testAddrs[i] = sdk.AccAddress(pk.Address())
|
||||
}
|
||||
|
||||
@@ -96,13 +96,13 @@ func DefaultStartUpConfig() StartupConfig {
|
||||
|
||||
// Setup initializes a new runtime.App and can inject values into extraOutputs.
|
||||
// It uses SetupWithConfiguration under the hood.
|
||||
func Setup(appConfig depinject.Config, extraOutputs ...interface{}) (*runtime.App, error) {
|
||||
func Setup(appConfig depinject.Config, extraOutputs ...any) (*runtime.App, error) {
|
||||
return SetupWithConfiguration(appConfig, DefaultStartUpConfig(), extraOutputs...)
|
||||
}
|
||||
|
||||
// SetupAtGenesis initializes a new runtime.App at genesis and can inject values into extraOutputs.
|
||||
// It uses SetupWithConfiguration under the hood.
|
||||
func SetupAtGenesis(appConfig depinject.Config, extraOutputs ...interface{}) (*runtime.App, error) {
|
||||
func SetupAtGenesis(appConfig depinject.Config, extraOutputs ...any) (*runtime.App, error) {
|
||||
cfg := DefaultStartUpConfig()
|
||||
cfg.AtGenesis = true
|
||||
return SetupWithConfiguration(appConfig, cfg, extraOutputs...)
|
||||
@@ -136,7 +136,7 @@ func NextBlock(app *runtime.App, ctx sdk.Context, jumpTime time.Duration) (sdk.C
|
||||
// SetupWithConfiguration initializes a new runtime.App. A Nop logger is set in runtime.App.
|
||||
// appConfig defines the application configuration (f.e. app_config.go).
|
||||
// extraOutputs defines the extra outputs to be assigned by the dependency injector (depinject).
|
||||
func SetupWithConfiguration(appConfig depinject.Config, startupConfig StartupConfig, extraOutputs ...interface{}) (*runtime.App, error) {
|
||||
func SetupWithConfiguration(appConfig depinject.Config, startupConfig StartupConfig, extraOutputs ...any) (*runtime.App, error) {
|
||||
// create the app with depinject
|
||||
var (
|
||||
app *runtime.App
|
||||
@@ -285,17 +285,17 @@ func GenesisStateWithValSet(
|
||||
type EmptyAppOptions struct{}
|
||||
|
||||
// Get implements AppOptions
|
||||
func (ao EmptyAppOptions) Get(o string) interface{} {
|
||||
func (ao EmptyAppOptions) Get(o string) any {
|
||||
return nil
|
||||
}
|
||||
|
||||
// AppOptionsMap is a stub implementing AppOptions which can get data from a map
|
||||
type AppOptionsMap map[string]interface{}
|
||||
type AppOptionsMap map[string]any
|
||||
|
||||
func (m AppOptionsMap) Get(key string) interface{} {
|
||||
func (m AppOptionsMap) Get(key string) any {
|
||||
v, ok := m[key]
|
||||
if !ok {
|
||||
return interface{}(nil)
|
||||
return any(nil)
|
||||
}
|
||||
|
||||
return v
|
||||
|
||||
@@ -123,7 +123,7 @@ func PrintStats(db dbm.DB) {
|
||||
// GetSimulationLog unmarshals the KVPair's Value to the corresponding type based on the
|
||||
// each's module store key and the prefix bytes of the KVPair's key.
|
||||
func GetSimulationLog(storeName string, sdr simtypes.StoreDecoderRegistry, kvAs, kvBs []kv.Pair) (log string) {
|
||||
for i := 0; i < len(kvAs); i++ {
|
||||
for i := range kvAs {
|
||||
if len(kvAs[i].Value) == 0 && len(kvBs[i].Value) == 0 {
|
||||
// skip if the value doesn't have any bytes
|
||||
continue
|
||||
|
||||
@@ -65,7 +65,7 @@ func AppStateFnWithExtendedCbs(
|
||||
cdc codec.JSONCodec,
|
||||
simManager *module.SimulationManager,
|
||||
genesisState map[string]json.RawMessage,
|
||||
moduleStateCb func(moduleName string, genesisState interface{}),
|
||||
moduleStateCb func(moduleName string, genesisState any),
|
||||
rawStateCb func(rawState map[string]json.RawMessage),
|
||||
) simtypes.AppStateFn {
|
||||
return func(
|
||||
|
||||
Reference in New Issue
Block a user