diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index 60d21f31fd..b8f93b9594 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -693,6 +693,7 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa return fmt.Errorf("invalid transaction nonce: got %d, want %d", tx.Nonce(), nonce) } // Include tx in chain + // nolint : contextcheck blocks, receipts := core.GenerateChain(b.config, block, ethash.NewFaker(), b.database, 1, func(number int, block *core.BlockGen) { for _, tx := range b.pendingBlock.Transactions() { block.AddTxWithChain(b.blockchain, tx) diff --git a/core/state_transition.go b/core/state_transition.go index 87490a9bf4..9e272a44ae 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -391,6 +391,7 @@ func (st *StateTransition) TransitionDb(interruptCtx context.Context) (*Executio vmerr error // vm errors do not effect consensus and are therefore not assigned to err ) if contractCreation { + // nolint : contextcheck ret, _, st.gasRemaining, vmerr = st.evm.Create(sender, msg.Data, st.gasRemaining, msg.Value) } else { // Increment the nonce for the next transaction diff --git a/eth/state_accessor.go b/eth/state_accessor.go index 55d2ffe914..c4db017607 100644 --- a/eth/state_accessor.go +++ b/eth/state_accessor.go @@ -160,6 +160,7 @@ func (eth *Ethereum) StateAtBlock(ctx context.Context, block *types.Block, reexe return nil, nil, fmt.Errorf("block #%d not found", next) } + // nolint : contextcheck _, _, _, err := eth.blockchain.Processor().Process(current, statedb, vm.Config{}, nil) if err != nil { diff --git a/eth/tracers/api.go b/eth/tracers/api.go index b376fc7b1d..193060b95e 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -290,6 +290,7 @@ func (api *API) TraceChain(ctx context.Context, start, end rpc.BlockNumber, conf } sub := notifier.CreateSubscription() + // nolint : contextcheck resCh := api.traceChain(from, to, config, notifier.Closed()) go func() { for result := range resCh { @@ -1276,6 +1277,7 @@ func (api *API) traceTx(ctx context.Context, message *core.Message, txctx *Conte if *config.BorTx { callmsg := prepareCallMessage(*message) + // nolint : contextcheck if _, err := statefull.ApplyBorMessage(*vmenv, callmsg); err != nil { return nil, fmt.Errorf("tracing failed: %w", err) } diff --git a/les/state_accessor.go b/les/state_accessor.go index 075235238f..1c6d2bf8bf 100644 --- a/les/state_accessor.go +++ b/les/state_accessor.go @@ -69,6 +69,7 @@ func (leth *LightEthereum) stateAtTransaction(ctx context.Context, block *types. } // Not yet the searched for transaction, execute on top of the current state vmenv := vm.NewEVM(blockContext, txContext, statedb, leth.blockchain.Config(), vm.Config{}) + // nolint : contextcheck if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(tx.Gas()), context.Background()); err != nil { return nil, vm.BlockContext{}, nil, nil, fmt.Errorf("transaction %#x failed: %v", tx.Hash(), err) } diff --git a/node/node_test.go b/node/node_test.go index 04810a815b..1f1c3461a7 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -557,19 +557,21 @@ func (test rpcPrefixTest) check(t *testing.T, node *Node) { if node.WSEndpoint() != wsBase+test.wsPrefix { t.Errorf("Error: node has wrong WSEndpoint %q", node.WSEndpoint()) } - + var resp *http.Response for _, path := range test.wantHTTP { - resp := rpcRequest(t, httpBase+path, testMethod) + resp = rpcRequest(t, httpBase+path, testMethod) if resp.StatusCode != 200 { t.Errorf("Error: %s: bad status code %d, want 200", path, resp.StatusCode) } } + defer resp.Body.Close() for _, path := range test.wantNoHTTP { - resp := rpcRequest(t, httpBase+path, testMethod) + resp = rpcRequest(t, httpBase+path, testMethod) if resp.StatusCode != 404 { t.Errorf("Error: %s: bad status code %d, want 404", path, resp.StatusCode) } } + defer resp.Body.Close() for _, path := range test.wantWS { err := wsRequest(t, wsBase+path) if err != nil { diff --git a/node/rpcstack_test.go b/node/rpcstack_test.go index 22ca4b7ee8..72a7973122 100644 --- a/node/rpcstack_test.go +++ b/node/rpcstack_test.go @@ -45,11 +45,15 @@ func TestCorsHandler(t *testing.T) { defer srv.stop() url := "http://" + srv.listenAddr() - resp := rpcRequest(t, url, testMethod, "origin", "test.com") - assert.Equal(t, "test.com", resp.Header.Get("Access-Control-Allow-Origin")) + var resp, resp2 *http.Response - resp2 := rpcRequest(t, url, testMethod, "origin", "bad") + resp = rpcRequest(t, url, testMethod, "origin", "test.com") + assert.Equal(t, "test.com", resp.Header.Get("Access-Control-Allow-Origin")) + defer resp.Body.Close() + + resp2 = rpcRequest(t, url, testMethod, "origin", "bad") assert.Equal(t, "", resp2.Header.Get("Access-Control-Allow-Origin")) + defer resp2.Body.Close() } // TestVhosts makes sure vhosts are properly handled on the http server. @@ -58,11 +62,15 @@ func TestVhosts(t *testing.T) { defer srv.stop() url := "http://" + srv.listenAddr() - resp := rpcRequest(t, url, testMethod, "host", "test") - assert.Equal(t, resp.StatusCode, http.StatusOK) + var resp, resp2 *http.Response - resp2 := rpcRequest(t, url, testMethod, "host", "bad") + resp = rpcRequest(t, url, testMethod, "host", "test") + assert.Equal(t, resp.StatusCode, http.StatusOK) + defer resp.Body.Close() + + resp2 = rpcRequest(t, url, testMethod, "host", "bad") assert.Equal(t, resp2.StatusCode, http.StatusForbidden) + defer resp2.Body.Close() } type originTest struct { @@ -435,6 +443,7 @@ func TestJWT(t *testing.T) { return fmt.Sprintf("Bearer \t%v", issueToken(secret, nil, testClaim{"iat": time.Now().Unix()})) }, } + var resp *http.Response for i, tokenFn := range expFail { token := tokenFn() if err := wsRequest(t, wsUrl, "Authorization", token); err == nil { @@ -442,11 +451,12 @@ func TestJWT(t *testing.T) { } token = tokenFn() - resp := rpcRequest(t, htUrl, testMethod, "Authorization", token) + resp = rpcRequest(t, htUrl, testMethod, "Authorization", token) if resp.StatusCode != http.StatusUnauthorized { t.Errorf("tc %d-http, token '%v': expected not to allow, got %v", i, token, resp.StatusCode) } } + defer resp.Body.Close() srv.stop() }