mirror of https://github.com/status-im/op-geth.git
cmd/geth, core/rawdb: add missing error checks (#19871)
* Added missing error checks Add error handling where we assign err a value, but don't check for it being nil. * core/rawdb: tiny style nit
This commit is contained in:
parent
cc3ef1e4f4
commit
57fc1d21e1
|
@ -533,6 +533,9 @@ func (api *RetestethAPI) mineBlock() error {
|
|||
}
|
||||
}
|
||||
block, err := api.engine.FinalizeAndAssemble(api.blockchain, header, statedb, txs, []*types.Header{}, receipts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return api.importBlock(block)
|
||||
}
|
||||
|
||||
|
|
|
@ -272,7 +272,9 @@ func (t *freezerTable) repair() error {
|
|||
if newLastIndex.filenum != lastIndex.filenum {
|
||||
// Release earlier opened file
|
||||
t.releaseFile(lastIndex.filenum)
|
||||
t.head, err = t.openFile(newLastIndex.filenum, openFreezerFileForAppend)
|
||||
if t.head, err = t.openFile(newLastIndex.filenum, openFreezerFileForAppend); err != nil {
|
||||
return err
|
||||
}
|
||||
if stat, err = t.head.Stat(); err != nil {
|
||||
// TODO, anything more we can do here?
|
||||
// A data file has gone missing...
|
||||
|
|
|
@ -113,6 +113,9 @@ func TestFreezerBasicsClosing(t *testing.T) {
|
|||
f.Append(uint64(x), data)
|
||||
f.Close()
|
||||
f, err = newCustomTable(os.TempDir(), fname, rm, wm, sc, 50, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
|
@ -170,6 +173,9 @@ func TestFreezerRepairDanglingHead(t *testing.T) {
|
|||
// Now open it again
|
||||
{
|
||||
f, err := newCustomTable(os.TempDir(), fname, rm, wm, sc, 50, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// The last item should be missing
|
||||
if _, err = f.Retrieve(0xff); err == nil {
|
||||
t.Errorf("Expected error for missing index entry")
|
||||
|
@ -217,6 +223,9 @@ func TestFreezerRepairDanglingHeadLarge(t *testing.T) {
|
|||
// Now open it again
|
||||
{
|
||||
f, err := newCustomTable(os.TempDir(), fname, rm, wm, sc, 50, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// The first item should be there
|
||||
if _, err = f.Retrieve(0); err != nil {
|
||||
t.Fatal(err)
|
||||
|
@ -269,6 +278,9 @@ func TestSnappyDetection(t *testing.T) {
|
|||
// Open without snappy
|
||||
{
|
||||
f, err := newCustomTable(os.TempDir(), fname, rm, wm, sc, 50, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err = f.Retrieve(0); err == nil {
|
||||
f.Close()
|
||||
t.Fatalf("expected empty table")
|
||||
|
@ -278,6 +290,9 @@ func TestSnappyDetection(t *testing.T) {
|
|||
// Open with snappy
|
||||
{
|
||||
f, err := newCustomTable(os.TempDir(), fname, rm, wm, sc, 50, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// There should be 255 items
|
||||
if _, err = f.Retrieve(0xfe); err != nil {
|
||||
f.Close()
|
||||
|
|
Loading…
Reference in New Issue