github.com/ethersphere/bee/v2@v2.2.0/pkg/storage/leveldbstore/store_test.go (about) 1 // Copyright 2022 The Swarm Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package leveldbstore_test 6 7 import ( 8 "testing" 9 10 "github.com/ethersphere/bee/v2/pkg/storage/leveldbstore" 11 "github.com/ethersphere/bee/v2/pkg/storage/storagetest" 12 "github.com/syndtr/goleveldb/leveldb/opt" 13 ) 14 15 func TestStore(t *testing.T) { 16 t.Parallel() 17 18 store, err := leveldbstore.New(t.TempDir(), nil) 19 if err != nil { 20 t.Fatalf("create store failed: %v", err) 21 } 22 t.Cleanup(func() { _ = store.Close() }) 23 storagetest.TestStore(t, store) 24 } 25 26 func BenchmarkStore(b *testing.B) { 27 st, err := leveldbstore.New("", &opt.Options{ 28 Compression: opt.SnappyCompression, 29 }) 30 if err != nil { 31 b.Fatalf("create store failed: %v", err) 32 } 33 b.Cleanup(func() { _ = st.Close() }) 34 storagetest.BenchmarkStore(b, st) 35 } 36 37 func TestBatchedStore(t *testing.T) { 38 t.Parallel() 39 40 st, err := leveldbstore.New("", nil) 41 if err != nil { 42 t.Fatalf("create store failed: %v", err) 43 } 44 t.Cleanup(func() { _ = st.Close() }) 45 storagetest.TestBatchedStore(t, st) 46 } 47 48 func BenchmarkBatchedStore(b *testing.B) { 49 st, err := leveldbstore.New("", &opt.Options{ 50 Compression: opt.SnappyCompression, 51 }) 52 if err != nil { 53 b.Fatalf("create store failed: %v", err) 54 } 55 b.Cleanup(func() { _ = st.Close() }) 56 storagetest.BenchmarkBatchedStore(b, st) 57 }