From 0addbc707179fc2b97319a8fbd26d895d2a7ac1a Mon Sep 17 00:00:00 2001 From: tycho garen Date: Fri, 18 Mar 2022 08:54:20 -0400 Subject: [PATCH] consensus: avoid persistent kvstore in tests --- internal/consensus/common_test.go | 4 ---- internal/consensus/replay_test.go | 24 ++++++------------------ 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/internal/consensus/common_test.go b/internal/consensus/common_test.go index b0f22e54f..23327a7dd 100644 --- a/internal/consensus/common_test.go +++ b/internal/consensus/common_test.go @@ -973,10 +973,6 @@ func newEpehemeralKVStore(_ log.Logger, _ string) abci.Application { return kvstore.NewApplication() } -func newPersistentKVStore(logger log.Logger, dbDir string) abci.Application { - return kvstore.NewPersistentKVStoreApplication(logger, dbDir) -} - func signDataIsEqual(v1 *types.Vote, v2 *tmproto.Vote) bool { if v1 == nil || v2 == nil { return false diff --git a/internal/consensus/replay_test.go b/internal/consensus/replay_test.go index c735e9977..66e890b83 100644 --- a/internal/consensus/replay_test.go +++ b/internal/consensus/replay_test.go @@ -8,7 +8,6 @@ import ( "io" "math/rand" "os" - "path/filepath" "runtime" "testing" "time" @@ -338,13 +337,13 @@ func setupSimulator(ctx context.Context, t *testing.T) *simulatorTestSuite { nPeers, "replay_test", newMockTickerFunc(true), - newPersistentKVStore) + newEpehemeralKVStore) sim.Config = cfg + defer func() { t.Cleanup(cleanup) }() var err error sim.GenesisState, err = sm.MakeGenesisState(genDoc) require.NoError(t, err) - sim.CleanupFunc = cleanup partSize := types.BlockPartSizeBytes @@ -584,9 +583,6 @@ func setupSimulator(ctx context.Context, t *testing.T) *simulatorTestSuite { sim.Chain = append(sim.Chain, css[0].blockStore.LoadBlock(int64(i))) sim.Commits = append(sim.Commits, css[0].blockStore.LoadBlockCommit(int64(i))) } - if sim.CleanupFunc != nil { - t.Cleanup(sim.CleanupFunc) - } return sim } @@ -743,19 +739,14 @@ func testHandshakeReplay( ) latestAppHash := state.AppHash - // make a new client creator - kvstoreApp := kvstore.NewPersistentKVStoreApplication(logger, - filepath.Join(cfg.DBDir(), fmt.Sprintf("replay_test_%d_%d_a_r%d", nBlocks, mode, rand.Int()))) - t.Cleanup(func() { require.NoError(t, kvstoreApp.Close()) }) - eventBus := eventbus.NewDefault(logger) require.NoError(t, eventBus.Start(ctx)) - clientCreator2 := abciclient.NewLocalClient(logger, kvstoreApp) + client := abciclient.NewLocalClient(logger, kvstore.NewApplication()) if nBlocks > 0 { // run nBlocks against a new client to build up the app state. // use a throwaway tendermint state - proxyApp := proxy.New(clientCreator2, logger, proxy.NopMetrics()) + proxyApp := proxy.New(client, logger, proxy.NopMetrics()) stateDB1 := dbm.NewMemDB() stateStore := sm.NewStore(stateDB1) err := stateStore.Save(genesisState) @@ -776,7 +767,7 @@ func testHandshakeReplay( genDoc, err := sm.MakeGenesisDocFromFile(cfg.GenesisFile()) require.NoError(t, err) handshaker := NewHandshaker(logger, stateStore, state, store, eventBus, genDoc) - proxyApp := proxy.New(clientCreator2, logger, proxy.NopMetrics()) + proxyApp := proxy.New(client, logger, proxy.NopMetrics()) require.NoError(t, proxyApp.Start(ctx), "Error starting proxy app connections") require.True(t, proxyApp.IsRunning()) require.NotNil(t, proxyApp) @@ -905,10 +896,7 @@ func buildTMStateFromChain( t.Helper() // run the whole chain against this client to build up the tendermint state - kvstoreApp := kvstore.NewPersistentKVStoreApplication(logger, - filepath.Join(cfg.DBDir(), fmt.Sprintf("replay_test_%d_%d_t", nBlocks, mode))) - defer kvstoreApp.Close() - client := abciclient.NewLocalClient(logger, kvstoreApp) + client := abciclient.NewLocalClient(logger, kvstore.NewApplication()) proxyApp := proxy.New(client, logger, proxy.NopMetrics()) require.NoError(t, proxyApp.Start(ctx))