swarm: mock store listings (#19157)
* swarm/storage/mock: implement listings methods for mem and rpc stores * swarm/storage/mock/rpc: add comments and newTestStore helper function * swarm/storage/mock/mem: add missing comments * swarm/storage/mock: add comments to new types and constants * swarm/storage/mock/db: implement listings for mock/db global store * swarm/storage/mock/test: add comments for MockStoreListings * swarm/storage/mock/explorer: initial implementation * cmd/swarm/global-store: add chunk explorer * cmd/swarm/global-store: add chunk explorer tests * swarm/storage/mock/explorer: add tests * swarm/storage/mock/explorer: add swagger api definition * swarm/storage/mock/explorer: not-zero test values for invalid addr and key * swarm/storage/mock/explorer: test wildcard cors origin * swarm/storage/mock/db: renames based on Fabio's suggestions * swarm/storage/mock/explorer: add more comments to testHandler function * cmd/swarm/global-store: terminate subprocess with Kill in tests
This commit is contained in:
committed by
Viktor Trón
parent
02c28046a0
commit
64d10c0872
@ -27,6 +27,27 @@ import (
|
||||
// TestDBStore is running test for a GlobalStore
|
||||
// using test.MockStore function.
|
||||
func TestRPCStore(t *testing.T) {
|
||||
store, cleanup := newTestStore(t)
|
||||
defer cleanup()
|
||||
|
||||
test.MockStore(t, store, 30)
|
||||
}
|
||||
|
||||
// TestRPCStoreListings is running test for a GlobalStore
|
||||
// using test.MockStoreListings function.
|
||||
func TestRPCStoreListings(t *testing.T) {
|
||||
store, cleanup := newTestStore(t)
|
||||
defer cleanup()
|
||||
|
||||
test.MockStoreListings(t, store, 1000)
|
||||
}
|
||||
|
||||
// newTestStore creates a temporary GlobalStore
|
||||
// that will be closed when returned cleanup function
|
||||
// is called.
|
||||
func newTestStore(t *testing.T) (s *GlobalStore, cleanup func()) {
|
||||
t.Helper()
|
||||
|
||||
serverStore := mem.NewGlobalStore()
|
||||
|
||||
server := rpc.NewServer()
|
||||
@ -35,7 +56,9 @@ func TestRPCStore(t *testing.T) {
|
||||
}
|
||||
|
||||
store := NewGlobalStore(rpc.DialInProc(server))
|
||||
defer store.Close()
|
||||
|
||||
test.MockStore(t, store, 30)
|
||||
return store, func() {
|
||||
if err := store.Close(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user