diff --git a/abci/client/mocks/client.go b/abci/client/mocks/client.go index 664646e61..efd0960d6 100644 --- a/abci/client/mocks/client.go +++ b/abci/client/mocks/client.go @@ -801,3 +801,18 @@ func (_m *Client) String() string { func (_m *Client) Wait() { _m.Called() } + +type mockConstructorTestingTNewClient interface { + mock.TestingT + Cleanup(func()) +} + +// NewClient creates a new instance of Client. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewClient(t mockConstructorTestingTNewClient) *Client { + mock := &Client{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/cmd/tendermint/commands/reindex_event.go b/cmd/tendermint/commands/reindex_event.go index bd9577963..b147768d4 100644 --- a/cmd/tendermint/commands/reindex_event.go +++ b/cmd/tendermint/commands/reindex_event.go @@ -37,6 +37,9 @@ replace the backend. The default start-height is 0, meaning the tooling will sta reindex from the base block height(inclusive); and the default end-height is 0, meaning the tooling will reindex until the latest block height(inclusive). User can omit either or both arguments. + +Note: This operation requires ABCIResponses. Do not set DiscardABCIResponses to true if you +want to use this command. `, Example: ` tendermint reindex-event @@ -154,7 +157,7 @@ func loadStateAndBlockStore(cfg *tmcfg.Config) (*store.BlockStore, state.Store, if err != nil { return nil, nil, err } - stateStore := state.NewStore(stateDB) + stateStore := state.NewStore(stateDB, cfg.RPC.DiscardABCIResponses) return blockStore, stateStore, nil } diff --git a/config/config.go b/config/config.go index c8f4b3a88..de1dc68a3 100644 --- a/config/config.go +++ b/config/config.go @@ -582,8 +582,8 @@ func DefaultRPCConfig() *RPCConfig { MaxBodyBytes: int64(1000000), // 1MB MaxHeaderBytes: 1 << 20, // same as the net/http default - TLSCertFile: "", - TLSKeyFile: "", + TLSCertFile: "", + TLSKeyFile: "", DiscardABCIResponses: true, } } diff --git a/internal/blocksync/v0/reactor_test.go b/internal/blocksync/v0/reactor_test.go index 2cac774e5..b83faeb17 100644 --- a/internal/blocksync/v0/reactor_test.go +++ b/internal/blocksync/v0/reactor_test.go @@ -103,7 +103,7 @@ func (rts *reactorTestSuite) addNode(t *testing.T, blockDB := dbm.NewMemDB() stateDB := dbm.NewMemDB() - stateStore := sm.NewStore(stateDB) + stateStore := sm.NewStore(stateDB, false) blockStore := store.NewBlockStore(blockDB) state, err := sm.MakeGenesisState(genDoc) diff --git a/internal/blocksync/v2/reactor_test.go b/internal/blocksync/v2/reactor_test.go index f0266029e..620c4019d 100644 --- a/internal/blocksync/v2/reactor_test.go +++ b/internal/blocksync/v2/reactor_test.go @@ -169,7 +169,7 @@ func newTestReactor(t *testing.T, p testReactorParams) *BlockchainReactor { err := proxyApp.Start() require.NoError(t, err) db := dbm.NewMemDB() - stateStore := sm.NewStore(db) + stateStore := sm.NewStore(db, false) blockStore := tmstore.NewBlockStore(dbm.NewMemDB()) appl = sm.NewBlockExecutor( stateStore, p.logger, proxyApp.Consensus(), mock.Mempool{}, sm.EmptyEvidencePool{}, blockStore) @@ -494,7 +494,7 @@ func newReactorStore( stateDB := dbm.NewMemDB() blockStore := tmstore.NewBlockStore(dbm.NewMemDB()) - stateStore := sm.NewStore(stateDB) + stateStore := sm.NewStore(stateDB, false) state, err := sm.MakeGenesisState(genDoc) require.NoError(t, err) diff --git a/internal/consensus/byzantine_test.go b/internal/consensus/byzantine_test.go index ab8d12205..d690ef9fe 100644 --- a/internal/consensus/byzantine_test.go +++ b/internal/consensus/byzantine_test.go @@ -45,7 +45,7 @@ func TestByzantinePrevoteEquivocation(t *testing.T) { func() { logger := consensusLogger().With("test", "byzantine", "validator", i) stateDB := dbm.NewMemDB() // each state needs its own db - stateStore := sm.NewStore(stateDB) + stateStore := sm.NewStore(stateDB, false) state, err := sm.MakeGenesisState(genDoc) require.NoError(t, err) require.NoError(t, stateStore.Save(state)) diff --git a/internal/consensus/common_test.go b/internal/consensus/common_test.go index 0477c8b0c..e29f8cdea 100644 --- a/internal/consensus/common_test.go +++ b/internal/consensus/common_test.go @@ -431,7 +431,7 @@ func newStateWithConfigAndBlockStore( // Make State stateDB := dbm.NewMemDB() - stateStore := sm.NewStore(stateDB) + stateStore := sm.NewStore(stateDB, false) if err := stateStore.Save(state); err != nil { // for save height 1's validators info panic(err) } diff --git a/internal/consensus/mempool_test.go b/internal/consensus/mempool_test.go index 558dbd4b3..f468620d9 100644 --- a/internal/consensus/mempool_test.go +++ b/internal/consensus/mempool_test.go @@ -126,7 +126,7 @@ func TestMempoolTxConcurrentWithCommit(t *testing.T) { config := configSetup(t) state, privVals := randGenesisState(config, 1, false, 10) - stateStore := sm.NewStore(dbm.NewMemDB()) + stateStore := sm.NewStore(dbm.NewMemDB(), false) blockStore := store.NewBlockStore(dbm.NewMemDB()) cs := newStateWithConfigAndBlockStore(config, state, privVals[0], NewCounterApplication(), blockStore) err := stateStore.Save(state) @@ -153,7 +153,7 @@ func TestMempoolRmBadTx(t *testing.T) { state, privVals := randGenesisState(config, 1, false, 10) app := NewCounterApplication() - stateStore := sm.NewStore(dbm.NewMemDB()) + stateStore := sm.NewStore(dbm.NewMemDB(), false) blockStore := store.NewBlockStore(dbm.NewMemDB()) cs := newStateWithConfigAndBlockStore(config, state, privVals[0], app, blockStore) err := stateStore.Save(state) diff --git a/internal/consensus/mocks/cons_sync_reactor.go b/internal/consensus/mocks/cons_sync_reactor.go index 5ac592f0d..25caddfb9 100644 --- a/internal/consensus/mocks/cons_sync_reactor.go +++ b/internal/consensus/mocks/cons_sync_reactor.go @@ -26,3 +26,18 @@ func (_m *ConsSyncReactor) SetStateSyncingMetrics(_a0 float64) { func (_m *ConsSyncReactor) SwitchToConsensus(_a0 state.State, _a1 bool) { _m.Called(_a0, _a1) } + +type mockConstructorTestingTNewConsSyncReactor interface { + mock.TestingT + Cleanup(func()) +} + +// NewConsSyncReactor creates a new instance of ConsSyncReactor. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewConsSyncReactor(t mockConstructorTestingTNewConsSyncReactor) *ConsSyncReactor { + mock := &ConsSyncReactor{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/consensus/reactor_test.go b/internal/consensus/reactor_test.go index 5843dc3b5..a1ae74b22 100644 --- a/internal/consensus/reactor_test.go +++ b/internal/consensus/reactor_test.go @@ -329,7 +329,7 @@ func TestReactorWithEvidence(t *testing.T) { for i := 0; i < n; i++ { stateDB := dbm.NewMemDB() // each state needs its own db - stateStore := sm.NewStore(stateDB) + stateStore := sm.NewStore(stateDB, false) state, err := sm.MakeGenesisState(genDoc) require.NoError(t, err) thisConfig, err := ResetConfig(fmt.Sprintf("%s_%d", testName, i)) diff --git a/internal/consensus/replay_file.go b/internal/consensus/replay_file.go index f60dff531..8e4581668 100644 --- a/internal/consensus/replay_file.go +++ b/internal/consensus/replay_file.go @@ -300,7 +300,7 @@ func newConsensusStateForReplay(cfg config.BaseConfig, csConfig *config.Consensu if err != nil { tmos.Exit(err.Error()) } - stateStore := sm.NewStore(stateDB) + stateStore := sm.NewStore(stateDB, false) gdoc, err := sm.MakeGenesisDocFromFile(cfg.GenesisFile()) if err != nil { tmos.Exit(err.Error()) diff --git a/internal/consensus/replay_stubs.go b/internal/consensus/replay_stubs.go index 8f6edd8ef..1235baccb 100644 --- a/internal/consensus/replay_stubs.go +++ b/internal/consensus/replay_stubs.go @@ -54,7 +54,7 @@ func (emptyMempool) CloseWAL() {} // Useful because we don't want to call Commit() twice for the same block on // the real app. -func newMockProxyApp(appHash []byte, abciResponses *tmstate.ABCIResponsesInfo) proxy.AppConnConsensus { +func newMockProxyApp(appHash []byte, abciResponses *tmstate.ABCIResponses) proxy.AppConnConsensus { clientCreator := abciclient.NewLocalCreator(&mockProxyApp{ appHash: appHash, abciResponses: abciResponses, @@ -72,11 +72,11 @@ type mockProxyApp struct { appHash []byte txCount int - abciResponses *tmstate.ABCIResponsesInfo + abciResponses *tmstate.ABCIResponses } func (mock *mockProxyApp) DeliverTx(req abci.RequestDeliverTx) abci.ResponseDeliverTx { - r := mock.abciResponses.AbciResponses.DeliverTxs[mock.txCount] + r := mock.abciResponses.DeliverTxs[mock.txCount] mock.txCount++ if r == nil { return abci.ResponseDeliverTx{} @@ -86,7 +86,7 @@ func (mock *mockProxyApp) DeliverTx(req abci.RequestDeliverTx) abci.ResponseDeli func (mock *mockProxyApp) EndBlock(req abci.RequestEndBlock) abci.ResponseEndBlock { mock.txCount = 0 - return *mock.abciResponses.AbciResponses.EndBlock + return *mock.abciResponses.EndBlock } func (mock *mockProxyApp) Commit() abci.ResponseCommit { diff --git a/internal/consensus/replay_test.go b/internal/consensus/replay_test.go index 42c449a05..41756e4be 100644 --- a/internal/consensus/replay_test.go +++ b/internal/consensus/replay_test.go @@ -152,7 +152,7 @@ LOOP: logger := log.NewNopLogger() blockDB := dbm.NewMemDB() stateDB := dbm.NewMemDB() - stateStore := sm.NewStore(stateDB) + stateStore := sm.NewStore(stateDB, false) blockStore := store.NewBlockStore(blockDB) state, err := sm.MakeGenesisStateFromFile(consensusReplayConfig.GenesisFile()) require.NoError(t, err) @@ -730,7 +730,7 @@ func testHandshakeReplay(t *testing.T, sim *simulatorTestSuite, nBlocks int, mod stateDB, genesisState, store = stateAndStore(cfg, pubKey, kvstore.ProtocolVersion) } - stateStore := sm.NewStore(stateDB) + stateStore := sm.NewStore(stateDB, false) store.chain = chain store.commits = commits @@ -749,8 +749,7 @@ func testHandshakeReplay(t *testing.T, sim *simulatorTestSuite, nBlocks int, mod // run nBlocks against a new client to build up the app state. // use a throwaway tendermint state proxyApp := proxy.NewAppConns(clientCreator2, proxy.NopMetrics()) - stateDB1 := dbm.NewMemDB() - stateStore := sm.NewStore(stateDB1) + stateStore := sm.NewStore(dbm.NewMemDB(), false) err := stateStore.Save(genesisState) require.NoError(t, err) buildAppStateFromChain(proxyApp, stateStore, sim.Mempool, sim.Evpool, genesisState, chain, nBlocks, mode, store) @@ -950,7 +949,7 @@ func TestHandshakePanicsIfAppReturnsWrongAppHash(t *testing.T) { pubKey, err := privVal.GetPubKey(context.Background()) require.NoError(t, err) stateDB, state, store := stateAndStore(cfg, pubKey, appVersion) - stateStore := sm.NewStore(stateDB) + stateStore := sm.NewStore(stateDB, false) genDoc, _ := sm.MakeGenesisDocFromFile(cfg.GenesisFile()) state.LastValidators = state.Validators.Copy() // mode = 0 for committing all the blocks @@ -1161,7 +1160,7 @@ func stateAndStore( pubKey crypto.PubKey, appVersion uint64) (dbm.DB, sm.State, *mockBlockStore) { stateDB := dbm.NewMemDB() - stateStore := sm.NewStore(stateDB) + stateStore := sm.NewStore(stateDB, false) state, _ := sm.MakeGenesisStateFromFile(cfg.GenesisFile()) state.Version.Consensus.App = appVersion store := newMockBlockStore(cfg, state.ConsensusParams) @@ -1242,7 +1241,7 @@ func TestHandshakeUpdatesValidators(t *testing.T) { pubKey, err := privVal.GetPubKey(context.Background()) require.NoError(t, err) stateDB, state, store := stateAndStore(cfg, pubKey, 0x0) - stateStore := sm.NewStore(stateDB) + stateStore := sm.NewStore(stateDB, false) oldValAddr := state.Validators.Validators[0].Address diff --git a/internal/consensus/wal_generator.go b/internal/consensus/wal_generator.go index 6ac438c4a..535953869 100644 --- a/internal/consensus/wal_generator.go +++ b/internal/consensus/wal_generator.go @@ -53,7 +53,7 @@ func WALGenerateNBlocks(t *testing.T, wr io.Writer, numBlocks int) (err error) { } blockStoreDB := dbm.NewMemDB() stateDB := blockStoreDB - stateStore := sm.NewStore(stateDB) + stateStore := sm.NewStore(stateDB, false) state, err := sm.MakeGenesisState(genDoc) if err != nil { return fmt.Errorf("failed to make genesis state: %w", err) diff --git a/internal/evidence/mocks/block_store.go b/internal/evidence/mocks/block_store.go index ef3346b2a..e61c4e0ae 100644 --- a/internal/evidence/mocks/block_store.go +++ b/internal/evidence/mocks/block_store.go @@ -57,3 +57,18 @@ func (_m *BlockStore) LoadBlockMeta(height int64) *types.BlockMeta { return r0 } + +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 mockConstructorTestingTNewBlockStore) *BlockStore { + mock := &BlockStore{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/evidence/pool_test.go b/internal/evidence/pool_test.go index f38c09e02..90c018cd1 100644 --- a/internal/evidence/pool_test.go +++ b/internal/evidence/pool_test.go @@ -387,7 +387,7 @@ func TestRecoverPendingEvidence(t *testing.T) { func initializeStateFromValidatorSet(t *testing.T, valSet *types.ValidatorSet, height int64) sm.Store { stateDB := dbm.NewMemDB() - stateStore := sm.NewStore(stateDB) + stateStore := sm.NewStore(stateDB, false) state := sm.State{ ChainID: evidenceChainID, InitialHeight: 1, diff --git a/internal/inspect/inspect.go b/internal/inspect/inspect.go index 3f49866b3..b86ec0b6d 100644 --- a/internal/inspect/inspect.go +++ b/internal/inspect/inspect.go @@ -77,7 +77,7 @@ func NewFromConfig(logger log.Logger, cfg *config.Config) (*Inspector, error) { if err != nil { return nil, err } - ss := state.NewStore(sDB) + ss := state.NewStore(sDB, false) return New(cfg.RPC, bs, ss, sinks, logger), nil } diff --git a/internal/p2p/mocks/connection.go b/internal/p2p/mocks/connection.go index 6c6174117..23c3eb5b2 100644 --- a/internal/p2p/mocks/connection.go +++ b/internal/p2p/mocks/connection.go @@ -206,3 +206,18 @@ func (_m *Connection) TrySendMessage(_a0 p2p.ChannelID, _a1 []byte) (bool, error return r0, r1 } + +type mockConstructorTestingTNewConnection interface { + mock.TestingT + Cleanup(func()) +} + +// NewConnection creates a new instance of Connection. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewConnection(t mockConstructorTestingTNewConnection) *Connection { + mock := &Connection{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/p2p/mocks/peer.go b/internal/p2p/mocks/peer.go index b905c1156..67721be47 100644 --- a/internal/p2p/mocks/peer.go +++ b/internal/p2p/mocks/peer.go @@ -332,3 +332,18 @@ func (_m *Peer) TrySend(_a0 byte, _a1 []byte) bool { func (_m *Peer) Wait() { _m.Called() } + +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 mockConstructorTestingTNewPeer) *Peer { + mock := &Peer{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/p2p/mocks/transport.go b/internal/p2p/mocks/transport.go index 82bd670cb..2cf93e078 100644 --- a/internal/p2p/mocks/transport.go +++ b/internal/p2p/mocks/transport.go @@ -119,3 +119,18 @@ func (_m *Transport) String() string { return r0 } + +type mockConstructorTestingTNewTransport interface { + mock.TestingT + Cleanup(func()) +} + +// NewTransport creates a new instance of Transport. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewTransport(t mockConstructorTestingTNewTransport) *Transport { + mock := &Transport{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/proxy/mocks/app_conn_consensus.go b/internal/proxy/mocks/app_conn_consensus.go index fa93b0931..b9f37301c 100644 --- a/internal/proxy/mocks/app_conn_consensus.go +++ b/internal/proxy/mocks/app_conn_consensus.go @@ -150,3 +150,18 @@ func (_m *AppConnConsensus) InitChainSync(_a0 context.Context, _a1 types.Request func (_m *AppConnConsensus) SetResponseCallback(_a0 abciclient.Callback) { _m.Called(_a0) } + +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 mockConstructorTestingTNewAppConnConsensus) *AppConnConsensus { + mock := &AppConnConsensus{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/proxy/mocks/app_conn_mempool.go b/internal/proxy/mocks/app_conn_mempool.go index 5429d8f90..6d62194fc 100644 --- a/internal/proxy/mocks/app_conn_mempool.go +++ b/internal/proxy/mocks/app_conn_mempool.go @@ -118,3 +118,18 @@ func (_m *AppConnMempool) FlushSync(_a0 context.Context) error { func (_m *AppConnMempool) SetResponseCallback(_a0 abciclient.Callback) { _m.Called(_a0) } + +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 mockConstructorTestingTNewAppConnMempool) *AppConnMempool { + mock := &AppConnMempool{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/proxy/mocks/app_conn_query.go b/internal/proxy/mocks/app_conn_query.go index 47ac5bef9..b73be9c0b 100644 --- a/internal/proxy/mocks/app_conn_query.go +++ b/internal/proxy/mocks/app_conn_query.go @@ -97,3 +97,18 @@ func (_m *AppConnQuery) QuerySync(_a0 context.Context, _a1 types.RequestQuery) ( return r0, r1 } + +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 mockConstructorTestingTNewAppConnQuery) *AppConnQuery { + mock := &AppConnQuery{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/proxy/mocks/app_conn_snapshot.go b/internal/proxy/mocks/app_conn_snapshot.go index 0b6f10ce1..d7469c44d 100644 --- a/internal/proxy/mocks/app_conn_snapshot.go +++ b/internal/proxy/mocks/app_conn_snapshot.go @@ -120,3 +120,18 @@ func (_m *AppConnSnapshot) OfferSnapshotSync(_a0 context.Context, _a1 types.Requ return r0, r1 } + +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 mockConstructorTestingTNewAppConnSnapshot) *AppConnSnapshot { + mock := &AppConnSnapshot{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/rpc/core/blocks_test.go b/internal/rpc/core/blocks_test.go index 213845bf4..74272d9b2 100644 --- a/internal/rpc/core/blocks_test.go +++ b/internal/rpc/core/blocks_test.go @@ -81,7 +81,7 @@ func TestBlockResults(t *testing.T) { } env := &Environment{} - env.StateStore = sm.NewStore(dbm.NewMemDB()) + env.StateStore = sm.NewStore(dbm.NewMemDB(), false) err := env.StateStore.SaveABCIResponses(100, results) require.NoError(t, err) mockstore := &mocks.BlockStore{} diff --git a/internal/state/indexer/mocks/event_sink.go b/internal/state/indexer/mocks/event_sink.go index 98b32e935..984d8414d 100644 --- a/internal/state/indexer/mocks/event_sink.go +++ b/internal/state/indexer/mocks/event_sink.go @@ -165,3 +165,18 @@ func (_m *EventSink) Type() indexer.EventSinkType { return r0 } + +type mockConstructorTestingTNewEventSink interface { + mock.TestingT + Cleanup(func()) +} + +// NewEventSink creates a new instance of EventSink. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewEventSink(t mockConstructorTestingTNewEventSink) *EventSink { + mock := &EventSink{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/state/mocks/block_store.go b/internal/state/mocks/block_store.go index 563183437..23532da75 100644 --- a/internal/state/mocks/block_store.go +++ b/internal/state/mocks/block_store.go @@ -208,3 +208,18 @@ func (_m *BlockStore) Size() int64 { return r0 } + +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 mockConstructorTestingTNewBlockStore) *BlockStore { + mock := &BlockStore{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/state/mocks/evidence_pool.go b/internal/state/mocks/evidence_pool.go index 8bf4a9b64..9a21c73ce 100644 --- a/internal/state/mocks/evidence_pool.go +++ b/internal/state/mocks/evidence_pool.go @@ -68,3 +68,18 @@ func (_m *EvidencePool) PendingEvidence(maxBytes int64) ([]types.Evidence, int64 func (_m *EvidencePool) Update(_a0 state.State, _a1 types.EvidenceList) { _m.Called(_a0, _a1) } + +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 mockConstructorTestingTNewEvidencePool) *EvidencePool { + mock := &EvidencePool{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/state/mocks/store.go b/internal/state/mocks/store.go index 02c69d3e0..ecb665585 100644 --- a/internal/state/mocks/store.go +++ b/internal/state/mocks/store.go @@ -108,6 +108,29 @@ func (_m *Store) LoadConsensusParams(_a0 int64) (types.ConsensusParams, 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) (*types.ValidatorSet, error) { ret := _m.Called(_a0) @@ -186,3 +209,18 @@ func (_m *Store) SaveValidatorSets(_a0 int64, _a1 int64, _a2 *types.ValidatorSet return r0 } + +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 mockConstructorTestingTNewStore) *Store { + mock := &Store{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/state/store.go b/internal/state/store.go index eb2408660..9f62c95d2 100644 --- a/internal/state/store.go +++ b/internal/state/store.go @@ -472,12 +472,12 @@ func (store dbStore) LoadLastABCIResponse(height int64) (*tmstate.ABCIResponses, changed: %v\n`, err)) } - //Here we sanitise by comparing the height from the height that is given to the last ABCIResponse + //Here we sanitize by comparing the height from the height that is given to the last ABCIResponse if height != abciResponse.GetHeight() { return nil, errors.New("expected height %d but last stored abci responses was at height %d") - } else { - return abciResponse.AbciResponses, nil } + + return abciResponse.AbciResponses, nil } // SaveABCIResponses persists the ABCIResponses to the database. @@ -512,8 +512,8 @@ func (store dbStore) SaveABCIResponses(height int64, abciResponses *tmstate.ABCI // We always save the last ABCI response incase we crash after app.Commit and before s.Save(.) // This overwrites the previous saved ABCI Response response := &tmstate.ABCIResponsesInfo{ - abciResponses, - height, + AbciResponses: abciResponses, + Height: height, } bz, err := response.Marshal() if err != nil { diff --git a/internal/state/store_test.go b/internal/state/store_test.go index 8f45c64f6..99fd54820 100644 --- a/internal/state/store_test.go +++ b/internal/state/store_test.go @@ -311,6 +311,7 @@ func TestLastABCIResponses(t *testing.T) { stateDB := dbm.NewMemDB() stateStore := sm.NewStore(stateDB, false) responses, err := stateStore.LoadABCIResponses(1) + require.NoError(t, err) require.Nil(t, responses) fmt.Println(responses) diff --git a/internal/statesync/mocks/state_provider.go b/internal/statesync/mocks/state_provider.go index b8d681631..099588ed1 100644 --- a/internal/statesync/mocks/state_provider.go +++ b/internal/statesync/mocks/state_provider.go @@ -82,3 +82,18 @@ func (_m *StateProvider) State(ctx context.Context, height uint64) (state.State, return r0, r1 } + +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 mockConstructorTestingTNewStateProvider) *StateProvider { + mock := &StateProvider{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/light/provider/mocks/provider.go b/light/provider/mocks/provider.go index aa36fa2d3..a17bc4cb5 100644 --- a/light/provider/mocks/provider.go +++ b/light/provider/mocks/provider.go @@ -51,3 +51,18 @@ func (_m *Provider) ReportEvidence(_a0 context.Context, _a1 types.Evidence) erro return r0 } + +type mockConstructorTestingTNewProvider interface { + mock.TestingT + Cleanup(func()) +} + +// NewProvider creates a new instance of Provider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewProvider(t mockConstructorTestingTNewProvider) *Provider { + mock := &Provider{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/light/rpc/mocks/light_client.go b/light/rpc/mocks/light_client.go index cc32cf649..fabf73b01 100644 --- a/light/rpc/mocks/light_client.go +++ b/light/rpc/mocks/light_client.go @@ -99,3 +99,18 @@ func (_m *LightClient) VerifyLightBlockAtHeight(ctx context.Context, height int6 return r0, r1 } + +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 mockConstructorTestingTNewLightClient) *LightClient { + mock := &LightClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/rpc/client/mocks/client.go b/rpc/client/mocks/client.go index 0a83ef201..2b5ff2670 100644 --- a/rpc/client/mocks/client.go +++ b/rpc/client/mocks/client.go @@ -800,3 +800,18 @@ func (_m *Client) Validators(ctx context.Context, height *int64, page *int, perP return r0, r1 } + +type mockConstructorTestingTNewClient interface { + mock.TestingT + Cleanup(func()) +} + +// NewClient creates a new instance of Client. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewClient(t mockConstructorTestingTNewClient) *Client { + mock := &Client{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/test/e2e/generator/generate.go b/test/e2e/generator/generate.go index 4a17ddf3a..02299cae8 100644 --- a/test/e2e/generator/generate.go +++ b/test/e2e/generator/generate.go @@ -186,7 +186,7 @@ func generateTestnet(r *rand.Rand, opt map[string]interface{}) (e2e.Manifest, er numValidators = 4 case "large": // FIXME Networks are kept small since large ones use too much CPU. - numSeeds = r.Intn(1) + numSeeds = r.Intn(2) numLightClients = r.Intn(2) numValidators = 4 + r.Intn(4) numFulls = r.Intn(4)