refactor: remove suite from chaindecorator handler test #14173

This commit is contained in:
Marko 2022-12-06 16:24:23 +00:00 committed by GitHub
parent 14c9dc6b7f
commit fa6e679492
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,34 +4,22 @@ import (
"testing"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/suite"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/testutil/mock"
sdk "github.com/cosmos/cosmos-sdk/types"
)
type handlerTestSuite struct {
suite.Suite
}
func TestHandlerTestSuite(t *testing.T) {
suite.Run(t, new(handlerTestSuite))
}
func (s *handlerTestSuite) SetupSuite() {
s.T().Parallel()
}
func (s *handlerTestSuite) TestChainAnteDecorators() {
func TestChainAnteDecorators(t *testing.T) {
// test panic
s.Require().Nil(sdk.ChainAnteDecorators([]sdk.AnteDecorator{}...))
require.Nil(t, sdk.ChainAnteDecorators([]sdk.AnteDecorator{}...))
ctx, tx := sdk.Context{}, sdk.Tx(nil)
mockCtrl := gomock.NewController(s.T())
mockCtrl := gomock.NewController(t)
mockAnteDecorator1 := mock.NewMockAnteDecorator(mockCtrl)
mockAnteDecorator1.EXPECT().AnteHandle(gomock.Eq(ctx), gomock.Eq(tx), true, gomock.Any()).Times(1)
_, err := sdk.ChainAnteDecorators(mockAnteDecorator1)(ctx, tx, true)
s.Require().NoError(err)
require.NoError(t, err)
mockAnteDecorator2 := mock.NewMockAnteDecorator(mockCtrl)
// NOTE: we can't check that mockAnteDecorator2 is passed as the last argument because
@ -43,5 +31,5 @@ func (s *handlerTestSuite) TestChainAnteDecorators() {
_, err = sdk.ChainAnteDecorators(
mockAnteDecorator1,
mockAnteDecorator2)(ctx, tx, true)
s.Require().NoError(err)
require.NoError(t, err)
}