cosmos-sdk/collections/internal/testutil/context.go
Aaron Craelius 2ccf08a3fe
refactor(collections): remove core dependency (#24081)
Co-authored-by: Alex | Interchain Labs <alex@interchainlabs.io>
Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com>
2025-03-28 22:22:27 +00:00

33 lines
546 B
Go

package testutil
import (
"context"
"cosmossdk.io/collections/corecompat"
)
type dummyKey struct{}
func Context() context.Context {
dummy := &dummyCtx{
stores: map[string]corecompat.KVStore{},
}
ctx := context.WithValue(context.Background(), dummyKey{}, dummy)
return ctx
}
type dummyCtx struct {
// maps store by the actor.
stores map[string]corecompat.KVStore
}
func unwrap(ctx context.Context) *dummyCtx {
dummy := ctx.Value(dummyKey{})
if dummy == nil {
panic("invalid ctx without dummy")
}
return dummy.(*dummyCtx)
}