mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 07:06:42 +00:00
dev: fix: bodyclose lint issues
This commit is contained in:
parent
79ff0c17e1
commit
2c87219c80
7 changed files with 28 additions and 10 deletions
|
|
@ -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)
|
return fmt.Errorf("invalid transaction nonce: got %d, want %d", tx.Nonce(), nonce)
|
||||||
}
|
}
|
||||||
// Include tx in chain
|
// Include tx in chain
|
||||||
|
// nolint : contextcheck
|
||||||
blocks, receipts := core.GenerateChain(b.config, block, ethash.NewFaker(), b.database, 1, func(number int, block *core.BlockGen) {
|
blocks, receipts := core.GenerateChain(b.config, block, ethash.NewFaker(), b.database, 1, func(number int, block *core.BlockGen) {
|
||||||
for _, tx := range b.pendingBlock.Transactions() {
|
for _, tx := range b.pendingBlock.Transactions() {
|
||||||
block.AddTxWithChain(b.blockchain, tx)
|
block.AddTxWithChain(b.blockchain, tx)
|
||||||
|
|
|
||||||
|
|
@ -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
|
vmerr error // vm errors do not effect consensus and are therefore not assigned to err
|
||||||
)
|
)
|
||||||
if contractCreation {
|
if contractCreation {
|
||||||
|
// nolint : contextcheck
|
||||||
ret, _, st.gasRemaining, vmerr = st.evm.Create(sender, msg.Data, st.gasRemaining, msg.Value)
|
ret, _, st.gasRemaining, vmerr = st.evm.Create(sender, msg.Data, st.gasRemaining, msg.Value)
|
||||||
} else {
|
} else {
|
||||||
// Increment the nonce for the next transaction
|
// Increment the nonce for the next transaction
|
||||||
|
|
|
||||||
|
|
@ -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)
|
return nil, nil, fmt.Errorf("block #%d not found", next)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nolint : contextcheck
|
||||||
_, _, _, err := eth.blockchain.Processor().Process(current, statedb, vm.Config{}, nil)
|
_, _, _, err := eth.blockchain.Processor().Process(current, statedb, vm.Config{}, nil)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -290,6 +290,7 @@ func (api *API) TraceChain(ctx context.Context, start, end rpc.BlockNumber, conf
|
||||||
}
|
}
|
||||||
sub := notifier.CreateSubscription()
|
sub := notifier.CreateSubscription()
|
||||||
|
|
||||||
|
// nolint : contextcheck
|
||||||
resCh := api.traceChain(from, to, config, notifier.Closed())
|
resCh := api.traceChain(from, to, config, notifier.Closed())
|
||||||
go func() {
|
go func() {
|
||||||
for result := range resCh {
|
for result := range resCh {
|
||||||
|
|
@ -1276,6 +1277,7 @@ func (api *API) traceTx(ctx context.Context, message *core.Message, txctx *Conte
|
||||||
|
|
||||||
if *config.BorTx {
|
if *config.BorTx {
|
||||||
callmsg := prepareCallMessage(*message)
|
callmsg := prepareCallMessage(*message)
|
||||||
|
// nolint : contextcheck
|
||||||
if _, err := statefull.ApplyBorMessage(*vmenv, callmsg); err != nil {
|
if _, err := statefull.ApplyBorMessage(*vmenv, callmsg); err != nil {
|
||||||
return nil, fmt.Errorf("tracing failed: %w", err)
|
return nil, fmt.Errorf("tracing failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
// Not yet the searched for transaction, execute on top of the current state
|
||||||
vmenv := vm.NewEVM(blockContext, txContext, statedb, leth.blockchain.Config(), vm.Config{})
|
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 {
|
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)
|
return nil, vm.BlockContext{}, nil, nil, fmt.Errorf("transaction %#x failed: %v", tx.Hash(), err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -557,19 +557,21 @@ func (test rpcPrefixTest) check(t *testing.T, node *Node) {
|
||||||
if node.WSEndpoint() != wsBase+test.wsPrefix {
|
if node.WSEndpoint() != wsBase+test.wsPrefix {
|
||||||
t.Errorf("Error: node has wrong WSEndpoint %q", node.WSEndpoint())
|
t.Errorf("Error: node has wrong WSEndpoint %q", node.WSEndpoint())
|
||||||
}
|
}
|
||||||
|
var resp *http.Response
|
||||||
for _, path := range test.wantHTTP {
|
for _, path := range test.wantHTTP {
|
||||||
resp := rpcRequest(t, httpBase+path, testMethod)
|
resp = rpcRequest(t, httpBase+path, testMethod)
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
t.Errorf("Error: %s: bad status code %d, want 200", path, resp.StatusCode)
|
t.Errorf("Error: %s: bad status code %d, want 200", path, resp.StatusCode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
for _, path := range test.wantNoHTTP {
|
for _, path := range test.wantNoHTTP {
|
||||||
resp := rpcRequest(t, httpBase+path, testMethod)
|
resp = rpcRequest(t, httpBase+path, testMethod)
|
||||||
if resp.StatusCode != 404 {
|
if resp.StatusCode != 404 {
|
||||||
t.Errorf("Error: %s: bad status code %d, want 404", path, resp.StatusCode)
|
t.Errorf("Error: %s: bad status code %d, want 404", path, resp.StatusCode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
for _, path := range test.wantWS {
|
for _, path := range test.wantWS {
|
||||||
err := wsRequest(t, wsBase+path)
|
err := wsRequest(t, wsBase+path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,15 @@ func TestCorsHandler(t *testing.T) {
|
||||||
defer srv.stop()
|
defer srv.stop()
|
||||||
url := "http://" + srv.listenAddr()
|
url := "http://" + srv.listenAddr()
|
||||||
|
|
||||||
resp := rpcRequest(t, url, testMethod, "origin", "test.com")
|
var resp, resp2 *http.Response
|
||||||
assert.Equal(t, "test.com", resp.Header.Get("Access-Control-Allow-Origin"))
|
|
||||||
|
|
||||||
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"))
|
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.
|
// TestVhosts makes sure vhosts are properly handled on the http server.
|
||||||
|
|
@ -58,11 +62,15 @@ func TestVhosts(t *testing.T) {
|
||||||
defer srv.stop()
|
defer srv.stop()
|
||||||
url := "http://" + srv.listenAddr()
|
url := "http://" + srv.listenAddr()
|
||||||
|
|
||||||
resp := rpcRequest(t, url, testMethod, "host", "test")
|
var resp, resp2 *http.Response
|
||||||
assert.Equal(t, resp.StatusCode, http.StatusOK)
|
|
||||||
|
|
||||||
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)
|
assert.Equal(t, resp2.StatusCode, http.StatusForbidden)
|
||||||
|
defer resp2.Body.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
type originTest struct {
|
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()}))
|
return fmt.Sprintf("Bearer \t%v", issueToken(secret, nil, testClaim{"iat": time.Now().Unix()}))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
var resp *http.Response
|
||||||
for i, tokenFn := range expFail {
|
for i, tokenFn := range expFail {
|
||||||
token := tokenFn()
|
token := tokenFn()
|
||||||
if err := wsRequest(t, wsUrl, "Authorization", token); err == nil {
|
if err := wsRequest(t, wsUrl, "Authorization", token); err == nil {
|
||||||
|
|
@ -442,11 +451,12 @@ func TestJWT(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
token = tokenFn()
|
token = tokenFn()
|
||||||
resp := rpcRequest(t, htUrl, testMethod, "Authorization", token)
|
resp = rpcRequest(t, htUrl, testMethod, "Authorization", token)
|
||||||
if resp.StatusCode != http.StatusUnauthorized {
|
if resp.StatusCode != http.StatusUnauthorized {
|
||||||
t.Errorf("tc %d-http, token '%v': expected not to allow, got %v", i, token, resp.StatusCode)
|
t.Errorf("tc %d-http, token '%v': expected not to allow, got %v", i, token, resp.StatusCode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
srv.stop()
|
srv.stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue