mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-21 07:24:36 +00:00
mocks
This commit is contained in:
@@ -58,13 +58,13 @@ func (_m *BlockStore) LoadBlockMeta(height int64) *types.BlockMeta {
|
||||
return r0
|
||||
}
|
||||
|
||||
type NewBlockStoreT interface {
|
||||
type mockConstructorTestingTNewBlockStore interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewBlockStore creates a new instance of BlockStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewBlockStore(t NewBlockStoreT) *BlockStore {
|
||||
func NewBlockStore(t mockConstructorTestingTNewBlockStore) *BlockStore {
|
||||
mock := &BlockStore{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
||||
@@ -100,13 +100,13 @@ func (_m *LightClient) VerifyLightBlockAtHeight(ctx context.Context, height int6
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
type NewLightClientT interface {
|
||||
type mockConstructorTestingTNewLightClient interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewLightClient creates a new instance of LightClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewLightClient(t NewLightClientT) *LightClient {
|
||||
func NewLightClient(t mockConstructorTestingTNewLightClient) *LightClient {
|
||||
mock := &LightClient{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
||||
+3
-1
@@ -429,7 +429,9 @@ func createEvidenceReactor(config *cfg.Config, dbProvider DBProvider,
|
||||
return nil, nil, err
|
||||
}
|
||||
evidenceLogger := logger.With("module", "evidence")
|
||||
evidencePool, err := evidence.NewPool(evidenceDB, sm.NewStore(stateDB), blockStore)
|
||||
evidencePool, err := evidence.NewPool(evidenceDB, sm.NewStore(stateDB, sm.StoreOptions{
|
||||
DiscardABCIResponses: false,
|
||||
}), blockStore)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
+2
-2
@@ -330,13 +330,13 @@ func (_m *Peer) TrySend(_a0 byte, _a1 []byte) bool {
|
||||
return r0
|
||||
}
|
||||
|
||||
type NewPeerT interface {
|
||||
type mockConstructorTestingTNewPeer interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewPeer creates a new instance of Peer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewPeer(t NewPeerT) *Peer {
|
||||
func NewPeer(t mockConstructorTestingTNewPeer) *Peer {
|
||||
mock := &Peer{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
||||
@@ -141,13 +141,13 @@ func (_m *AppConnConsensus) SetResponseCallback(_a0 abcicli.Callback) {
|
||||
_m.Called(_a0)
|
||||
}
|
||||
|
||||
type NewAppConnConsensusT interface {
|
||||
type mockConstructorTestingTNewAppConnConsensus interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewAppConnConsensus creates a new instance of AppConnConsensus. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewAppConnConsensus(t NewAppConnConsensusT) *AppConnConsensus {
|
||||
func NewAppConnConsensus(t mockConstructorTestingTNewAppConnConsensus) *AppConnConsensus {
|
||||
mock := &AppConnConsensus{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
||||
@@ -102,13 +102,13 @@ func (_m *AppConnMempool) SetResponseCallback(_a0 abcicli.Callback) {
|
||||
_m.Called(_a0)
|
||||
}
|
||||
|
||||
type NewAppConnMempoolT interface {
|
||||
type mockConstructorTestingTNewAppConnMempool interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewAppConnMempool creates a new instance of AppConnMempool. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewAppConnMempool(t NewAppConnMempoolT) *AppConnMempool {
|
||||
func NewAppConnMempool(t mockConstructorTestingTNewAppConnMempool) *AppConnMempool {
|
||||
mock := &AppConnMempool{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
||||
@@ -96,13 +96,13 @@ func (_m *AppConnQuery) QuerySync(_a0 types.RequestQuery) (*types.ResponseQuery,
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
type NewAppConnQueryT interface {
|
||||
type mockConstructorTestingTNewAppConnQuery interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewAppConnQuery creates a new instance of AppConnQuery. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewAppConnQuery(t NewAppConnQueryT) *AppConnQuery {
|
||||
func NewAppConnQuery(t mockConstructorTestingTNewAppConnQuery) *AppConnQuery {
|
||||
mock := &AppConnQuery{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
||||
@@ -119,13 +119,13 @@ func (_m *AppConnSnapshot) OfferSnapshotSync(_a0 types.RequestOfferSnapshot) (*t
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
type NewAppConnSnapshotT interface {
|
||||
type mockConstructorTestingTNewAppConnSnapshot interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewAppConnSnapshot creates a new instance of AppConnSnapshot. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewAppConnSnapshot(t NewAppConnSnapshotT) *AppConnSnapshot {
|
||||
func NewAppConnSnapshot(t mockConstructorTestingTNewAppConnSnapshot) *AppConnSnapshot {
|
||||
mock := &AppConnSnapshot{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
||||
@@ -35,13 +35,13 @@ func (_m *ClientCreator) NewABCIClient() (abcicli.Client, error) {
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
type NewClientCreatorT interface {
|
||||
type mockConstructorTestingTNewClientCreator interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewClientCreator creates a new instance of ClientCreator. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewClientCreator(t NewClientCreatorT) *ClientCreator {
|
||||
func NewClientCreator(t mockConstructorTestingTNewClientCreator) *ClientCreator {
|
||||
mock := &ClientCreator{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
||||
@@ -75,13 +75,13 @@ func (_m *BlockIndexer) Search(ctx context.Context, q *query.Query) ([]int64, er
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
type NewBlockIndexerT interface {
|
||||
type mockConstructorTestingTNewBlockIndexer interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewBlockIndexer creates a new instance of BlockIndexer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewBlockIndexer(t NewBlockIndexerT) *BlockIndexer {
|
||||
func NewBlockIndexer(t mockConstructorTestingTNewBlockIndexer) *BlockIndexer {
|
||||
mock := &BlockIndexer{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
||||
@@ -193,13 +193,13 @@ func (_m *BlockStore) Size() int64 {
|
||||
return r0
|
||||
}
|
||||
|
||||
type NewBlockStoreT interface {
|
||||
type mockConstructorTestingTNewBlockStore interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewBlockStore creates a new instance of BlockStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewBlockStore(t NewBlockStoreT) *BlockStore {
|
||||
func NewBlockStore(t mockConstructorTestingTNewBlockStore) *BlockStore {
|
||||
mock := &BlockStore{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
||||
@@ -70,13 +70,13 @@ func (_m *EvidencePool) Update(_a0 state.State, _a1 types.EvidenceList) {
|
||||
_m.Called(_a0, _a1)
|
||||
}
|
||||
|
||||
type NewEvidencePoolT interface {
|
||||
type mockConstructorTestingTNewEvidencePool interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewEvidencePool creates a new instance of EvidencePool. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewEvidencePool(t NewEvidencePoolT) *EvidencePool {
|
||||
func NewEvidencePool(t mockConstructorTestingTNewEvidencePool) *EvidencePool {
|
||||
mock := &EvidencePool{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
||||
+25
-3
@@ -67,7 +67,6 @@ func (_m *Store) Load() (state.State, error) {
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
|
||||
// LoadABCIResponses provides a mock function with given fields: _a0
|
||||
func (_m *Store) LoadABCIResponses(_a0 int64) (*tendermintstate.ABCIResponses, error) {
|
||||
ret := _m.Called(_a0)
|
||||
@@ -154,6 +153,29 @@ func (_m *Store) LoadFromDBOrGenesisFile(_a0 string) (state.State, error) {
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// LoadLastABCIResponse provides a mock function with given fields: _a0
|
||||
func (_m *Store) LoadLastABCIResponse(_a0 int64) (*tendermintstate.ABCIResponses, error) {
|
||||
ret := _m.Called(_a0)
|
||||
|
||||
var r0 *tendermintstate.ABCIResponses
|
||||
if rf, ok := ret.Get(0).(func(int64) *tendermintstate.ABCIResponses); ok {
|
||||
r0 = rf(_a0)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*tendermintstate.ABCIResponses)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(int64) error); ok {
|
||||
r1 = rf(_a0)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// LoadValidators provides a mock function with given fields: _a0
|
||||
func (_m *Store) LoadValidators(_a0 int64) (*tenderminttypes.ValidatorSet, error) {
|
||||
ret := _m.Called(_a0)
|
||||
@@ -219,13 +241,13 @@ func (_m *Store) SaveABCIResponses(_a0 int64, _a1 *tendermintstate.ABCIResponses
|
||||
return r0
|
||||
}
|
||||
|
||||
type NewStoreT interface {
|
||||
type mockConstructorTestingTNewStore interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewStore creates a new instance of Store. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewStore(t NewStoreT) *Store {
|
||||
func NewStore(t mockConstructorTestingTNewStore) *Store {
|
||||
mock := &Store{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
||||
@@ -85,8 +85,7 @@ func TestRollbackNoState(t *testing.T) {
|
||||
stateStore := state.NewStore(dbm.NewMemDB(),
|
||||
state.StoreOptions{
|
||||
DiscardABCIResponses: false,
|
||||
}
|
||||
)
|
||||
})
|
||||
blockStore := &mocks.BlockStore{}
|
||||
|
||||
_, _, err := state.Rollback(blockStore, stateStore)
|
||||
|
||||
+1
-4
@@ -17,10 +17,7 @@ import (
|
||||
"github.com/tendermint/tendermint/version"
|
||||
)
|
||||
|
||||
// database keys
|
||||
var (
|
||||
stateKey = []byte("stateKey")
|
||||
)
|
||||
// database key
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
+3
-1
@@ -224,7 +224,9 @@ func TestValidatorSimpleSaveLoad(t *testing.T) {
|
||||
defer tearDown(t)
|
||||
assert := assert.New(t)
|
||||
|
||||
statestore := sm.NewStore(stateDB)
|
||||
statestore := sm.NewStore(stateDB, sm.StoreOptions{
|
||||
DiscardABCIResponses: false,
|
||||
})
|
||||
|
||||
// Can't load anything for height 0.
|
||||
_, err := statestore.LoadValidators(0)
|
||||
|
||||
+1
-1
@@ -485,7 +485,7 @@ func (store dbStore) SaveABCIResponses(height int64, abciResponses *tmstate.ABCI
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := store.db.Set(ResponsesKey(height), bz); err != nil {
|
||||
if err := store.db.Set(ABCIResponsesKey(height), bz); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,13 +92,13 @@ func (_m *TxIndexer) Search(ctx context.Context, q *query.Query) ([]*types.TxRes
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
type NewTxIndexerT interface {
|
||||
type mockConstructorTestingTNewTxIndexer interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewTxIndexer creates a new instance of TxIndexer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewTxIndexer(t NewTxIndexerT) *TxIndexer {
|
||||
func NewTxIndexer(t mockConstructorTestingTNewTxIndexer) *TxIndexer {
|
||||
mock := &TxIndexer{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
||||
@@ -83,13 +83,13 @@ func (_m *StateProvider) State(ctx context.Context, height uint64) (state.State,
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
type NewStateProviderT interface {
|
||||
type mockConstructorTestingTNewStateProvider interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewStateProvider creates a new instance of StateProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewStateProvider(t NewStateProviderT) *StateProvider {
|
||||
func NewStateProvider(t mockConstructorTestingTNewStateProvider) *StateProvider {
|
||||
mock := &StateProvider{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
||||
+1
-1
@@ -431,7 +431,7 @@ func TestPruneBlocks(t *testing.T) {
|
||||
defer os.RemoveAll(config.RootDir)
|
||||
stateStore := sm.NewStore(dbm.NewMemDB(), sm.StoreOptions{
|
||||
DiscardABCIResponses: false,
|
||||
)}
|
||||
})
|
||||
state, err := stateStore.LoadFromDBOrGenesisFile(config.GenesisFile())
|
||||
require.NoError(t, err)
|
||||
db := dbm.NewMemDB()
|
||||
|
||||
Reference in New Issue
Block a user