cosmos-sdk/core/testing/store.go
testinginprod fe22e9a5da
feat(core): add coretest package (#20487)
Co-authored-by: unknown unknown <unknown@unknown>
2024-06-05 22:11:33 +00:00

28 lines
523 B
Go

package coretesting
import (
"context"
"fmt"
"cosmossdk.io/core/store"
)
func KVStoreService(ctx context.Context, moduleName string) store.KVStoreService {
unwrap(ctx).stores[moduleName] = newMemDB()
return kvStoreService{
moduleName: moduleName,
}
}
type kvStoreService struct {
moduleName string
}
func (k kvStoreService) OpenKVStore(ctx context.Context) store.KVStore {
kv, ok := unwrap(ctx).stores[k.moduleName]
if !ok {
panic(fmt.Sprintf("KVStoreService %s not found", k.moduleName))
}
return kv
}