fix tests

This commit is contained in:
William Banfield
2021-10-12 17:53:29 -04:00
parent 4396224c1f
commit e412fe5a94
8 changed files with 78 additions and 48 deletions

View File

@@ -98,7 +98,7 @@ func (rts *reactorTestSuite) addNode(t *testing.T,
t.Helper()
rts.nodes = append(rts.nodes, nodeID)
rts.app[nodeID] = proxy.NewAppConns(abciclient.NewLocalCreator(&abci.BaseApplication{}))
rts.app[nodeID] = proxy.NewAppConns(abciclient.NewLocalCreator(&abci.BaseApplication{}), proxy.NopMetrics())
require.NoError(t, rts.app[nodeID].Start())
blockDB := dbm.NewMemDB()

View File

@@ -745,7 +745,7 @@ func testHandshakeReplay(t *testing.T, sim *simulatorTestSuite, nBlocks int, mod
if nBlocks > 0 {
// run nBlocks against a new client to build up the app state.
// use a throwaway tendermint state
proxyApp := proxy.NewAppConns(clientCreator2)
proxyApp := proxy.NewAppConns(clientCreator2, proxy.NopMetrics())
stateDB1 := dbm.NewMemDB()
stateStore := sm.NewStore(stateDB1)
err := stateStore.Save(genesisState)
@@ -765,7 +765,7 @@ func testHandshakeReplay(t *testing.T, sim *simulatorTestSuite, nBlocks int, mod
// now start the app using the handshake - it should sync
genDoc, _ := sm.MakeGenesisDocFromFile(cfg.GenesisFile())
handshaker := NewHandshaker(stateStore, state, store, genDoc)
proxyApp := proxy.NewAppConns(clientCreator2)
proxyApp := proxy.NewAppConns(clientCreator2, proxy.NopMetrics())
if err := proxyApp.Start(); err != nil {
t.Fatalf("Error starting proxy app connections: %v", err)
}
@@ -893,7 +893,7 @@ func buildTMStateFromChain(
defer kvstoreApp.Close()
clientCreator := abciclient.NewLocalCreator(kvstoreApp)
proxyApp := proxy.NewAppConns(clientCreator)
proxyApp := proxy.NewAppConns(clientCreator, proxy.NopMetrics())
if err := proxyApp.Start(); err != nil {
panic(err)
}
@@ -960,7 +960,7 @@ func TestHandshakePanicsIfAppReturnsWrongAppHash(t *testing.T) {
{
app := &badApp{numBlocks: 3, allHashesAreWrong: true}
clientCreator := abciclient.NewLocalCreator(app)
proxyApp := proxy.NewAppConns(clientCreator)
proxyApp := proxy.NewAppConns(clientCreator, proxy.NopMetrics())
err := proxyApp.Start()
require.NoError(t, err)
t.Cleanup(func() {
@@ -984,7 +984,7 @@ func TestHandshakePanicsIfAppReturnsWrongAppHash(t *testing.T) {
{
app := &badApp{numBlocks: 3, onlyLastHashIsWrong: true}
clientCreator := abciclient.NewLocalCreator(app)
proxyApp := proxy.NewAppConns(clientCreator)
proxyApp := proxy.NewAppConns(clientCreator, proxy.NopMetrics())
err := proxyApp.Start()
require.NoError(t, err)
t.Cleanup(func() {
@@ -1243,7 +1243,7 @@ func TestHandshakeUpdatesValidators(t *testing.T) {
// now start the app using the handshake - it should sync
genDoc, _ := sm.MakeGenesisDocFromFile(cfg.GenesisFile())
handshaker := NewHandshaker(stateStore, state, store, genDoc)
proxyApp := proxy.NewAppConns(clientCreator)
proxyApp := proxy.NewAppConns(clientCreator, proxy.NopMetrics())
if err := proxyApp.Start(); err != nil {
t.Fatalf("Error starting proxy app connections: %v", err)
}

View File

@@ -81,8 +81,10 @@ func (app *appConnConsensus) InitChainSync(
req types.RequestInitChain,
) (*types.ResponseInitChain, error) {
start := time.Now()
defer app.metrics.MethodTiming.With("method", "init_chain",
"type", "sync").Observe(time.Since(start).Seconds())
defer func() {
app.metrics.MethodTiming.With("method", "init_chain",
"type", "sync").Observe(time.Since(start).Seconds())
}()
return app.appConn.InitChainSync(ctx, req)
}
@@ -91,8 +93,10 @@ func (app *appConnConsensus) BeginBlockSync(
req types.RequestBeginBlock,
) (*types.ResponseBeginBlock, error) {
start := time.Now()
defer app.metrics.MethodTiming.With("method", "begin_block",
"type", "sync").Observe(time.Since(start).Seconds())
defer func() {
app.metrics.MethodTiming.With("method", "begin_block",
"type", "sync").Observe(time.Since(start).Seconds())
}()
return app.appConn.BeginBlockSync(ctx, req)
}
@@ -101,8 +105,10 @@ func (app *appConnConsensus) DeliverTxAsync(
req types.RequestDeliverTx,
) (*abciclient.ReqRes, error) {
start := time.Now()
defer app.metrics.MethodTiming.With("method", "deliver_tx",
"type", "aync").Observe(time.Since(start).Seconds())
defer func() {
app.metrics.MethodTiming.With("method", "deliver_tx",
"type", "aync").Observe(time.Since(start).Seconds())
}()
return app.appConn.DeliverTxAsync(ctx, req)
}
@@ -111,15 +117,19 @@ func (app *appConnConsensus) EndBlockSync(
req types.RequestEndBlock,
) (*types.ResponseEndBlock, error) {
start := time.Now()
defer app.metrics.MethodTiming.With("method", "deliver_tx",
"type", "sync").Observe(time.Since(start).Seconds())
defer func() {
app.metrics.MethodTiming.With("method", "deliver_tx",
"type", "sync").Observe(time.Since(start).Seconds())
}()
return app.appConn.EndBlockSync(ctx, req)
}
func (app *appConnConsensus) CommitSync(ctx context.Context) (*types.ResponseCommit, error) {
start := time.Now()
defer app.metrics.MethodTiming.With("method", "commit",
"type", "sync").Observe(time.Since(start).Seconds())
defer func() {
app.metrics.MethodTiming.With("method", "commit",
"type", "sync").Observe(time.Since(start).Seconds())
}()
return app.appConn.CommitSync(ctx)
}
@@ -148,15 +158,19 @@ func (app *appConnMempool) Error() error {
func (app *appConnMempool) FlushAsync(ctx context.Context) (*abciclient.ReqRes, error) {
start := time.Now()
defer app.metrics.MethodTiming.With("method", "flush",
"type", "sync").Observe(time.Since(start).Seconds())
defer func() {
app.metrics.MethodTiming.With("method", "flush",
"type", "sync").Observe(time.Since(start).Seconds())
}()
return app.appConn.FlushAsync(ctx)
}
func (app *appConnMempool) FlushSync(ctx context.Context) error {
start := time.Now()
defer app.metrics.MethodTiming.With("method", "flush",
"type", "sync").Observe(time.Since(start).Seconds())
defer func() {
app.metrics.MethodTiming.With("method", "flush",
"type", "sync").Observe(time.Since(start).Seconds())
}()
return app.appConn.FlushSync(ctx)
}
@@ -169,8 +183,10 @@ func (app *appConnMempool) CheckTxAsync(ctx context.Context, req types.RequestCh
func (app *appConnMempool) CheckTxSync(ctx context.Context, req types.RequestCheckTx) (*types.ResponseCheckTx, error) {
start := time.Now()
defer app.metrics.MethodTiming.With("method", "check_tx",
"type", "sync").Observe(time.Since(start).Seconds())
defer func() {
app.metrics.MethodTiming.With("method", "check_tx",
"type", "sync").Observe(time.Since(start).Seconds())
}()
return app.appConn.CheckTxSync(ctx, req)
}
@@ -195,22 +211,28 @@ func (app *appConnQuery) Error() error {
func (app *appConnQuery) EchoSync(ctx context.Context, msg string) (*types.ResponseEcho, error) {
start := time.Now()
defer app.metrics.MethodTiming.With("method", "echo",
"type", "sync").Observe(time.Since(start).Seconds())
defer func() {
app.metrics.MethodTiming.With("method", "echo",
"type", "sync").Observe(time.Since(start).Seconds())
}()
return app.appConn.EchoSync(ctx, msg)
}
func (app *appConnQuery) InfoSync(ctx context.Context, req types.RequestInfo) (*types.ResponseInfo, error) {
start := time.Now()
defer app.metrics.MethodTiming.With("method", "info",
"type", "sync").Observe(time.Since(start).Seconds())
defer func() {
app.metrics.MethodTiming.With("method", "info",
"type", "sync").Observe(time.Since(start).Seconds())
}()
return app.appConn.InfoSync(ctx, req)
}
func (app *appConnQuery) QuerySync(ctx context.Context, reqQuery types.RequestQuery) (*types.ResponseQuery, error) {
start := time.Now()
defer app.metrics.MethodTiming.With("method", "query",
"type", "sync").Observe(time.Since(start).Seconds())
defer func() {
app.metrics.MethodTiming.With("method", "query",
"type", "sync").Observe(time.Since(start).Seconds())
}()
return app.appConn.QuerySync(ctx, reqQuery)
}
@@ -238,8 +260,10 @@ func (app *appConnSnapshot) ListSnapshotsSync(
req types.RequestListSnapshots,
) (*types.ResponseListSnapshots, error) {
start := time.Now()
defer app.metrics.MethodTiming.With("method", "list_snapshots",
"type", "sync").Observe(time.Since(start).Seconds())
defer func() {
app.metrics.MethodTiming.With("method", "list_snapshots",
"type", "sync").Observe(time.Since(start).Seconds())
}()
return app.appConn.ListSnapshotsSync(ctx, req)
}
@@ -248,8 +272,10 @@ func (app *appConnSnapshot) OfferSnapshotSync(
req types.RequestOfferSnapshot,
) (*types.ResponseOfferSnapshot, error) {
start := time.Now()
defer app.metrics.MethodTiming.With("method", "offer_snapshot",
"type", "sync").Observe(time.Since(start).Seconds())
defer func() {
app.metrics.MethodTiming.With("method", "offer_snapshot",
"type", "sync").Observe(time.Since(start).Seconds())
}()
return app.appConn.OfferSnapshotSync(ctx, req)
}
@@ -257,8 +283,10 @@ func (app *appConnSnapshot) LoadSnapshotChunkSync(
ctx context.Context,
req types.RequestLoadSnapshotChunk) (*types.ResponseLoadSnapshotChunk, error) {
start := time.Now()
defer app.metrics.MethodTiming.With("method", "load_snapshot_chunk",
"type", "sync").Observe(time.Since(start).Seconds())
defer func() {
app.metrics.MethodTiming.With("method", "load_snapshot_chunk",
"type", "sync").Observe(time.Since(start).Seconds())
}()
return app.appConn.LoadSnapshotChunkSync(ctx, req)
}
@@ -266,7 +294,9 @@ func (app *appConnSnapshot) ApplySnapshotChunkSync(
ctx context.Context,
req types.RequestApplySnapshotChunk) (*types.ResponseApplySnapshotChunk, error) {
start := time.Now()
defer app.metrics.MethodTiming.With("method", "apply_snapshot_chunk",
"type", "sync").Observe(time.Since(start).Seconds())
defer func() {
app.metrics.MethodTiming.With("method", "apply_snapshot_chunk",
"type", "sync").Observe(time.Since(start).Seconds())
}()
return app.appConn.ApplySnapshotChunkSync(ctx, req)
}

View File

@@ -31,7 +31,7 @@ func TestAppConns_Start_Stop(t *testing.T) {
return clientMock, nil
}
appConns := NewAppConns(creator)
appConns := NewAppConns(creator, NopMetrics())
err := appConns.Start()
require.NoError(t, err)

View File

@@ -36,7 +36,7 @@ var (
func TestApplyBlock(t *testing.T) {
app := &testApp{}
cc := abciclient.NewLocalCreator(app)
proxyApp := proxy.NewAppConns(cc)
proxyApp := proxy.NewAppConns(cc, proxy.NopMetrics())
err := proxyApp.Start()
require.Nil(t, err)
defer proxyApp.Stop() //nolint:errcheck // ignore for tests
@@ -61,7 +61,7 @@ func TestApplyBlock(t *testing.T) {
func TestBeginBlockValidators(t *testing.T) {
app := &testApp{}
cc := abciclient.NewLocalCreator(app)
proxyApp := proxy.NewAppConns(cc)
proxyApp := proxy.NewAppConns(cc, proxy.NopMetrics())
err := proxyApp.Start()
require.Nil(t, err)
defer proxyApp.Stop() //nolint:errcheck // no need to check error again
@@ -124,7 +124,7 @@ func TestBeginBlockValidators(t *testing.T) {
func TestBeginBlockByzantineValidators(t *testing.T) {
app := &testApp{}
cc := abciclient.NewLocalCreator(app)
proxyApp := proxy.NewAppConns(cc)
proxyApp := proxy.NewAppConns(cc, proxy.NopMetrics())
err := proxyApp.Start()
require.Nil(t, err)
defer proxyApp.Stop() //nolint:errcheck // ignore for tests
@@ -349,7 +349,7 @@ func TestUpdateValidators(t *testing.T) {
func TestEndBlockValidatorUpdates(t *testing.T) {
app := &testApp{}
cc := abciclient.NewLocalCreator(app)
proxyApp := proxy.NewAppConns(cc)
proxyApp := proxy.NewAppConns(cc, proxy.NopMetrics())
err := proxyApp.Start()
require.Nil(t, err)
defer proxyApp.Stop() //nolint:errcheck // ignore for tests
@@ -422,7 +422,7 @@ func TestEndBlockValidatorUpdates(t *testing.T) {
func TestEndBlockValidatorUpdatesResultingInEmptySet(t *testing.T) {
app := &testApp{}
cc := abciclient.NewLocalCreator(app)
proxyApp := proxy.NewAppConns(cc)
proxyApp := proxy.NewAppConns(cc, proxy.NopMetrics())
err := proxyApp.Start()
require.Nil(t, err)
defer proxyApp.Stop() //nolint:errcheck // ignore for tests

View File

@@ -31,7 +31,7 @@ type paramsChangeTestCase struct {
func newTestApp() proxy.AppConns {
app := &testApp{}
cc := abciclient.NewLocalCreator(app)
return proxy.NewAppConns(cc)
return proxy.NewAppConns(cc, proxy.NopMetrics())
}
func makeAndCommitGoodBlock(

View File

@@ -214,7 +214,7 @@ func TestCreateProposalBlock(t *testing.T) {
cfg := config.ResetTestRoot("node_create_proposal")
defer os.RemoveAll(cfg.RootDir)
cc := abciclient.NewLocalCreator(kvstore.NewApplication())
proxyApp := proxy.NewAppConns(cc)
proxyApp := proxy.NewAppConns(cc, proxy.NopMetrics())
err := proxyApp.Start()
require.Nil(t, err)
defer proxyApp.Stop() //nolint:errcheck // ignore for tests
@@ -306,7 +306,7 @@ func TestMaxTxsProposalBlockSize(t *testing.T) {
cfg := config.ResetTestRoot("node_create_proposal")
defer os.RemoveAll(cfg.RootDir)
cc := abciclient.NewLocalCreator(kvstore.NewApplication())
proxyApp := proxy.NewAppConns(cc)
proxyApp := proxy.NewAppConns(cc, proxy.NopMetrics())
err := proxyApp.Start()
require.Nil(t, err)
defer proxyApp.Stop() //nolint:errcheck // ignore for tests
@@ -368,7 +368,7 @@ func TestMaxProposalBlockSize(t *testing.T) {
cfg := config.ResetTestRoot("node_create_proposal")
defer os.RemoveAll(cfg.RootDir)
cc := abciclient.NewLocalCreator(kvstore.NewApplication())
proxyApp := proxy.NewAppConns(cc)
proxyApp := proxy.NewAppConns(cc, proxy.NopMetrics())
err := proxyApp.Start()
require.Nil(t, err)
defer proxyApp.Stop() //nolint:errcheck // ignore for tests

View File

@@ -48,7 +48,7 @@ func initDBs(cfg *config.Config, dbProvider config.DBProvider) (blockStore *stor
}
func createAndStartProxyAppConns(clientCreator abciclient.Creator, logger log.Logger, metrics *proxy.Metrics) (proxy.AppConns, error) {
proxyApp := proxy.NewAppConns(clientCreator, metrics)
proxyApp := proxy.NewAppConns(clientCreator, metrics, proxy.NopMetrics())
proxyApp.SetLogger(logger.With("module", "proxy"))
if err := proxyApp.Start(); err != nil {
return nil, fmt.Errorf("error starting proxy app connections: %v", err)