-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TimerStore: library for timers based on block height/timestamp
TimerStore manages timers to efficiently support future timeouts. Timeouts can be based on either block-height or block-timestamp. When a timeout occurs, a designated callback function is called with the details (ctx and data).
- Loading branch information
1 parent
95d0e7c
commit b57ccd7
Showing
6 changed files
with
473 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package common_test | ||
|
||
import ( | ||
"testing" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
"github.com/cosmos/cosmos-sdk/store" | ||
storetypes "github.com/cosmos/cosmos-sdk/store/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/stretchr/testify/require" | ||
"github.com/tendermint/tendermint/libs/log" | ||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
tmdb "github.com/tendermint/tm-db" | ||
) | ||
|
||
var ( | ||
mockStoreKey *sdk.KVStoreKey = sdk.NewKVStoreKey("storeKey") | ||
mockMemStoreKey *sdk.MemoryStoreKey = storetypes.NewMemoryStoreKey("storeMemKey") | ||
) | ||
|
||
// Helper function to init a mock keeper and context | ||
func initCtx(t *testing.T) (sdk.Context, *codec.ProtoCodec) { | ||
db := tmdb.NewMemDB() | ||
stateStore := store.NewCommitMultiStore(db) | ||
|
||
registry := codectypes.NewInterfaceRegistry() | ||
cdc := codec.NewProtoCodec(registry) | ||
|
||
stateStore.MountStoreWithDB(mockStoreKey, sdk.StoreTypeIAVL, db) | ||
stateStore.MountStoreWithDB(mockMemStoreKey, sdk.StoreTypeMemory, nil) | ||
|
||
require.NoError(t, stateStore.LoadLatestVersion()) | ||
|
||
ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.TestingLogger()) | ||
|
||
return ctx, cdc | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.