github.com/vipernet-xyz/tm@v0.34.24/test/maverick/consensus/replay_stubs.go (about)

     1  package consensus
     2  
     3  import (
     4  	abci "github.com/vipernet-xyz/tm/abci/types"
     5  	"github.com/vipernet-xyz/tm/libs/clist"
     6  	mempl "github.com/vipernet-xyz/tm/mempool"
     7  	tmstate "github.com/vipernet-xyz/tm/proto/tendermint/state"
     8  	"github.com/vipernet-xyz/tm/proxy"
     9  	"github.com/vipernet-xyz/tm/types"
    10  )
    11  
    12  //-----------------------------------------------------------------------------
    13  
    14  type emptyMempool struct{}
    15  
    16  var _ mempl.Mempool = emptyMempool{}
    17  
    18  func (emptyMempool) Lock()            {}
    19  func (emptyMempool) Unlock()          {}
    20  func (emptyMempool) Size() int        { return 0 }
    21  func (emptyMempool) SizeBytes() int64 { return 0 }
    22  func (emptyMempool) CheckTx(_ types.Tx, _ func(*abci.Response), _ mempl.TxInfo) error {
    23  	return nil
    24  }
    25  func (emptyMempool) RemoveTxByKey(txKey types.TxKey) error   { return nil }
    26  func (emptyMempool) ReapMaxBytesMaxGas(_, _ int64) types.Txs { return types.Txs{} }
    27  func (emptyMempool) ReapMaxTxs(n int) types.Txs              { return types.Txs{} }
    28  func (emptyMempool) Update(
    29  	_ int64,
    30  	_ types.Txs,
    31  	_ []*abci.ResponseDeliverTx,
    32  	_ mempl.PreCheckFunc,
    33  	_ mempl.PostCheckFunc,
    34  ) error {
    35  	return nil
    36  }
    37  func (emptyMempool) Flush()                        {}
    38  func (emptyMempool) FlushAppConn() error           { return nil }
    39  func (emptyMempool) TxsAvailable() <-chan struct{} { return make(chan struct{}) }
    40  func (emptyMempool) EnableTxsAvailable()           {}
    41  func (emptyMempool) TxsBytes() int64               { return 0 }
    42  
    43  func (emptyMempool) TxsFront() *clist.CElement    { return nil }
    44  func (emptyMempool) TxsWaitChan() <-chan struct{} { return nil }
    45  
    46  func (emptyMempool) InitWAL() error { return nil }
    47  func (emptyMempool) CloseWAL()      {}
    48  
    49  //-----------------------------------------------------------------------------
    50  // mockProxyApp uses ABCIResponses to give the right results.
    51  //
    52  // Useful because we don't want to call Commit() twice for the same block on
    53  // the real app.
    54  
    55  func newMockProxyApp(appHash []byte, abciResponses *tmstate.ABCIResponses) proxy.AppConnConsensus {
    56  	clientCreator := proxy.NewLocalClientCreator(&mockProxyApp{
    57  		appHash:       appHash,
    58  		abciResponses: abciResponses,
    59  	})
    60  	cli, _ := clientCreator.NewABCIClient()
    61  	err := cli.Start()
    62  	if err != nil {
    63  		panic(err)
    64  	}
    65  	return proxy.NewAppConnConsensus(cli)
    66  }
    67  
    68  type mockProxyApp struct {
    69  	abci.BaseApplication
    70  
    71  	appHash       []byte
    72  	txCount       int
    73  	abciResponses *tmstate.ABCIResponses
    74  }
    75  
    76  func (mock *mockProxyApp) DeliverTx(req abci.RequestDeliverTx) abci.ResponseDeliverTx {
    77  	r := mock.abciResponses.DeliverTxs[mock.txCount]
    78  	mock.txCount++
    79  	if r == nil {
    80  		return abci.ResponseDeliverTx{}
    81  	}
    82  	return *r
    83  }
    84  
    85  func (mock *mockProxyApp) EndBlock(req abci.RequestEndBlock) abci.ResponseEndBlock {
    86  	mock.txCount = 0
    87  	return *mock.abciResponses.EndBlock
    88  }
    89  
    90  func (mock *mockProxyApp) Commit() abci.ResponseCommit {
    91  	return abci.ResponseCommit{Data: mock.appHash}
    92  }