add test for mock/store.go

This commit is contained in:
mossid 2018-03-19 14:27:39 +01:00
parent cc07dce8f2
commit 380fa78eae
1 changed files with 33 additions and 0 deletions

33
mock/store_test.go Normal file
View File

@ -0,0 +1,33 @@
package mock
import (
"testing"
"github.com/stretchr/testify/assert"
dbm "github.com/tendermint/tmlibs/db"
sdk "github.com/cosmos/cosmos-sdk/types"
)
func TestStore(t *testing.T) {
db := dbm.NewMemDB()
cms := NewCommitMultiStore(db)
key := sdk.NewKVStoreKey("test")
cms.MountStoreWithDB(key, sdk.StoreTypeIAVL, db)
err := cms.LoadLatestVersion()
assert.Nil(t, err)
store := cms.GetKVStore(key)
assert.NotNil(t, store)
k := []byte("hello")
v := []byte("world")
assert.False(t, store.Has(k))
store.Set(k, v)
assert.True(t, store.Has(k))
assert.Equal(t, v, store.Get(k))
store.Delete(k)
assert.False(t, store.Has(k))
}