all: improve some error strings (#29842)

This commit is contained in:
trillo 2024-05-28 20:44:40 +09:00 committed by GitHub
parent ea6c16007c
commit caafa93598
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 11 additions and 11 deletions

@ -65,7 +65,7 @@ func convertPayload[T payloadType](payload T, parentRoot *zrntcommon.Root) (*typ
block := types.NewBlockWithHeader(&header).WithBody(types.Body{Transactions: transactions, Withdrawals: withdrawals}) block := types.NewBlockWithHeader(&header).WithBody(types.Body{Transactions: transactions, Withdrawals: withdrawals})
if hash := block.Hash(); hash != expectedHash { if hash := block.Hash(); hash != expectedHash {
return nil, fmt.Errorf("Sanity check failed, payload hash does not match (expected %x, got %x)", expectedHash, hash) return nil, fmt.Errorf("sanity check failed, payload hash does not match (expected %x, got %x)", expectedHash, hash)
} }
return block, nil return block, nil
} }

@ -552,7 +552,7 @@ func listWallets(c *cli.Context) error {
// accountImport imports a raw hexadecimal private key via CLI. // accountImport imports a raw hexadecimal private key via CLI.
func accountImport(c *cli.Context) error { func accountImport(c *cli.Context) error {
if c.Args().Len() != 1 { if c.Args().Len() != 1 {
return errors.New("<keyfile> must be given as first argument.") return errors.New("<keyfile> must be given as first argument")
} }
internalApi, ui, err := initInternalApi(c) internalApi, ui, err := initInternalApi(c)
if err != nil { if err != nil {

@ -228,7 +228,7 @@ func (b *testChainIndexBackend) Process(ctx context.Context, header *types.Heade
b.t.Error("Unexpected call to Process") b.t.Error("Unexpected call to Process")
// Can't use Fatal since this is not the test's goroutine. // Can't use Fatal since this is not the test's goroutine.
// Returning error stops the chainIndexer's updateLoop // Returning error stops the chainIndexer's updateLoop
return errors.New("Unexpected call to Process") return errors.New("unexpected call to Process")
case b.processCh <- header.Number.Uint64(): case b.processCh <- header.Number.Uint64():
} }
return nil return nil

@ -379,7 +379,7 @@ func assertEqual(orig *Transaction, cpy *Transaction) error {
} }
if orig.AccessList() != nil { if orig.AccessList() != nil {
if !reflect.DeepEqual(orig.AccessList(), cpy.AccessList()) { if !reflect.DeepEqual(orig.AccessList(), cpy.AccessList()) {
return errors.New("access list wrong!") return errors.New("access list wrong")
} }
} }
return nil return nil

@ -208,7 +208,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
} }
t, err := tracers.LiveDirectory.New(config.VMTrace, traceConfig) t, err := tracers.LiveDirectory.New(config.VMTrace, traceConfig)
if err != nil { if err != nil {
return nil, fmt.Errorf("Failed to create tracer %s: %v", config.VMTrace, err) return nil, fmt.Errorf("failed to create tracer %s: %v", config.VMTrace, err)
} }
vmConfig.Tracer = t vmConfig.Tracer = t
} }

@ -979,11 +979,11 @@ func TestSimultaneousNewBlock(t *testing.T) {
defer wg.Done() defer wg.Done()
if newResp, err := api.NewPayloadV1(*execData); err != nil { if newResp, err := api.NewPayloadV1(*execData); err != nil {
errMu.Lock() errMu.Lock()
testErr = fmt.Errorf("Failed to insert block: %w", err) testErr = fmt.Errorf("failed to insert block: %w", err)
errMu.Unlock() errMu.Unlock()
} else if newResp.Status != "VALID" { } else if newResp.Status != "VALID" {
errMu.Lock() errMu.Lock()
testErr = fmt.Errorf("Failed to insert block: %v", newResp.Status) testErr = fmt.Errorf("failed to insert block: %v", newResp.Status)
errMu.Unlock() errMu.Unlock()
} }
}() }()
@ -1018,7 +1018,7 @@ func TestSimultaneousNewBlock(t *testing.T) {
defer wg.Done() defer wg.Done()
if _, err := api.ForkchoiceUpdatedV1(fcState, nil); err != nil { if _, err := api.ForkchoiceUpdatedV1(fcState, nil); err != nil {
errMu.Lock() errMu.Lock()
testErr = fmt.Errorf("Failed to insert block: %w", err) testErr = fmt.Errorf("failed to insert block: %w", err)
errMu.Unlock() errMu.Unlock()
} }
}() }()

@ -97,7 +97,7 @@ func benchmarkLogger(b *testing.B, l Logger) {
tt = time.Now() tt = time.Now()
bigint = big.NewInt(100) bigint = big.NewInt(100)
nilbig *big.Int nilbig *big.Int
err = errors.New("Oh nooes it's crap") err = errors.New("oh nooes it's crap")
) )
b.ReportAllocs() b.ReportAllocs()
b.ResetTimer() b.ResetTimer()
@ -126,7 +126,7 @@ func TestLoggerOutput(t *testing.T) {
tt = time.Time{} tt = time.Time{}
bigint = big.NewInt(100) bigint = big.NewInt(100)
nilbig *big.Int nilbig *big.Int
err = errors.New("Oh nooes it's crap") err = errors.New("oh nooes it's crap")
smallUint = uint256.NewInt(500_000) smallUint = uint256.NewInt(500_000)
bigUint = &uint256.Int{0xff, 0xff, 0xff, 0xff} bigUint = &uint256.Int{0xff, 0xff, 0xff, 0xff}
) )
@ -150,7 +150,7 @@ func TestLoggerOutput(t *testing.T) {
have := out.String() have := out.String()
t.Logf("output %v", out.String()) t.Logf("output %v", out.String())
want := `INFO [11-07|19:14:33.821] This is a message foo=123 bytes="[0 0 0 0 0 0 0 0 0 0]" bonk="a string with text" time=0001-01-01T00:00:00+0000 bigint=100 nilbig=<nil> err="Oh nooes it's crap" struct="{A:Foo B:12}" struct="{A:Foo\nLinebreak B:122}" ptrstruct="&{A:Foo B:12}" smalluint=500,000 bigUint=1,600,660,942,523,603,594,864,898,306,482,794,244,293,965,082,972,225,630,372,095 want := `INFO [11-07|19:14:33.821] This is a message foo=123 bytes="[0 0 0 0 0 0 0 0 0 0]" bonk="a string with text" time=0001-01-01T00:00:00+0000 bigint=100 nilbig=<nil> err="oh nooes it's crap" struct="{A:Foo B:12}" struct="{A:Foo\nLinebreak B:122}" ptrstruct="&{A:Foo B:12}" smalluint=500,000 bigUint=1,600,660,942,523,603,594,864,898,306,482,794,244,293,965,082,972,225,630,372,095
` `
if !bytes.Equal([]byte(have)[25:], []byte(want)[25:]) { if !bytes.Equal([]byte(have)[25:], []byte(want)[25:]) {
t.Errorf("Error\nhave: %q\nwant: %q", have, want) t.Errorf("Error\nhave: %q\nwant: %q", have, want)