mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
cmd/utils: better defer handling in history test
This commit is contained in:
parent
3fa17e775f
commit
02b3f1983e
1 changed files with 45 additions and 43 deletions
|
|
@ -107,11 +107,11 @@ func TestHistoryImportAndExport(t *testing.T) {
|
|||
// Verify each Era.
|
||||
entries, _ := era.ReadDir(dir, "mainnet")
|
||||
for i, filename := range entries {
|
||||
func() {
|
||||
f, err := os.Open(path.Join(dir, filename))
|
||||
if err != nil {
|
||||
t.Fatalf("error opening era file: %v", err)
|
||||
}
|
||||
|
||||
var (
|
||||
h = sha256.New()
|
||||
buf = bytes.NewBuffer(nil)
|
||||
|
|
@ -122,11 +122,11 @@ func TestHistoryImportAndExport(t *testing.T) {
|
|||
if got, want := common.BytesToHash(h.Sum(buf.Bytes()[:])).Hex(), checksums[i]; got != want {
|
||||
t.Fatalf("checksum %d does not match: got %s, want %s", i, got, want)
|
||||
}
|
||||
|
||||
e, err := era.From(f)
|
||||
if err != nil {
|
||||
t.Fatalf("error opening era: %v", err)
|
||||
}
|
||||
defer e.Close()
|
||||
it, err := era.NewIterator(e)
|
||||
if err != nil {
|
||||
t.Fatalf("error making era reader: %v", err)
|
||||
|
|
@ -157,6 +157,8 @@ func TestHistoryImportAndExport(t *testing.T) {
|
|||
t.Fatalf("receipt root %d mismatch: want %s, got %s", n, want.ReceiptHash(), got)
|
||||
}
|
||||
}
|
||||
return
|
||||
}()
|
||||
}
|
||||
|
||||
// Now import Era.
|
||||
|
|
|
|||
Loading…
Reference in a new issue