Skip to content

Commit

Permalink
test(header/store): new store test proving there is an issue with sto…
Browse files Browse the repository at this point in the history
…re cache misses
  • Loading branch information
Wondertan committed Jun 3, 2022
1 parent 52193fd commit e7114c9
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions header/store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,31 @@ func TestStore(t *testing.T) {
err = store.Stop(ctx)
require.NoError(t, err)
}

func TestStorePendingCacheMiss(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
t.Cleanup(cancel)

suite := header.NewTestSuite(t, 3)

ds := sync.MutexWrap(datastore.NewMapDatastore())

DefaultWriteBatchSize = 100
DefaultStoreCacheSize = 100
store, err := NewStoreWithHead(ctx, ds, suite.Head())
require.NoError(t, err)

err = store.Start(ctx)
require.NoError(t, err)
_, err = store.Append(ctx, suite.GenExtendedHeaders(100)...)
require.NoError(t, err)

_, err = store.Append(ctx, suite.GenExtendedHeaders(50)...)
require.NoError(t, err)

_, err = store.GetRangeByHeight(ctx, 1, 101)
require.NoError(t, err)

_, err = store.GetRangeByHeight(ctx, 101, 151)
require.NoError(t, err)
}

0 comments on commit e7114c9

Please sign in to comment.