Address comments
I hope this is correct. I'm feely pretty dizzy right now from the fish food.
This commit is contained in:
parent
243564c233
commit
fcc8a9a415
|
@ -74,15 +74,20 @@ func (app *BaseApp) Name() string {
|
||||||
// Broken until #532 is implemented.
|
// Broken until #532 is implemented.
|
||||||
func (app *BaseApp) MountStoresIAVL(keys ...*sdk.KVStoreKey) {
|
func (app *BaseApp) MountStoresIAVL(keys ...*sdk.KVStoreKey) {
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
app.MountStore(key, sdk.StoreTypeIAVL, app.db)
|
app.MountStore(key, sdk.StoreTypeIAVL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mount a store to the provided key in the BaseApp multistore
|
// Mount a store to the provided key in the BaseApp multistore
|
||||||
func (app *BaseApp) MountStore(key sdk.StoreKey, typ sdk.StoreType, db dbm.DB) {
|
func (app *BaseApp) MountStoreWithDB(key sdk.StoreKey, typ sdk.StoreType, db dbm.DB) {
|
||||||
app.cms.MountStoreWithDB(key, typ, db)
|
app.cms.MountStoreWithDB(key, typ, db)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mount a store to the provided key in the BaseApp multistore
|
||||||
|
func (app *BaseApp) MountStore(key sdk.StoreKey, typ sdk.StoreType) {
|
||||||
|
app.cms.MountStoreWithDB(key, typ, app.db)
|
||||||
|
}
|
||||||
|
|
||||||
// nolint - Set functions
|
// nolint - Set functions
|
||||||
func (app *BaseApp) SetTxDecoder(txDecoder sdk.TxDecoder) {
|
func (app *BaseApp) SetTxDecoder(txDecoder sdk.TxDecoder) {
|
||||||
app.txDecoder = txDecoder
|
app.txDecoder = txDecoder
|
||||||
|
|
|
@ -35,12 +35,15 @@ func TestMountStores(t *testing.T) {
|
||||||
|
|
||||||
// make some cap keys
|
// make some cap keys
|
||||||
capKey1 := sdk.NewKVStoreKey("key1")
|
capKey1 := sdk.NewKVStoreKey("key1")
|
||||||
|
db1 := dbm.NewMemDB()
|
||||||
capKey2 := sdk.NewKVStoreKey("key2")
|
capKey2 := sdk.NewKVStoreKey("key2")
|
||||||
|
db2 := dbm.NewMemDB()
|
||||||
|
|
||||||
// no stores are mounted
|
// no stores are mounted
|
||||||
assert.Panics(t, func() { app.LoadLatestVersion(capKey1) })
|
assert.Panics(t, func() { app.LoadLatestVersion(capKey1) })
|
||||||
|
|
||||||
app.MountStoresIAVL(capKey1, capKey2)
|
app.MountStoreWithDB(capKey1, sdk.StoreTypeIAVL, db1)
|
||||||
|
app.MountStoreWithDB(capKey2, sdk.StoreTypeIAVL, db2)
|
||||||
|
|
||||||
// stores are mounted
|
// stores are mounted
|
||||||
err := app.LoadLatestVersion(capKey1)
|
err := app.LoadLatestVersion(capKey1)
|
||||||
|
@ -126,7 +129,6 @@ func TestTxDecoder(t *testing.T) {
|
||||||
|
|
||||||
// Test that Info returns the latest committed state.
|
// Test that Info returns the latest committed state.
|
||||||
func TestInfo(t *testing.T) {
|
func TestInfo(t *testing.T) {
|
||||||
|
|
||||||
app := newBaseApp(t.Name())
|
app := newBaseApp(t.Name())
|
||||||
|
|
||||||
// ----- test an empty response -------
|
// ----- test an empty response -------
|
||||||
|
@ -145,17 +147,19 @@ func TestInfo(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInitChainer(t *testing.T) {
|
func TestInitChainer(t *testing.T) {
|
||||||
logger := defaultLogger()
|
|
||||||
db := dbm.NewMemDB()
|
|
||||||
name := t.Name()
|
name := t.Name()
|
||||||
|
db := dbm.NewMemDB()
|
||||||
|
logger := defaultLogger()
|
||||||
app := NewBaseApp(name, logger, db)
|
app := NewBaseApp(name, logger, db)
|
||||||
|
|
||||||
// make cap keys and mount the stores
|
// make cap keys and mount the stores
|
||||||
// NOTE/TODO: mounting multiple stores is broken
|
// NOTE/TODO: mounting multiple stores is broken
|
||||||
// see https://github.com/cosmos/cosmos-sdk/issues/532
|
// see https://github.com/cosmos/cosmos-sdk/issues/532
|
||||||
capKey := sdk.NewKVStoreKey("main")
|
capKey := sdk.NewKVStoreKey("main")
|
||||||
// capKey2 := sdk.NewKVStoreKey("key2")
|
db1 := dbm.NewMemDB()
|
||||||
app.MountStoresIAVL(capKey) // , capKey2)
|
capKey2 := sdk.NewKVStoreKey("key2")
|
||||||
|
db2 := dbm.NewMemDB()
|
||||||
|
app.MountStoreWithDB(capKey, sdk.StoreTypeIAVL, db1)
|
||||||
|
app.MountStoreWithDB(capKey2, sdk.StoreTypeIAVL, db2)
|
||||||
err := app.LoadLatestVersion(capKey) // needed to make stores non-nil
|
err := app.LoadLatestVersion(capKey) // needed to make stores non-nil
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
|
@ -187,9 +191,8 @@ func TestInitChainer(t *testing.T) {
|
||||||
|
|
||||||
// reload app
|
// reload app
|
||||||
app = NewBaseApp(name, logger, db)
|
app = NewBaseApp(name, logger, db)
|
||||||
capKey = sdk.NewKVStoreKey("main")
|
app.MountStoreWithDB(capKey, sdk.StoreTypeIAVL, db1)
|
||||||
// capKey2 = sdk.NewKVStoreKey("key2") // TODO
|
app.MountStoreWithDB(capKey2, sdk.StoreTypeIAVL, db2)
|
||||||
app.MountStoresIAVL(capKey) //, capKey2)
|
|
||||||
err = app.LoadLatestVersion(capKey) // needed to make stores non-nil
|
err = app.LoadLatestVersion(capKey) // needed to make stores non-nil
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
app.SetInitChainer(initChainer)
|
app.SetInitChainer(initChainer)
|
||||||
|
|
|
@ -71,10 +71,10 @@ func NewBasecoinApp(logger log.Logger, dbMain, dbAcc, dbIBC, dbStaking dbm.DB) *
|
||||||
// initialize BaseApp
|
// initialize BaseApp
|
||||||
app.SetTxDecoder(app.txDecoder)
|
app.SetTxDecoder(app.txDecoder)
|
||||||
app.SetInitChainer(app.initChainer)
|
app.SetInitChainer(app.initChainer)
|
||||||
app.MountStore(app.capKeyMainStore, sdk.StoreTypeIAVL, dbMain)
|
app.MountStoreWithDB(app.capKeyMainStore, sdk.StoreTypeIAVL, dbMain)
|
||||||
app.MountStore(app.capKeyAccountStore, sdk.StoreTypeIAVL, dbAcc)
|
app.MountStoreWithDB(app.capKeyAccountStore, sdk.StoreTypeIAVL, dbAcc)
|
||||||
app.MountStore(app.capKeyIBCStore, sdk.StoreTypeIAVL, dbIBC)
|
app.MountStoreWithDB(app.capKeyIBCStore, sdk.StoreTypeIAVL, dbIBC)
|
||||||
app.MountStore(app.capKeyStakingStore, sdk.StoreTypeIAVL, dbStaking)
|
app.MountStoreWithDB(app.capKeyStakingStore, sdk.StoreTypeIAVL, dbStaking)
|
||||||
// NOTE: Broken until #532 lands
|
// NOTE: Broken until #532 lands
|
||||||
//app.MountStoresIAVL(app.capKeyMainStore, app.capKeyIBCStore, app.capKeyStakingStore)
|
//app.MountStoresIAVL(app.capKeyMainStore, app.capKeyIBCStore, app.capKeyStakingStore)
|
||||||
app.SetAnteHandler(auth.NewAnteHandler(app.accountMapper))
|
app.SetAnteHandler(auth.NewAnteHandler(app.accountMapper))
|
||||||
|
|
Loading…
Reference in New Issue