From 4d059db7bbdc641e3ae2eef379f6a73bfeb3620e Mon Sep 17 00:00:00 2001 From: liuyueyangxmu Date: Wed, 26 Nov 2025 16:40:11 +0800 Subject: [PATCH] refactor: omit unnecessary reassignment Signed-off-by: liuyueyangxmu --- e2e/e2etests/legacy/test_rate_limiter.go | 1 - e2e/e2etests/test_stress_sui_deposit.go | 1 - e2e/e2etests/test_stress_sui_withdraw.go | 1 - e2e/utils/zetacore.go | 1 - pkg/chains/chain_test.go | 1 - pkg/os/path_test.go | 2 -- x/crosschain/genesis.go | 3 --- x/crosschain/keeper/abci_test.go | 4 ---- x/crosschain/keeper/cctx_test.go | 2 -- x/crosschain/keeper/grpc_query_gas_price_test.go | 1 - x/crosschain/keeper/grpc_query_last_block_height_test.go | 1 - x/crosschain/keeper/msg_server_vote_inbound_tx_test.go | 1 - x/crosschain/keeper/msg_server_vote_outbound_tx_test.go | 1 - x/crosschain/simulation/decoders_test.go | 1 - x/emissions/simulation/decoders_test.go | 1 - x/fungible/keeper/evm_hooks_test.go | 1 - x/fungible/simulation/decoders_test.go | 1 - x/fungible/types/message_pause_zrc20_test.go | 1 - x/fungible/types/message_unpause_zrc20_test.go | 1 - x/observer/genesis.go | 1 - x/observer/keeper/grpc_query_node_account_test.go | 1 - x/observer/keeper/grpc_query_nonces_test.go | 1 - x/observer/keeper/grpc_query_tss_test.go | 2 -- x/observer/simulation/decoders_test.go | 1 - x/observer/types/ballot_test.go | 3 --- 25 files changed, 35 deletions(-) diff --git a/e2e/e2etests/legacy/test_rate_limiter.go b/e2e/e2etests/legacy/test_rate_limiter.go index f348d9403c..7e5b2a7ddb 100644 --- a/e2e/e2etests/legacy/test_rate_limiter.go +++ b/e2e/e2etests/legacy/test_rate_limiter.go @@ -109,7 +109,6 @@ func createAndWaitWithdraws(r *runner.E2ERunner, withdrawType withdrawType, with g, ctx := errgroup.WithContext(r.Ctx) for i, tx := range txs { // capture the loop variables - tx, i := tx, i // start a goroutine to wait for the withdraw to be mined g.Go(func() error { diff --git a/e2e/e2etests/test_stress_sui_deposit.go b/e2e/e2etests/test_stress_sui_deposit.go index 19fed096b6..8477365aaf 100644 --- a/e2e/e2etests/test_stress_sui_deposit.go +++ b/e2e/e2etests/test_stress_sui_deposit.go @@ -25,7 +25,6 @@ func TestStressSuiDeposit(r *runner.E2ERunner, args []string) { // send the SUI deposit transactions for i := range numDeposits { // each goroutine captures its own copy of i - i := i resp := r.SuiDepositSUI(r.SuiGateway.PackageID(), r.EVMAddress(), math.NewUintFromBigInt(amount)) r.Logger.Print("index %d: started with tx hash: %s", i, resp.Digest) diff --git a/e2e/e2etests/test_stress_sui_withdraw.go b/e2e/e2etests/test_stress_sui_withdraw.go index bd58f15cda..b9fe5b0430 100644 --- a/e2e/e2etests/test_stress_sui_withdraw.go +++ b/e2e/e2etests/test_stress_sui_withdraw.go @@ -44,7 +44,6 @@ func TestStressSuiWithdraw(r *runner.E2ERunner, args []string) { revertOptions := gatewayzevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)} for i := range numWithdrawals { // each goroutine captures its own copy of i - i := i tx := r.SuiWithdraw(signer.Address(), amount, r.SUIZRC20Addr, revertOptions) // wait for receipt before next withdrawal to avoid race condition diff --git a/e2e/utils/zetacore.go b/e2e/utils/zetacore.go index 43fde410a9..aa16deecba 100644 --- a/e2e/utils/zetacore.go +++ b/e2e/utils/zetacore.go @@ -141,7 +141,6 @@ func WaitCctxsMinedByInboundHash( cctxs = make([]*crosschaintypes.CrossChainTx, 0, len(res.CrossChainTxs)) allFound := true for j, cctx := range res.CrossChainTxs { - cctx := cctx if !cctx.CctxStatus.Status.IsTerminal() { // prevent spamming logs if i%20 == 0 { diff --git a/pkg/chains/chain_test.go b/pkg/chains/chain_test.go index a23fa9cbdf..4385f10a6e 100644 --- a/pkg/chains/chain_test.go +++ b/pkg/chains/chain_test.go @@ -236,7 +236,6 @@ func TestChain_EncodeAddress(t *testing.T) { } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { s, err := tc.chain.EncodeAddress(tc.b) if tc.wantErr { diff --git a/pkg/os/path_test.go b/pkg/os/path_test.go index 086c0105bc..18e4f57e6b 100644 --- a/pkg/os/path_test.go +++ b/pkg/os/path_test.go @@ -39,7 +39,6 @@ func TestResolveHome(t *testing.T) { } for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { pathOut, err := zetaos.ExpandHomeDir(tc.pathIn) require.NoError(t, err) @@ -74,7 +73,6 @@ func TestFileExists(t *testing.T) { } for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { exists := zetaos.FileExists(tc.file) require.Equal(t, tc.expected, exists) diff --git a/x/crosschain/genesis.go b/x/crosschain/genesis.go index 41999fa0e6..5bde0b4440 100644 --- a/x/crosschain/genesis.go +++ b/x/crosschain/genesis.go @@ -70,21 +70,18 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { // Get all gas prices gasPriceList := k.GetAllGasPrice(ctx) for _, elem := range gasPriceList { - elem := elem genesis.GasPriceList = append(genesis.GasPriceList, &elem) } // Get all last block heights lastBlockHeightList := k.GetAllLastBlockHeight(ctx) for _, elem := range lastBlockHeightList { - elem := elem genesis.LastBlockHeightList = append(genesis.LastBlockHeightList, &elem) } // Get all send sendList := k.GetAllCrossChainTx(ctx) for _, elem := range sendList { - elem := elem genesis.CrossChainTxs = append(genesis.CrossChainTxs, &elem) } diff --git a/x/crosschain/keeper/abci_test.go b/x/crosschain/keeper/abci_test.go index 42f2f08b96..d1dbdeba9a 100644 --- a/x/crosschain/keeper/abci_test.go +++ b/x/crosschain/keeper/abci_test.go @@ -192,7 +192,6 @@ func Test_CheckAndUpdateCCTXGasPrice(t *testing.T) { }, } for _, tc := range tt { - tc := tc t.Run(tc.name, func(t *testing.T) { // ARRANGE k, ctx := testkeeper.CrosschainKeeperAllMocks(t) @@ -405,7 +404,6 @@ func Test_CheckAndUpdateCCTXGasPriceEVM(t *testing.T) { }, } for _, tc := range tt { - tc := tc t.Run(tc.name, func(t *testing.T) { // ARRANGE k, ctx := testkeeper.CrosschainKeeperAllMocks(t) @@ -572,7 +570,6 @@ func Test_CheckAndUpdateCCTXGasPriceBTC(t *testing.T) { }, } for _, tc := range tt { - tc := tc t.Run(tc.name, func(t *testing.T) { // ARRANGE k, ctx := testkeeper.CrosschainKeeperAllMocks(t) @@ -747,7 +744,6 @@ func Test_IsCCTXGasPriceUpdateSupported(t *testing.T) { } for _, tc := range tt { - tc := tc t.Run(tc.name, func(t *testing.T) { isSupported := keeper.IsCCTXGasPriceUpdateSupported(tc.chainID, []chains.Chain{}) require.Equal(t, tc.isSupport, isSupported) diff --git a/x/crosschain/keeper/cctx_test.go b/x/crosschain/keeper/cctx_test.go index ba62d0d6c2..78a293b9ac 100644 --- a/x/crosschain/keeper/cctx_test.go +++ b/x/crosschain/keeper/cctx_test.go @@ -128,7 +128,6 @@ func TestCCTXs(t *testing.T) { }, } for _, tt := range cctxsTest { - tt := tt t.Run(tt.TestName, func(t *testing.T) { keeper, ctx, _, zk := keepertest.CrosschainKeeper(t) keeper.SetZetaAccounting(ctx, types.ZetaAccounting{AbortedZetaAmount: math.ZeroUint()}) @@ -227,7 +226,6 @@ func TestCCTXQuerySingle(t *testing.T) { err: status.Error(codes.InvalidArgument, "invalid request"), }, } { - tc := tc t.Run(tc.desc, func(t *testing.T) { response, err := keeper.Cctx(wctx, tc.request) if tc.err != nil { diff --git a/x/crosschain/keeper/grpc_query_gas_price_test.go b/x/crosschain/keeper/grpc_query_gas_price_test.go index 58b22e37a6..3df97152fd 100644 --- a/x/crosschain/keeper/grpc_query_gas_price_test.go +++ b/x/crosschain/keeper/grpc_query_gas_price_test.go @@ -49,7 +49,6 @@ func TestGasPriceQuerySingle(t *testing.T) { err: fmt.Errorf("strconv.Atoi: parsing \"abc\": invalid syntax"), }, } { - tc := tc t.Run(tc.desc, func(t *testing.T) { response, err := k.GasPrice(wctx, tc.request) if tc.err != nil { diff --git a/x/crosschain/keeper/grpc_query_last_block_height_test.go b/x/crosschain/keeper/grpc_query_last_block_height_test.go index 2ba8fae76e..e7becaab7d 100644 --- a/x/crosschain/keeper/grpc_query_last_block_height_test.go +++ b/x/crosschain/keeper/grpc_query_last_block_height_test.go @@ -44,7 +44,6 @@ func TestLastBlockHeightQuerySingle(t *testing.T) { err: status.Error(codes.InvalidArgument, "invalid request"), }, } { - tc := tc t.Run(tc.desc, func(t *testing.T) { response, err := k.LastBlockHeight(wctx, tc.request) if tc.err != nil { diff --git a/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go b/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go index f5ce6e214f..1b70130867 100644 --- a/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go +++ b/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go @@ -308,7 +308,6 @@ func TestStatus_UpdateCctxStatus(t *testing.T) { }, } for _, test := range tt { - test := test t.Run(test.Name, func(t *testing.T) { test.Status.UpdateStatusAndErrorMessages(test.NonErrStatus, types.StatusMessages{StatusMessage: test.Msg}) if test.IsErr { diff --git a/x/crosschain/keeper/msg_server_vote_outbound_tx_test.go b/x/crosschain/keeper/msg_server_vote_outbound_tx_test.go index f3551f3524..2f1696c480 100644 --- a/x/crosschain/keeper/msg_server_vote_outbound_tx_test.go +++ b/x/crosschain/keeper/msg_server_vote_outbound_tx_test.go @@ -93,7 +93,6 @@ func TestKeeper_FundGasStabilityPoolFromRemainingFees(t *testing.T) { } for _, tc := range tt { - tc := tc t.Run(tc.name, func(t *testing.T) { k, ctx := keepertest.CrosschainKeeperAllMocks(t) fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) diff --git a/x/crosschain/simulation/decoders_test.go b/x/crosschain/simulation/decoders_test.go index 8c22cf9707..c8fed24b62 100644 --- a/x/crosschain/simulation/decoders_test.go +++ b/x/crosschain/simulation/decoders_test.go @@ -75,7 +75,6 @@ func TestDecodeStore(t *testing.T) { } for i, tt := range tests { - i, tt := i, tt t.Run(tt.name, func(t *testing.T) { require.Equal(t, tt.expectedLog, dec(kvPairs.Pairs[i], kvPairs.Pairs[i])) }) diff --git a/x/emissions/simulation/decoders_test.go b/x/emissions/simulation/decoders_test.go index b072cad9db..f144be0f04 100644 --- a/x/emissions/simulation/decoders_test.go +++ b/x/emissions/simulation/decoders_test.go @@ -40,7 +40,6 @@ func TestDecodeStore(t *testing.T) { } for i, tt := range tests { - i, tt := i, tt t.Run(tt.name, func(t *testing.T) { require.Equal(t, tt.expectedLog, dec(kvPairs.Pairs[i], kvPairs.Pairs[i])) }) diff --git a/x/fungible/keeper/evm_hooks_test.go b/x/fungible/keeper/evm_hooks_test.go index f1dba2fd6c..836a804203 100644 --- a/x/fungible/keeper/evm_hooks_test.go +++ b/x/fungible/keeper/evm_hooks_test.go @@ -96,7 +96,6 @@ func TestKeeper_CheckPausedZRC20(t *testing.T) { } for _, tc := range tt { - tc := tc t.Run(tc.name, func(t *testing.T) { k, ctx, _, _ := keepertest.FungibleKeeper(t) diff --git a/x/fungible/simulation/decoders_test.go b/x/fungible/simulation/decoders_test.go index c2e4cdfd44..14087a9bfd 100644 --- a/x/fungible/simulation/decoders_test.go +++ b/x/fungible/simulation/decoders_test.go @@ -35,7 +35,6 @@ func TestDecodeStore(t *testing.T) { } for i, tt := range tests { - i, tt := i, tt t.Run(tt.name, func(t *testing.T) { require.Equal(t, tt.expectedLog, dec(kvPairs.Pairs[i], kvPairs.Pairs[i])) }) diff --git a/x/fungible/types/message_pause_zrc20_test.go b/x/fungible/types/message_pause_zrc20_test.go index 3efb9716a4..56583aea4e 100644 --- a/x/fungible/types/message_pause_zrc20_test.go +++ b/x/fungible/types/message_pause_zrc20_test.go @@ -74,7 +74,6 @@ func TestMsgPauseZRC20_ValidateBasic(t *testing.T) { }, } for _, tc := range tt { - tc := tc t.Run(tc.name, func(t *testing.T) { err := tc.msg.ValidateBasic() if tc.wantErr { diff --git a/x/fungible/types/message_unpause_zrc20_test.go b/x/fungible/types/message_unpause_zrc20_test.go index af5d4c12ca..66c124b49a 100644 --- a/x/fungible/types/message_unpause_zrc20_test.go +++ b/x/fungible/types/message_unpause_zrc20_test.go @@ -74,7 +74,6 @@ func TestMsgUnpauseZRC20_ValidateBasic(t *testing.T) { }, } for _, tc := range tt { - tc := tc t.Run(tc.name, func(t *testing.T) { err := tc.msg.ValidateBasic() if tc.wantErr { diff --git a/x/observer/genesis.go b/x/observer/genesis.go index 1910e8074d..f2aa8000d1 100644 --- a/x/observer/genesis.go +++ b/x/observer/genesis.go @@ -144,7 +144,6 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { nodeAccountList := k.GetAllNodeAccount(ctx) nodeAccounts := make([]*types.NodeAccount, len(nodeAccountList)) for i, elem := range nodeAccountList { - elem := elem nodeAccounts[i] = &elem } diff --git a/x/observer/keeper/grpc_query_node_account_test.go b/x/observer/keeper/grpc_query_node_account_test.go index 6c7894974e..0bb686a2ea 100644 --- a/x/observer/keeper/grpc_query_node_account_test.go +++ b/x/observer/keeper/grpc_query_node_account_test.go @@ -44,7 +44,6 @@ func TestNodeAccountQuerySingle(t *testing.T) { err: status.Error(codes.InvalidArgument, "invalid request"), }, } { - tc := tc t.Run(tc.desc, func(t *testing.T) { response, err := k.NodeAccount(wctx, tc.request) if tc.err != nil { diff --git a/x/observer/keeper/grpc_query_nonces_test.go b/x/observer/keeper/grpc_query_nonces_test.go index 8ae23e8110..78a52a41c8 100644 --- a/x/observer/keeper/grpc_query_nonces_test.go +++ b/x/observer/keeper/grpc_query_nonces_test.go @@ -47,7 +47,6 @@ func TestChainNoncesQuerySingle(t *testing.T) { err: status.Error(codes.InvalidArgument, "invalid request"), }, } { - tc := tc t.Run(tc.desc, func(t *testing.T) { response, err := k.ChainNonces(wctx, tc.request) if tc.err != nil { diff --git a/x/observer/keeper/grpc_query_tss_test.go b/x/observer/keeper/grpc_query_tss_test.go index 2cd66ff868..4936012ef6 100644 --- a/x/observer/keeper/grpc_query_tss_test.go +++ b/x/observer/keeper/grpc_query_tss_test.go @@ -44,7 +44,6 @@ func TestTSSQuerySingle(t *testing.T) { response: &types.QueryGetTSSResponse{TSS: tss}, }, } { - tc := tc t.Run(tc.desc, func(t *testing.T) { if !tc.skipSettingTss { k.SetTSS(ctx, tss) @@ -81,7 +80,6 @@ func TestTSSQueryHistory(t *testing.T) { err: nil, }, } { - tc := tc t.Run(tc.desc, func(t *testing.T) { tssList := sample.TssList(tc.tssCount) for _, tss := range tssList { diff --git a/x/observer/simulation/decoders_test.go b/x/observer/simulation/decoders_test.go index d5a397d3ad..92e471c445 100644 --- a/x/observer/simulation/decoders_test.go +++ b/x/observer/simulation/decoders_test.go @@ -103,7 +103,6 @@ func TestNewDecodeStore(t *testing.T) { } for i, tt := range tests { - i, tt := i, tt t.Run(tt.name, func(t *testing.T) { require.Equal(t, tt.expectedLog, dec(kvPairs.Pairs[i], kvPairs.Pairs[i])) }) diff --git a/x/observer/types/ballot_test.go b/x/observer/types/ballot_test.go index d7f6a0c93a..a62aac5c18 100644 --- a/x/observer/types/ballot_test.go +++ b/x/observer/types/ballot_test.go @@ -259,7 +259,6 @@ func TestBallot_AddVote(t *testing.T) { }, } for _, test := range tt { - test := test t.Run(test.name, func(t *testing.T) { ballot := Ballot{ Index: "index", @@ -396,7 +395,6 @@ func TestBallot_IsFinalizingVote(t *testing.T) { }, } for _, test := range tt { - test := test t.Run(test.name, func(t *testing.T) { ballot := Ballot{ @@ -733,7 +731,6 @@ func Test_BuildRewardsDistribution(t *testing.T) { }, }} for _, test := range tt { - test := test t.Run(test.name, func(t *testing.T) { result := BuildRewardsDistribution(test.ballotList) require.Equal(t, test.expectedMap, result)