Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
kasey committed Jun 4, 2024
1 parent a1bd0de commit 8a75887
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions beacon-chain/db/filesystem/pruner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,28 @@ func TestTryPruneDir_CachedNotExpired(t *testing.T) {

func TestCacheWarmFail(t *testing.T) {
fs := afero.NewMemMapFs()
n := blobNamer{root: bytesutil.ToBytes32([]byte("0x00f")), index: 0}
n := blobNamer{root: bytesutil.ToBytes32([]byte("derp")), index: 0}
bp := n.path()
mkdir := path.Dir(bp)
fs.MkdirAll(mkdir, directoryPermissions)
require.NoError(t, fs.MkdirAll(mkdir, directoryPermissions))

// Touch the file
// Create an empty blob index in the fs by touching the file at a seemingly valid path.
fi, err := fs.Create(bp)
require.NoError(t, err)
fi.Close()
require.NoError(t, fi.Close())

// Cache warm should fail due to the unexpected EOF.
pr, err := newBlobPruner(fs, 0)
require.NoError(t, err)
require.ErrorIs(t, pr.warmCache(), errPruningFailures)

// The cache warm has finished, so calling waitForCache with a super short deadline
// should not block or hit the context deadline.
ctx := context.Background()
ctx, _ = context.WithDeadline(ctx, time.Now().Add(1*time.Millisecond))
ctx, cancel := context.WithDeadline(ctx, time.Now().Add(1*time.Millisecond))
defer cancel()
c, err := pr.waitForCache(ctx)
// We will get an error and a nil value for the cache if we hit the deadline.
require.NoError(t, err)
require.NotNil(t, c)
}
Expand Down

0 comments on commit 8a75887

Please sign in to comment.