Skip to content

Commit

Permalink
Fix MountStoreWithDB(); Bump to 0.15.0-rc0
Browse files Browse the repository at this point in the history
  • Loading branch information
jaekwon committed Apr 13, 2018
1 parent eb25943 commit d530ee2
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 35 deletions.
18 changes: 9 additions & 9 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@

[[constraint]]
name = "github.com/tendermint/tendermint"
version = "0.19.0-rc4"
version = "0.19.0"

[[constraint]]
[[override]]
name = "github.com/tendermint/tmlibs"
version = "~0.8.1"
version = "~0.8.2-rc1"

[prune]
go-tests = true
Expand Down
2 changes: 1 addition & 1 deletion client/rpc/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func GetChainHeight() (int64, error) {
if err != nil {
return -1, err
}
height := status.LatestBlockHeight
height := status.SyncInfo.LatestBlockHeight
return height, nil
}

Expand Down
2 changes: 1 addition & 1 deletion client/rpc/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func NodeSyncingRequestHandler(w http.ResponseWriter, r *http.Request) {
return
}

syncing := status.Syncing
syncing := status.SyncInfo.Syncing
if err != nil {
w.WriteHeader(500)
w.Write([]byte(err.Error()))
Expand Down
5 changes: 3 additions & 2 deletions store/rootmultistore.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func parsePath(path string) (storeName string, subpath string, err sdk.Error) {
func (rs *rootMultiStore) loadCommitStoreFromParams(id CommitID, params storeParams) (store CommitStore, err error) {
var db dbm.DB
if params.db != nil {
db = dbm.NewPrefixDB(rs.db, []byte("s/_/"))
db = dbm.NewPrefixDB(params.db, []byte("s/_/"))
} else {
db = dbm.NewPrefixDB(rs.db, []byte("s/k:"+params.key.Name()+"/"))
}
Expand Down Expand Up @@ -379,10 +379,11 @@ func commitStores(version int64, storeMap map[StoreKey]CommitStore) commitInfo {
storeInfos = append(storeInfos, si)
}

return commitInfo{
ci := commitInfo{
Version: version,
StoreInfos: storeInfos,
}
return ci
}

// Gets commitInfo from disk.
Expand Down
41 changes: 23 additions & 18 deletions store/rootmultistore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,50 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

const useDebugDB = false

func TestMultistoreCommitLoad(t *testing.T) {
db := dbm.NewMemDB()
var db dbm.DB = dbm.NewMemDB()
if useDebugDB {
db = dbm.NewDebugDB("CMS", db)
}
store := newMultiStoreWithMounts(db)
err := store.LoadLatestVersion()
assert.Nil(t, err)

// new store has empty last commit
// New store has empty last commit.
commitID := CommitID{}
checkStore(t, store, commitID, commitID)

// make sure we can get stores by name
// Make sure we can get stores by name.
s1 := store.getStoreByName("store1")
assert.NotNil(t, s1)
s3 := store.getStoreByName("store3")
assert.NotNil(t, s3)
s77 := store.getStoreByName("store77")
assert.Nil(t, s77)

// make a few commits and check them
// Make a few commits and check them.
nCommits := int64(3)
for i := int64(0); i < nCommits; i++ {
commitID = store.Commit()
expectedCommitID := getExpectedCommitID(store, i+1)
checkStore(t, store, expectedCommitID, commitID)
}

// Load the latest multistore again and check version
// Load the latest multistore again and check version.
store = newMultiStoreWithMounts(db)
err = store.LoadLatestVersion()
assert.Nil(t, err)
commitID = getExpectedCommitID(store, nCommits)
checkStore(t, store, commitID, commitID)

// commit and check version
// Commit and check version.
commitID = store.Commit()
expectedCommitID := getExpectedCommitID(store, nCommits+1)
checkStore(t, store, expectedCommitID, commitID)

// Load an older multistore and check version
// Load an older multistore and check version.
ver := nCommits - 1
store = newMultiStoreWithMounts(db)
err = store.LoadVersion(ver)
Expand All @@ -62,8 +67,8 @@ func TestMultistoreCommitLoad(t *testing.T) {
expectedCommitID = getExpectedCommitID(store, ver+1)
checkStore(t, store, expectedCommitID, commitID)

// XXX: confirm old commit is overwritten and
// we have rolled back LatestVersion
// XXX: confirm old commit is overwritten and we have rolled back
// LatestVersion
store = newMultiStoreWithMounts(db)
err = store.LoadLatestVersion()
assert.Nil(t, err)
Expand Down Expand Up @@ -104,23 +109,23 @@ func TestMultiStoreQuery(t *testing.T) {

cid := multi.Commit()

// make sure we can get by name
// Make sure we can get by name.
garbage := multi.getStoreByName("bad-name")
assert.Nil(t, garbage)

// set and commit data in one store
// Set and commit data in one store.
store1 := multi.getStoreByName("store1").(KVStore)
store1.Set(k, v)

// and another
// ... and another.
store2 := multi.getStoreByName("store2").(KVStore)
store2.Set(k2, v2)

// commit the multistore
// Commit the multistore.
cid = multi.Commit()
ver := cid.Version

// bad path
// Test bad path.
query := abci.RequestQuery{Path: "/key", Data: k, Height: ver}
qres := multi.Query(query)
assert.Equal(t, uint32(sdk.CodeUnknownRequest), qres.Code)
Expand All @@ -129,25 +134,25 @@ func TestMultiStoreQuery(t *testing.T) {
qres = multi.Query(query)
assert.Equal(t, uint32(sdk.CodeUnknownRequest), qres.Code)

// invalid store name
// Test invalid store name.
query.Path = "/garbage/key"
qres = multi.Query(query)
assert.Equal(t, uint32(sdk.CodeUnknownRequest), qres.Code)

// valid query with data
// Test valid query with data.
query.Path = "/store1/key"
qres = multi.Query(query)
assert.Equal(t, uint32(sdk.CodeOK), qres.Code)
assert.Equal(t, v, qres.Value)

// valid but empty
// Test valid but empty query.
query.Path = "/store2/key"
query.Prove = true
qres = multi.Query(query)
assert.Equal(t, uint32(sdk.CodeOK), qres.Code)
assert.Nil(t, qres.Value)

// store2 data
// Test store2 data.
query.Data = k2
qres = multi.Query(query)
assert.Equal(t, uint32(sdk.CodeOK), qres.Code)
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Maj = "0"
const Min = "15"
const Fix = "0"

const Version = "0.15.0-rc1"
const Version = "0.15.0-rc0"

// GitCommit set by build flags
var GitCommit = ""

0 comments on commit d530ee2

Please sign in to comment.