Co-authored-by: Alex | Interchain Labs <alex@interchainlabs.io> Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com>
33 lines
546 B
Go
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)
|
|
}
|