cosmos-sdk/store/transient/store_test.go

36 lines
714 B
Go
Raw Normal View History

package transient_test
2018-07-26 18:24:18 -07:00
import (
"bytes"
2018-07-26 18:24:18 -07:00
"testing"
2020-03-20 10:14:14 -07:00
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/store/transient"
"github.com/cosmos/cosmos-sdk/store/types"
2018-07-26 18:24:18 -07:00
)
var k, v = []byte("hello"), []byte("world")
func TestTransientStore(t *testing.T) {
tstore := transient.NewStore()
2018-07-26 18:24:18 -07:00
require.Nil(t, tstore.Get(k))
tstore.Set(k, v)
require.Equal(t, v, tstore.Get(k))
tstore.Commit()
require.Nil(t, tstore.Get(k))
// no-op
tstore.SetPruning(types.PruningOptions{})
emptyCommitID := tstore.LastCommitID()
require.Equal(t, emptyCommitID.Version, int64(0))
require.True(t, bytes.Equal(emptyCommitID.Hash, nil))
require.Equal(t, types.StoreTypeTransient, tstore.GetStoreType())
2018-07-26 18:24:18 -07:00
}