fix tests for state and mempool
This commit is contained in:
parent
24ce90fc72
commit
4982cb4d1f
|
@ -4,14 +4,28 @@ import (
|
|||
"encoding/binary"
|
||||
"testing"
|
||||
|
||||
"github.com/tendermint/abci/example/counter"
|
||||
cfg "github.com/tendermint/tendermint/config"
|
||||
"github.com/tendermint/tendermint/config/tendermint_test"
|
||||
"github.com/tendermint/tendermint/proxy"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
"github.com/tendermint/abci/example/counter"
|
||||
)
|
||||
|
||||
func ResetConfig(name string) *Config {
|
||||
viperConfig := tendermint_test.ResetConfig(name)
|
||||
config := new(struct {
|
||||
cfg.Config `mapstructure:",squash"`
|
||||
Mempool *Config `mapstructure:"mempool"`
|
||||
})
|
||||
if err := viperConfig.Unmarshal(config); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return config.Mempool
|
||||
|
||||
}
|
||||
|
||||
func TestSerialReap(t *testing.T) {
|
||||
config := tendermint_test.ResetConfig("mempool_mempool_test")
|
||||
config := ResetConfig("mempool_test")
|
||||
|
||||
app := counter.NewCounterApplication(true)
|
||||
app.SetOption("serial", "on")
|
||||
|
|
|
@ -7,12 +7,10 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
"github.com/tendermint/abci/example/dummy"
|
||||
crypto "github.com/tendermint/go-crypto"
|
||||
dbm "github.com/tendermint/tmlibs/db"
|
||||
cfg "github.com/tendermint/tendermint/config/tendermint_test"
|
||||
"github.com/tendermint/tendermint/mempool"
|
||||
"github.com/tendermint/tendermint/proxy"
|
||||
"github.com/tendermint/tendermint/state/txindex"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
dbm "github.com/tendermint/tmlibs/db"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -24,12 +22,10 @@ var (
|
|||
|
||||
func TestApplyBlock(t *testing.T) {
|
||||
cc := proxy.NewLocalClientCreator(dummy.NewDummyApplication())
|
||||
config := cfg.ResetConfig("execution_test_")
|
||||
proxyApp := proxy.NewAppConns(config, cc, nil)
|
||||
proxyApp := proxy.NewAppConns(cc, nil)
|
||||
_, err := proxyApp.Start()
|
||||
require.Nil(t, err)
|
||||
defer proxyApp.Stop()
|
||||
mempool := mempool.NewMempool(config, proxyApp.Mempool())
|
||||
|
||||
state := state()
|
||||
indexer := &dummyIndexer{0}
|
||||
|
@ -38,7 +34,7 @@ func TestApplyBlock(t *testing.T) {
|
|||
// make block
|
||||
block := makeBlock(1, state)
|
||||
|
||||
err = state.ApplyBlock(nil, proxyApp.Consensus(), block, block.MakePartSet(testPartSize).Header(), mempool)
|
||||
err = state.ApplyBlock(nil, proxyApp.Consensus(), block, block.MakePartSet(testPartSize).Header(), types.MockMempool{})
|
||||
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, nTxsPerBlock, indexer.Indexed) // test indexing works
|
||||
|
|
|
@ -7,15 +7,27 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
abci "github.com/tendermint/abci/types"
|
||||
"github.com/tendermint/go-crypto"
|
||||
dbm "github.com/tendermint/tmlibs/db"
|
||||
cfg "github.com/tendermint/tendermint/config"
|
||||
"github.com/tendermint/tendermint/config/tendermint_test"
|
||||
dbm "github.com/tendermint/tmlibs/db"
|
||||
)
|
||||
|
||||
func ResetConfig(name string) *cfg.Config {
|
||||
viperConfig := tendermint_test.ResetConfig(name)
|
||||
config := new(struct {
|
||||
cfg.Config `mapstructure:",squash"`
|
||||
})
|
||||
if err := viperConfig.Unmarshal(config); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return &config.Config
|
||||
}
|
||||
|
||||
func TestStateCopyEquals(t *testing.T) {
|
||||
config := tendermint_test.ResetConfig("state_")
|
||||
config := ResetConfig("state_")
|
||||
// Get State db
|
||||
stateDB := dbm.NewDB("state", config.GetString("db_backend"), config.GetString("db_dir"))
|
||||
state := GetState(config, stateDB)
|
||||
stateDB := dbm.NewDB("state", config.DBBackend, config.DBDir)
|
||||
state := GetState(stateDB, config.GenesisFile)
|
||||
|
||||
stateCopy := state.Copy()
|
||||
|
||||
|
@ -31,10 +43,10 @@ func TestStateCopyEquals(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestStateSaveLoad(t *testing.T) {
|
||||
config := tendermint_test.ResetConfig("state_")
|
||||
config := ResetConfig("state_")
|
||||
// Get State db
|
||||
stateDB := dbm.NewDB("state", config.GetString("db_backend"), config.GetString("db_dir"))
|
||||
state := GetState(config, stateDB)
|
||||
stateDB := dbm.NewDB("state", config.DBBackend, config.DBDir)
|
||||
state := GetState(stateDB, config.GenesisFile)
|
||||
|
||||
state.LastBlockHeight += 1
|
||||
state.Save()
|
||||
|
@ -48,9 +60,9 @@ func TestStateSaveLoad(t *testing.T) {
|
|||
func TestABCIResponsesSaveLoad(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
config := tendermint_test.ResetConfig("state_")
|
||||
stateDB := dbm.NewDB("state", config.GetString("db_backend"), config.GetString("db_dir"))
|
||||
state := GetState(config, stateDB)
|
||||
config := ResetConfig("state_")
|
||||
stateDB := dbm.NewDB("state", config.DBBackend, config.DBDir)
|
||||
state := GetState(stateDB, config.GenesisFile)
|
||||
|
||||
state.LastBlockHeight += 1
|
||||
|
||||
|
|
Loading…
Reference in New Issue