-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from sei-protocol/yzang/SEI-7639
Add pruning and WAL capability for SS store
- Loading branch information
Showing
16 changed files
with
257 additions
and
34 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
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
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
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
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,58 @@ | ||
package ss | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/cosmos/iavl" | ||
"github.com/sei-protocol/sei-db/common/logger" | ||
"github.com/sei-protocol/sei-db/config" | ||
"github.com/sei-protocol/sei-db/proto" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestNewStateStore(t *testing.T) { | ||
tempDir := os.TempDir() | ||
ssConfig := config.StateStoreConfig{ | ||
DedicatedChangelog: true, | ||
Backend: string(PebbleDBBackend), | ||
AsyncWriteBuffer: 10, | ||
KeepRecent: 100, | ||
} | ||
stateStore, err := NewStateStore(logger.NewNopLogger(), tempDir, ssConfig) | ||
require.NoError(t, err) | ||
for i := 1; i < 10; i++ { | ||
var changesets []*proto.NamedChangeSet | ||
kvPair := &iavl.KVPair{ | ||
Delete: false, | ||
Key: []byte(fmt.Sprintf("key%d", i)), | ||
Value: []byte(fmt.Sprintf("value%d", i)), | ||
} | ||
var pairs []*iavl.KVPair | ||
pairs = append(pairs, kvPair) | ||
cs := iavl.ChangeSet{Pairs: pairs} | ||
ncs := &proto.NamedChangeSet{ | ||
Name: "storeA", | ||
Changeset: cs, | ||
} | ||
changesets = append(changesets, ncs) | ||
err := stateStore.ApplyChangesetAsync(int64(i), changesets) | ||
require.NoError(t, err) | ||
} | ||
// Closing the state store without waiting for data to be fully flushed | ||
err = stateStore.Close() | ||
require.NoError(t, err) | ||
|
||
// Reopen a new state store | ||
stateStore, err = NewStateStore(logger.NewNopLogger(), tempDir, ssConfig) | ||
require.NoError(t, err) | ||
|
||
// Make sure key and values can be found | ||
for i := 1; i < 10; i++ { | ||
value, err := stateStore.Get("storeA", int64(i), []byte(fmt.Sprintf("key%d", i))) | ||
require.NoError(t, err) | ||
require.Equal(t, fmt.Sprintf("value%d", i), string(value)) | ||
} | ||
|
||
} |
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.