From c0c45e3825bb3bd064c2ff68a3405ed043de8c4a Mon Sep 17 00:00:00 2001 From: Balint Gabor Date: Fri, 12 Jan 2018 09:50:53 +0100 Subject: [PATCH] Add new localStore constructor for tests --- swarm/storage/localstore.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/swarm/storage/localstore.go b/swarm/storage/localstore.go index 843505c2cb..4fcddbf735 100644 --- a/swarm/storage/localstore.go +++ b/swarm/storage/localstore.go @@ -42,6 +42,20 @@ func NewLocalStore(hash SwarmHasher, params *StoreParams, basekey []byte) (*Loca }, nil } +func NewTestLocalStore(path string) (*LocalStore, error) { + basekey := make([]byte, 32) + hasher := MakeHashFunc("SHA3") + dbStore, err := NewDbStore(path, hasher, singletonSwarmDbCapacity, func(k Key) (ret uint8) { return uint8(Proximity(basekey[:], k[:])) }) + if err != nil { + return nil, err + } + localStore := &LocalStore{ + memStore: NewMemStore(dbStore, singletonSwarmDbCapacity), + DbStore: dbStore, + } + return localStore, nil +} + // LocalStore is itself a chunk store // unsafe, in that the data is not integrity checked func (self *LocalStore) Put(chunk *Chunk) {