chore(store/v2): load the CommitID when LoadVersion (#20776)
This commit is contained in:
parent
5aaff21096
commit
929803d6cc
@ -243,7 +243,11 @@ func (s *Store) loadVersion(v uint64) error {
|
||||
s.commitHeader = nil
|
||||
|
||||
// set lastCommitInfo explicitly s.t. Commit commits the correct version, i.e. v+1
|
||||
s.lastCommitInfo = &proof.CommitInfo{Version: v}
|
||||
var err error
|
||||
s.lastCommitInfo, err = s.stateCommitment.GetCommitInfo(v)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get commit info for version %d: %w", v, err)
|
||||
}
|
||||
|
||||
// if we're migrating, we need to start the migration process
|
||||
if s.isMigrating {
|
||||
|
||||
@ -459,7 +459,7 @@ func (s *RootStoreTestSuite) TestMultiStore_Pruning_SameHeightsTwice() {
|
||||
for v := uint64(1); v < numVersions-keepRecent; v++ {
|
||||
var err error
|
||||
checkErr := func() bool {
|
||||
if err = s.rootStore.LoadVersion(v); err != nil {
|
||||
if _, err = s.rootStore.StateAt(v); err != nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@ -469,7 +469,7 @@ func (s *RootStoreTestSuite) TestMultiStore_Pruning_SameHeightsTwice() {
|
||||
}
|
||||
|
||||
for v := (numVersions - keepRecent); v < numVersions; v++ {
|
||||
err := s.rootStore.LoadVersion(v)
|
||||
_, err := s.rootStore.StateAt(v)
|
||||
s.Require().NoError(err, "expected no error when loading height: %d", v)
|
||||
}
|
||||
|
||||
@ -710,7 +710,7 @@ func (s *RootStoreTestSuite) TestMultiStoreRestart() {
|
||||
s.Require().Equal([]byte(fmt.Sprintf("val%03d_%03d", 4, 3)), result, "value should be equal")
|
||||
}
|
||||
|
||||
func (s *RootStoreTestSuite) TestHashStableWithEmptyCommit() {
|
||||
func (s *RootStoreTestSuite) TestHashStableWithEmptyCommitAndRestart() {
|
||||
err := s.rootStore.LoadLatestVersion()
|
||||
s.Require().Nil(err)
|
||||
|
||||
@ -739,4 +739,10 @@ func (s *RootStoreTestSuite) TestHashStableWithEmptyCommit() {
|
||||
s.Require().Nil(err)
|
||||
s.Require().Equal(uint64(2), latestVersion)
|
||||
s.Require().Equal(hash, cHash)
|
||||
|
||||
// reload the store
|
||||
s.Require().NoError(s.rootStore.LoadLatestVersion())
|
||||
lastCommitID, err = s.rootStore.LastCommitID()
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(lastCommitID.Hash, hash)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user