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())
|
logger = log.NewFilter(logger, log.AllowError())
|
||||||
privValidatorFile := config.PrivValidatorFile()
|
privValidatorFile := config.PrivValidatorFile()
|
||||||
privVal := tmtypes.LoadOrGenPrivValidatorFS(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()
|
genesisFile := config.GenesisFile()
|
||||||
genDoc, err := tmtypes.GenesisDocFromFile(genesisFile)
|
genDoc, err := tmtypes.GenesisDocFromFile(genesisFile)
|
||||||
|
|
|
@ -2,8 +2,6 @@ package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
|
|
||||||
abci "github.com/tendermint/abci/types"
|
abci "github.com/tendermint/abci/types"
|
||||||
oldwire "github.com/tendermint/go-wire"
|
oldwire "github.com/tendermint/go-wire"
|
||||||
|
@ -34,6 +32,7 @@ type BasecoinApp struct {
|
||||||
|
|
||||||
// keys to access the substores
|
// keys to access the substores
|
||||||
capKeyMainStore *sdk.KVStoreKey
|
capKeyMainStore *sdk.KVStoreKey
|
||||||
|
capKeyAccountStore *sdk.KVStoreKey
|
||||||
capKeyIBCStore *sdk.KVStoreKey
|
capKeyIBCStore *sdk.KVStoreKey
|
||||||
capKeyStakingStore *sdk.KVStoreKey
|
capKeyStakingStore *sdk.KVStoreKey
|
||||||
|
|
||||||
|
@ -41,12 +40,13 @@ type BasecoinApp struct {
|
||||||
accountMapper sdk.AccountMapper
|
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
|
// create your application object
|
||||||
var app = &BasecoinApp{
|
var app = &BasecoinApp{
|
||||||
BaseApp: bam.NewBaseApp(appName, logger, db),
|
BaseApp: bam.NewBaseApp(appName, logger, dbMain),
|
||||||
cdc: MakeCodec(),
|
cdc: MakeCodec(),
|
||||||
capKeyMainStore: sdk.NewKVStoreKey("main"),
|
capKeyMainStore: sdk.NewKVStoreKey("main"),
|
||||||
|
capKeyAccountStore: sdk.NewKVStoreKey("acc"),
|
||||||
capKeyIBCStore: sdk.NewKVStoreKey("ibc"),
|
capKeyIBCStore: sdk.NewKVStoreKey("ibc"),
|
||||||
capKeyStakingStore: sdk.NewKVStoreKey("staking"),
|
capKeyStakingStore: sdk.NewKVStoreKey("staking"),
|
||||||
}
|
}
|
||||||
|
@ -68,30 +68,17 @@ func NewBasecoinApp(logger log.Logger, db dbm.DB) *BasecoinApp {
|
||||||
AddRoute("ibc", ibc.NewHandler(ibcMapper, coinKeeper)).
|
AddRoute("ibc", ibc.NewHandler(ibcMapper, coinKeeper)).
|
||||||
AddRoute("staking", staking.NewHandler(stakeKeeper))
|
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
|
// 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.MountStore(app.capKeyMainStore, sdk.StoreTypeIAVL, dbMain)
|
||||||
|
app.MountStore(app.capKeyAccountStore, sdk.StoreTypeIAVL, dbAcc)
|
||||||
app.MountStore(app.capKeyIBCStore, sdk.StoreTypeIAVL, dbIBC)
|
app.MountStore(app.capKeyIBCStore, sdk.StoreTypeIAVL, dbIBC)
|
||||||
app.MountStore(app.capKeyStakingStore, sdk.StoreTypeIAVL, dbStaking)
|
app.MountStore(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))
|
||||||
err = app.LoadLatestVersion(app.capKeyMainStore)
|
err := app.LoadLatestVersion(app.capKeyMainStore)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmn.Exit(err.Error())
|
cmn.Exit(err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,8 +68,11 @@ var (
|
||||||
|
|
||||||
func newBasecoinApp() *BasecoinApp {
|
func newBasecoinApp() *BasecoinApp {
|
||||||
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "sdk/app")
|
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "sdk/app")
|
||||||
db := dbm.NewMemDB()
|
dbMain := dbm.NewMemDB()
|
||||||
return NewBasecoinApp(logger, db)
|
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) {
|
func TestGenesis(t *testing.T) {
|
||||||
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "sdk/app")
|
bapp := newBasecoinApp()
|
||||||
db := dbm.NewMemDB()
|
|
||||||
bapp := NewBasecoinApp(logger, db)
|
|
||||||
|
|
||||||
// Construct some genesis bytes to reflect basecoin/types/AppAccount
|
// Construct some genesis bytes to reflect basecoin/types/AppAccount
|
||||||
pk := crypto.GenPrivKeyEd25519().PubKey()
|
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) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
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
|
return bapp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue