github.com/ethersphere/bee/v2@v2.2.0/pkg/statestore/leveldb/leveldb_test.go (about) 1 // Copyright 2020 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 leveldb_test 6 7 import ( 8 "testing" 9 10 "github.com/ethersphere/bee/v2/pkg/log" 11 "github.com/ethersphere/bee/v2/pkg/statestore/leveldb" 12 "github.com/ethersphere/bee/v2/pkg/statestore/test" 13 "github.com/ethersphere/bee/v2/pkg/storage" 14 ) 15 16 func TestPersistentStateStore(t *testing.T) { 17 test.Run(t, func(t *testing.T) storage.StateStorer { 18 t.Helper() 19 20 dir := t.TempDir() 21 22 store, err := leveldb.NewStateStore(dir, log.Noop) 23 if err != nil { 24 t.Fatal(err) 25 } 26 t.Cleanup(func() { 27 if err := store.Close(); err != nil { 28 t.Fatal(err) 29 } 30 }) 31 32 return store 33 }) 34 35 test.RunPersist(t, func(t *testing.T, dir string) storage.StateStorer { 36 t.Helper() 37 38 store, err := leveldb.NewStateStore(dir, log.Noop) 39 if err != nil { 40 t.Fatal(err) 41 } 42 43 return store 44 }) 45 }