From f7f4d16bd7cd5143cc2bbd3565eaadb987f7d34d Mon Sep 17 00:00:00 2001 From: Jasmina Malicevic Date: Wed, 22 Jun 2022 17:11:55 +0200 Subject: [PATCH] Test improvements --- consensus/byzantine_test.go | 8 ++++---- consensus/reactor_test.go | 9 +++++---- mempool/v1/reactor_test.go | 11 ++++++----- node/node_test.go | 4 ++-- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/consensus/byzantine_test.go b/consensus/byzantine_test.go index dd3779c8a..dd5febcbd 100644 --- a/consensus/byzantine_test.go +++ b/consensus/byzantine_test.go @@ -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)), diff --git a/consensus/reactor_test.go b/consensus/reactor_test.go index f20158fb7..5d68cd9b7 100644 --- a/consensus/reactor_test.go +++ b/consensus/reactor_test.go @@ -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)), diff --git a/mempool/v1/reactor_test.go b/mempool/v1/reactor_test.go index 19fd003a7..a91122016 100644 --- a/mempool/v1/reactor_test.go +++ b/mempool/v1/reactor_test.go @@ -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) { diff --git a/node/node_test.go b/node/node_test.go index efcb492a6..9b82d6ca2 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -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: