cosmos-sdk/core/testing/store.go
testinginprod b03a2c6b0a
feat(coretesting): add test events service. (#20579)
Co-authored-by: unknown unknown <unknown@unknown>
2024-06-21 14:56:25 +00:00

30 lines
576 B
Go

package coretesting
import (
"context"
"fmt"
"cosmossdk.io/core/store"
)
var _ store.KVStoreService = (*kvStoreService)(nil)
func KVStoreService(ctx context.Context, moduleName string) store.KVStoreService {
unwrap(ctx).stores[moduleName] = NewMemKV()
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
}