Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

miner: fail early if core.NewBlockChain fails #26079

Merged
merged 1 commit into from
Nov 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion miner/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ func newTestWorkerBackend(t *testing.T, chainConfig *params.ChainConfig, engine
default:
t.Fatalf("unexpected consensus engine type: %T", engine)
}
chain, _ := core.NewBlockChain(db, &core.CacheConfig{TrieDirtyDisabled: true}, gspec, nil, engine, vm.Config{}, nil, nil)
chain, err := core.NewBlockChain(db, &core.CacheConfig{TrieDirtyDisabled: true}, gspec, nil, engine, vm.Config{}, nil, nil)
if err != nil {
t.Fatalf("core.NewBlockChain failed: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t.Fatalf("core.NewBlockChain failed: %v", err)
t.Fatal(err)

I mean, the stack track will tell us that core.NewBlockChain failed, right? Not a biggie though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No stack trace in the error I was getting:

[:prompt:] go test -v -run TestGenerateBlock
=== RUN TestGenerateBlockAndImportEthash
worker_test.go:139: core.NewBlockChain failed: genesis not found in chain
--- FAIL: TestGenerateBlockAndImportEthash (0.00s)
=== RUN TestGenerateBlockAndImportClique
worker_test.go:139: core.NewBlockChain failed: genesis not found in chain
--- FAIL: TestGenerateBlockAndImportClique (0.00s)
FAIL
exit status 1
FAIL github.com/ethereum/go-ethereum/miner 0.042s

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, my bad -- no stack trace, but the worker_test.go:139 shows exactly where the error occurred. But it doesn't really matter, you can leave it as is if you prefer.

}
txpool := txpool.NewTxPool(testTxPoolConfig, chainConfig, chain)

// Generate a small n-block chain and an uncle block for it
Expand Down