dev: fix: bodyclose lint issues

This commit is contained in:
marcello33 2023-06-15 10:11:23 +02:00
parent 79ff0c17e1
commit 2c87219c80
7 changed files with 28 additions and 10 deletions

View file

@ -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)

View file

@ -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

View file

@ -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 {

View file

@ -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)
}

View file

@ -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)
}

View file

@ -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 {

View file

@ -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()
}