Tests can never be proven to be non-deterministic
Our tests are at best probabilistic deterministic.
This commit is contained in:
parent
8574f923e8
commit
243564c233
|
@ -315,7 +315,7 @@ func startTMAndLCD() (*nm.Node, net.Listener, error) {
|
|||
logger = log.NewFilter(logger, log.AllowError())
|
||||
privValidatorFile := config.PrivValidatorFile()
|
||||
privVal := tmtypes.LoadOrGenPrivValidatorFS(privValidatorFile)
|
||||
app := bapp.NewBasecoinApp(logger, dbm.NewMemDB())
|
||||
app := bapp.NewBasecoinApp(logger, dbm.NewMemDB(), dbm.NewMemDB(), dbm.NewMemDB(), dbm.NewMemDB())
|
||||
|
||||
genesisFile := config.GenesisFile()
|
||||
genDoc, err := tmtypes.GenesisDocFromFile(genesisFile)
|
||||
|
|
|
@ -2,8 +2,6 @@ package app
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
abci "github.com/tendermint/abci/types"
|
||||
oldwire "github.com/tendermint/go-wire"
|
||||
|
@ -34,6 +32,7 @@ type BasecoinApp struct {
|
|||
|
||||
// keys to access the substores
|
||||
capKeyMainStore *sdk.KVStoreKey
|
||||
capKeyAccountStore *sdk.KVStoreKey
|
||||
capKeyIBCStore *sdk.KVStoreKey
|
||||
capKeyStakingStore *sdk.KVStoreKey
|
||||
|
||||
|
@ -41,12 +40,13 @@ type BasecoinApp struct {
|
|||
accountMapper sdk.AccountMapper
|
||||
}
|
||||
|
||||
func NewBasecoinApp(logger log.Logger, db dbm.DB) *BasecoinApp {
|
||||
func NewBasecoinApp(logger log.Logger, dbMain, dbAcc, dbIBC, dbStaking dbm.DB) *BasecoinApp {
|
||||
// create your application object
|
||||
var app = &BasecoinApp{
|
||||
BaseApp: bam.NewBaseApp(appName, logger, db),
|
||||
BaseApp: bam.NewBaseApp(appName, logger, dbMain),
|
||||
cdc: MakeCodec(),
|
||||
capKeyMainStore: sdk.NewKVStoreKey("main"),
|
||||
capKeyAccountStore: sdk.NewKVStoreKey("acc"),
|
||||
capKeyIBCStore: sdk.NewKVStoreKey("ibc"),
|
||||
capKeyStakingStore: sdk.NewKVStoreKey("staking"),
|
||||
}
|
||||
|
@ -68,30 +68,17 @@ func NewBasecoinApp(logger log.Logger, db dbm.DB) *BasecoinApp {
|
|||
AddRoute("ibc", ibc.NewHandler(ibcMapper, coinKeeper)).
|
||||
AddRoute("staking", staking.NewHandler(stakeKeeper))
|
||||
|
||||
rootDir := os.ExpandEnv("$HOME/.basecoind")
|
||||
dbMain, err := dbm.NewGoLevelDB("basecoin-main", filepath.Join(rootDir, "data"))
|
||||
if err != nil {
|
||||
cmn.Exit(err.Error())
|
||||
}
|
||||
dbIBC, err := dbm.NewGoLevelDB("basecoin-ibc", filepath.Join(rootDir, "data"))
|
||||
if err != nil {
|
||||
cmn.Exit(err.Error())
|
||||
}
|
||||
dbStaking, err := dbm.NewGoLevelDB("basecoin-staking", filepath.Join(rootDir, "data"))
|
||||
if err != nil {
|
||||
cmn.Exit(err.Error())
|
||||
}
|
||||
|
||||
// initialize BaseApp
|
||||
app.SetTxDecoder(app.txDecoder)
|
||||
app.SetInitChainer(app.initChainer)
|
||||
app.MountStore(app.capKeyMainStore, sdk.StoreTypeIAVL, dbMain)
|
||||
app.MountStore(app.capKeyAccountStore, sdk.StoreTypeIAVL, dbAcc)
|
||||
app.MountStore(app.capKeyIBCStore, sdk.StoreTypeIAVL, dbIBC)
|
||||
app.MountStore(app.capKeyStakingStore, sdk.StoreTypeIAVL, dbStaking)
|
||||
// NOTE: Broken until #532 lands
|
||||
//app.MountStoresIAVL(app.capKeyMainStore, app.capKeyIBCStore, app.capKeyStakingStore)
|
||||
app.SetAnteHandler(auth.NewAnteHandler(app.accountMapper))
|
||||
err = app.LoadLatestVersion(app.capKeyMainStore)
|
||||
err := app.LoadLatestVersion(app.capKeyMainStore)
|
||||
if err != nil {
|
||||
cmn.Exit(err.Error())
|
||||
}
|
||||
|
|
|
@ -68,8 +68,11 @@ var (
|
|||
|
||||
func newBasecoinApp() *BasecoinApp {
|
||||
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "sdk/app")
|
||||
db := dbm.NewMemDB()
|
||||
return NewBasecoinApp(logger, db)
|
||||
dbMain := dbm.NewMemDB()
|
||||
dbAcc := dbm.NewMemDB()
|
||||
dbIBC := dbm.NewMemDB()
|
||||
dbStaking := dbm.NewMemDB()
|
||||
return NewBasecoinApp(logger, dbMain, dbAcc, dbIBC, dbStaking)
|
||||
}
|
||||
|
||||
//_______________________________________________________________________
|
||||
|
@ -112,9 +115,7 @@ func TestMsgs(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGenesis(t *testing.T) {
|
||||
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "sdk/app")
|
||||
db := dbm.NewMemDB()
|
||||
bapp := NewBasecoinApp(logger, db)
|
||||
bapp := newBasecoinApp()
|
||||
|
||||
// Construct some genesis bytes to reflect basecoin/types/AppAccount
|
||||
pk := crypto.GenPrivKeyEd25519().PubKey()
|
||||
|
|
|
@ -51,11 +51,23 @@ func defaultOptions(args []string) (json.RawMessage, error) {
|
|||
}
|
||||
|
||||
func generateApp(rootDir string, logger log.Logger) (abci.Application, error) {
|
||||
db, err := dbm.NewGoLevelDB("basecoin", filepath.Join(rootDir, "data"))
|
||||
dbMain, err := dbm.NewGoLevelDB("basecoin", filepath.Join(rootDir, "data"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
bapp := app.NewBasecoinApp(logger, db)
|
||||
dbAcc, err := dbm.NewGoLevelDB("basecoin-acc", filepath.Join(rootDir, "data"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dbIBC, err := dbm.NewGoLevelDB("basecoin-ibc", filepath.Join(rootDir, "data"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dbStaking, err := dbm.NewGoLevelDB("basecoin-staking", filepath.Join(rootDir, "data"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
bapp := app.NewBasecoinApp(logger, dbMain, dbAcc, dbIBC, dbStaking)
|
||||
return bapp, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue