mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-19 11:20:45 +00:00
fix test for win
This commit is contained in:
parent
8f4f38002f
commit
15aff745b1
1 changed files with 9 additions and 12 deletions
|
|
@ -358,15 +358,14 @@ func TestOpenRejectsNoreceiptsProfile(t *testing.T) {
|
||||||
|
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
|
|
||||||
// Build a valid Ere file with default-profile contents, then rename it
|
// Build a valid Ere file with default-profile contents directly at the
|
||||||
// to claim a noreceipts profile in its filename.
|
// noreceipts path so Open() rejects it on the filename alone.
|
||||||
src, err := os.CreateTemp(dir, "ere-src-*.ere")
|
path := filepath.Join(dir, "mainnet-00000-deadbeef-noreceipts.ere")
|
||||||
|
f, err := os.Create(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("create temp file: %v", err)
|
t.Fatalf("create file: %v", err)
|
||||||
}
|
}
|
||||||
defer src.Close()
|
builder := NewBuilder(f)
|
||||||
|
|
||||||
builder := NewBuilder(src)
|
|
||||||
header := mustEncode(&types.Header{Number: big.NewInt(0), Difficulty: big.NewInt(1)})
|
header := mustEncode(&types.Header{Number: big.NewInt(0), Difficulty: big.NewInt(1)})
|
||||||
body := mustEncode(&types.Body{})
|
body := mustEncode(&types.Body{})
|
||||||
receipts := mustEncode([]types.SlimReceipt{})
|
receipts := mustEncode([]types.SlimReceipt{})
|
||||||
|
|
@ -376,12 +375,10 @@ func TestOpenRejectsNoreceiptsProfile(t *testing.T) {
|
||||||
if _, err := builder.Finalize(); err != nil {
|
if _, err := builder.Finalize(); err != nil {
|
||||||
t.Fatalf("Finalize: %v", err)
|
t.Fatalf("Finalize: %v", err)
|
||||||
}
|
}
|
||||||
|
if err := f.Close(); err != nil {
|
||||||
renamed := filepath.Join(dir, "mainnet-00000-deadbeef-noreceipts.ere")
|
t.Fatalf("close: %v", err)
|
||||||
if err := os.Rename(src.Name(), renamed); err != nil {
|
|
||||||
t.Fatalf("rename: %v", err)
|
|
||||||
}
|
}
|
||||||
if _, err := Open(renamed); err == nil {
|
if _, err := Open(path); err == nil {
|
||||||
t.Fatal("expected Open to reject noreceipts profile")
|
t.Fatal("expected Open to reject noreceipts profile")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue