Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pruning Refactor #6475

Merged
merged 18 commits into from
Jun 22, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix TestMultiStoreRestart
  • Loading branch information
alexanderbez committed Jun 21, 2020
commit ee8b3d633780230cb824bd983ad4da5962679c0b
3 changes: 1 addition & 2 deletions store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,9 +717,8 @@ func commitStores(version int64, storeMap map[types.StoreKey]types.CommitKVStore

// Gets commitInfo from disk.
func getCommitInfo(db dbm.DB, ver int64) (commitInfo, error) {

// Get from DB.
cInfoKey := fmt.Sprintf(commitInfoKeyFmt, ver)

cInfoBytes, err := db.Get([]byte(cInfoKey))
if err != nil {
return commitInfo{}, errors.Wrap(err, "failed to get commit info")
Expand Down
16 changes: 8 additions & 8 deletions store/rootmulti/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ func TestParsePath(t *testing.T) {
func TestMultiStoreRestart(t *testing.T) {
db := dbm.NewMemDB()
pruning := types.PruningOptions{
KeepRecent: 3,
KeepEvery: 6,
KeepRecent: 2,
KeepEvery: 3,
Interval: 1,
}
multi := newMultiStoreWithMounts(db, pruning)
Expand Down Expand Up @@ -323,8 +323,8 @@ func TestMultiStoreRestart(t *testing.T) {
multi.Commit()

cinfo, err := getCommitInfo(multi.db, int64(i))
require.NotNil(t, err)
require.Equal(t, commitInfo{}, cinfo)
require.NoError(t, err)
require.Equal(t, int64(i), cinfo.Version)
}

// Set and commit data in one store.
Expand All @@ -348,15 +348,15 @@ func TestMultiStoreRestart(t *testing.T) {
multi.Commit()

postFlushCinfo, err := getCommitInfo(multi.db, 4)
require.NotNil(t, err)
require.Equal(t, commitInfo{}, postFlushCinfo, "Commit changed after in-memory commit")
require.NoError(t, err)
require.Equal(t, int64(4), postFlushCinfo.Version, "Commit changed after in-memory commit")

multi = newMultiStoreWithMounts(db, pruning)
err = multi.LoadLatestVersion()
require.Nil(t, err)

reloadedCid := multi.LastCommitID()
require.Equal(t, flushedCinfo.CommitID(), reloadedCid, "Reloaded CID is not the same as last flushed CID")
require.Equal(t, int64(4), reloadedCid.Version, "Reloaded CID is not the same as last flushed CID")

// Check that store1 and store2 retained date from 3rd commit
store1 = multi.getStoreByName("store1").(types.KVStore)
Expand All @@ -370,7 +370,7 @@ func TestMultiStoreRestart(t *testing.T) {
// Check that store3 still has data from last commit even though update happened on 2nd commit
store3 = multi.getStoreByName("store3").(types.KVStore)
val3 := store3.Get([]byte(k3))
require.Equal(t, []byte(fmt.Sprintf("%s:%d", v3, 2)), val3, "Reloaded value not the same as last flushed value")
require.Equal(t, []byte(fmt.Sprintf("%s:%d", v3, 3)), val3, "Reloaded value not the same as last flushed value")
}

func TestMultiStoreQuery(t *testing.T) {
Expand Down