Skip to content

Commit

Permalink
refactor: use mocks for x/slashing (cosmos#12937)
Browse files Browse the repository at this point in the history
* move integration tests

* add unit testing

* refactor module import

* add hooks test

Co-authored-by: Aleksandr Bezobchuk <[email protected]>
Co-authored-by: Jeancarlo Barrios <[email protected]>
  • Loading branch information
3 people authored Aug 17, 2022
1 parent d5d6e8b commit b515372
Show file tree
Hide file tree
Showing 14 changed files with 1,094 additions and 504 deletions.
1 change: 1 addition & 0 deletions scripts/mockgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ $mockgen_cmd -source=x/auth/ante/expected_keepers.go -package testutil -destinat
$mockgen_cmd -source=x/authz/expected_keepers.go -package testutil -destination x/authz/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=x/bank/types/expected_keepers.go -package testutil -destination x/bank/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=x/evidence/types/expected_keepers.go -package testutil -destination x/evidence/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=x/slashing/types/expected_keepers.go -package testutil -destination x/slashing/testutil/expected_keepers_mocks.go
5 changes: 2 additions & 3 deletions tests/e2e/slashing/client/testutil/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ import (

"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/testutil/network"
clienttestutil "github.com/cosmos/cosmos-sdk/x/slashing/client/testutil"

"github.com/stretchr/testify/suite"
)

func TestIntegrationTestSuite(t *testing.T) {
func TestEndToEndTestSuite(t *testing.T) {
cfg := network.DefaultConfig(simapp.NewTestNetworkFixture)
cfg.NumValidators = 1
suite.Run(t, clienttestutil.NewIntegrationTestSuite(cfg))
suite.Run(t, NewEndToEndTestSuite(cfg))
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/slashing/types"
)

func (s *IntegrationTestSuite) TestGRPCQueries() {
func (s *EndToEndTestSuite) TestGRPCQueries() {
val := s.network.Validators[0]
baseURL := val.APIAddress

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ import (
"github.com/cosmos/cosmos-sdk/x/slashing/client/cli"
)

type IntegrationTestSuite struct {
type EndToEndTestSuite struct {
suite.Suite

cfg network.Config
network *network.Network
}

func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {
return &IntegrationTestSuite{cfg: cfg}
func NewEndToEndTestSuite(cfg network.Config) *EndToEndTestSuite {
return &EndToEndTestSuite{cfg: cfg}
}

// SetupSuite executes bootstrapping logic before all the tests, i.e. once before
// the entire suite, start executing.
func (s *IntegrationTestSuite) SetupSuite() {
func (s *EndToEndTestSuite) SetupSuite() {
s.T().Log("setting up integration test suite")

var err error
Expand All @@ -41,12 +41,12 @@ func (s *IntegrationTestSuite) SetupSuite() {

// TearDownSuite performs cleanup logic after all the tests, i.e. once after the
// entire suite, has finished executing.
func (s *IntegrationTestSuite) TearDownSuite() {
func (s *EndToEndTestSuite) TearDownSuite() {
s.T().Log("tearing down integration test suite")
s.network.Cleanup()
}

func (s *IntegrationTestSuite) TestGetCmdQuerySigningInfo() {
func (s *EndToEndTestSuite) TestGetCmdQuerySigningInfo() {
val := s.network.Validators[0]
pubKeyBz, err := s.cfg.Codec.MarshalInterfaceJSON(val.PubKey)
s.Require().NoError(err)
Expand Down Expand Up @@ -104,7 +104,7 @@ tombstoned: false`, sdk.ConsAddress(val.PubKey.Address())),
}
}

func (s *IntegrationTestSuite) TestGetCmdQueryParams() {
func (s *EndToEndTestSuite) TestGetCmdQueryParams() {
val := s.network.Validators[0]

testCases := []struct {
Expand Down Expand Up @@ -142,7 +142,7 @@ slash_fraction_downtime: "0.010000000000000000"`,
}
}

func (s *IntegrationTestSuite) TestNewUnjailTxCmd() {
func (s *EndToEndTestSuite) TestNewUnjailTxCmd() {
val := s.network.Validators[0]
testCases := []struct {
name string
Expand Down
Loading

0 comments on commit b515372

Please sign in to comment.