Test improvements

This commit is contained in:
Jasmina Malicevic
2022-06-22 17:11:55 +02:00
parent 69eed50ee3
commit f7f4d16bd7
4 changed files with 17 additions and 15 deletions

View File

@@ -62,10 +62,10 @@ func TestByzantinePrevoteEquivocation(t *testing.T) {
blockDB := dbm.NewMemDB()
blockStore := store.NewBlockStore(blockDB)
// one for mempool, one for consensus
mtx := new(tmsync.Mutex)
// one for mempool, one for consensus
proxyAppConnCon := abcicli.NewLocalClient(mtx, app)
proxyAppConnConMem := abcicli.NewLocalClient(mtx, app)
// Make Mempool
var mempool mempl.Mempool
@@ -73,14 +73,14 @@ func TestByzantinePrevoteEquivocation(t *testing.T) {
switch thisConfig.Mempool.Version {
case cfg.MempoolV0:
mempool = mempoolv0.NewCListMempool(config.Mempool,
proxyAppConnCon,
proxyAppConnConMem,
state.LastBlockHeight,
mempoolv0.WithPreCheck(sm.TxPreCheck(state)),
mempoolv0.WithPostCheck(sm.TxPostCheck(state)))
case cfg.MempoolV1:
mempool = mempoolv1.NewTxMempool(logger,
config.Mempool,
proxyAppConnCon,
proxyAppConnConMem,
state.LastBlockHeight,
mempoolv1.WithPreCheck(sm.TxPreCheck(state)),
mempoolv1.WithPostCheck(sm.TxPostCheck(state)),

View File

@@ -154,10 +154,11 @@ func TestReactorWithEvidence(t *testing.T) {
blockDB := dbm.NewMemDB()
blockStore := store.NewBlockStore(blockDB)
// one for mempool, one for consensus
mtx := new(tmsync.Mutex)
memplMetrics := mempl.PrometheusMetrics("node_test_1")
memplMetrics := mempl.NopMetrics()
// one for mempool, one for consensus
proxyAppConnCon := abcicli.NewLocalClient(mtx, app)
proxyAppConnConMem := abcicli.NewLocalClient(mtx, app)
// Make Mempool
var mempool mempl.Mempool
@@ -165,7 +166,7 @@ func TestReactorWithEvidence(t *testing.T) {
switch config.Mempool.Version {
case cfg.MempoolV0:
mempool = mempoolv0.NewCListMempool(config.Mempool,
proxyAppConnCon,
proxyAppConnConMem,
state.LastBlockHeight,
mempoolv0.WithMetrics(memplMetrics),
mempoolv0.WithPreCheck(sm.TxPreCheck(state)),
@@ -173,7 +174,7 @@ func TestReactorWithEvidence(t *testing.T) {
case cfg.MempoolV1:
mempool = mempoolv1.NewTxMempool(logger,
config.Mempool,
proxyAppConnCon,
proxyAppConnConMem,
state.LastBlockHeight,
mempoolv1.WithMetrics(memplMetrics),
mempoolv1.WithPreCheck(sm.TxPreCheck(state)),

View File

@@ -12,8 +12,9 @@ import (
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/abci/example/kvstore"
"github.com/tendermint/tendermint/config"
cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/mempool"
"github.com/tendermint/tendermint/p2p"
@@ -127,13 +128,13 @@ func mempoolLogger() log.Logger {
}
func newMempoolWithApp(cc proxy.ClientCreator) (*TxMempool, func()) {
conf := config.ResetTestRoot("mempool_test")
conf := cfg.ResetTestRoot("mempool_test")
mp, cu := newMempoolWithAppAndConfig(cc, conf)
return mp, cu
}
func newMempoolWithAppAndConfig(cc proxy.ClientCreator, cfg *config.Config) (*TxMempool, func()) {
func newMempoolWithAppAndConfig(cc proxy.ClientCreator, conf *cfg.Config) (*TxMempool, func()) {
appConnMem, _ := cc.NewABCIClient()
appConnMem.SetLogger(log.TestingLogger().With("module", "abci-client", "connection", "mempool"))
err := appConnMem.Start()
@@ -141,9 +142,9 @@ func newMempoolWithAppAndConfig(cc proxy.ClientCreator, cfg *config.Config) (*Tx
panic(err)
}
mp := NewTxMempool(log.TestingLogger(), cfg.Mempool, appConnMem, 0)
mp := NewTxMempool(log.TestingLogger(), conf.Mempool, appConnMem, 0)
return mp, func() { os.RemoveAll(cfg.RootDir) }
return mp, func() { os.RemoveAll(conf.RootDir) }
}
func waitForTxsOnReactors(t *testing.T, txs types.Txs, reactors []*Reactor) {

View File

@@ -244,7 +244,7 @@ func TestCreateProposalBlock(t *testing.T) {
proposerAddr, _ := state.Validators.GetByIndex(0)
// Make Mempool
memplMetrics := mempl.PrometheusMetrics("node_test_1")
memplMetrics := mempl.NopMetrics()
var mempool mempl.Mempool
switch config.Mempool.Version {
@@ -347,7 +347,7 @@ func TestMaxProposalBlockSize(t *testing.T) {
proposerAddr, _ := state.Validators.GetByIndex(0)
// Make Mempool
memplMetrics := mempl.PrometheusMetrics("node_test_2")
memplMetrics := mempl.NopMetrics()
var mempool mempl.Mempool
switch config.Mempool.Version {
case cfg.MempoolV0: