Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(code standards): remove calls to suite.SetupTest #1052

Merged
merged 3 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestAnteTestSuite(t *testing.T) {
}

// SetupTest setups a new test, with new app, context, and anteHandler.
func (s *AnteTestSuite) SetupTest(isCheckTx bool) {
func (s *AnteTestSuite) SetupTestCheckTx(isCheckTx bool) {
s.app = apptesting.Setup(s.T(), isCheckTx)
s.ctx = s.app.BaseApp.NewContext(isCheckTx, cometbftproto.Header{}).WithBlockHeight(1).WithChainID(apptesting.TestChainID)

Expand All @@ -72,7 +72,7 @@ func (s *AnteTestSuite) SetupTest(isCheckTx bool) {
}

func (suite *AnteTestSuite) TestCosmosAnteHandlerEip712() {
suite.SetupTest(false)
suite.SetupTestCheckTx(false)
privkey, _ := ethsecp256k1.GenerateKey()
key, err := privkey.ToECDSA()
suite.Require().NoError(err)
Expand Down
4 changes: 2 additions & 2 deletions app/upgrades/v3/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type UpgradeTestSuite struct {
}

// SetupTest initializes the necessary items for each test
func (s *UpgradeTestSuite) SetupTest(t *testing.T) {
func (s *UpgradeTestSuite) SetupTestCustom(t *testing.T) {
s.App = apptesting.Setup(t, false)
s.Ctx = s.App.BaseApp.NewContext(false, cometbftproto.Header{Height: 1, ChainID: "dymension_100-1", Time: time.Now().UTC()})
}
Expand Down Expand Up @@ -115,7 +115,7 @@ func (s *UpgradeTestSuite) TestUpgrade() {

for _, tc := range testCases {
s.Run(fmt.Sprintf("Case %s", tc.msg), func() {
s.SetupTest(s.T()) // Reset for each case
s.SetupTestCustom(s.T()) // Reset for each case

tc.upgrade()
err := tc.postUpgrade()
Expand Down
4 changes: 2 additions & 2 deletions app/upgrades/v4/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type UpgradeTestSuite struct {
}

// SetupTest initializes the necessary items for each test
func (s *UpgradeTestSuite) SetupTest(t *testing.T) {
func (s *UpgradeTestSuite) SetupTestCustom(t *testing.T) {
s.App = apptesting.Setup(t, false)
s.Ctx = s.App.BaseApp.NewContext(false, cometbftproto.Header{Height: 1, ChainID: "dymension_100-1", Time: time.Now().UTC()})
}
Expand Down Expand Up @@ -124,7 +124,7 @@ func (s *UpgradeTestSuite) TestUpgrade() {

for _, tc := range testCases {
s.Run(fmt.Sprintf("Case %s", tc.msg), func() {
s.SetupTest(s.T()) // Reset for each case
s.SetupTestCustom(s.T()) // Reset for each case

err := tc.preUpgrade(tc.numRollapps)
s.Require().NoError(err)
Expand Down
3 changes: 0 additions & 3 deletions x/eibc/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
)

func (suite *KeeperTestSuite) TestParamsQuery() {
suite.SetupTest()
wctx := sdk.WrapSDKContext(suite.Ctx)
params := types.DefaultParams()
suite.App.EIBCKeeper.SetParams(suite.Ctx, params)
Expand All @@ -24,7 +23,6 @@ func (suite *KeeperTestSuite) TestParamsQuery() {
}

func (suite *KeeperTestSuite) TestQueryDemandOrderById() {
suite.SetupTest()
keeper := suite.App.EIBCKeeper

// Validate demand order query with empty request
Expand All @@ -46,7 +44,6 @@ func (suite *KeeperTestSuite) TestQueryDemandOrderById() {
}

func (suite *KeeperTestSuite) TestQueryDemandOrdersByStatus() {
suite.SetupTest()
keeper := suite.App.EIBCKeeper

// Define the number of demand orders and create addresses
Expand Down
16 changes: 0 additions & 16 deletions x/incentives/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ var _ = suite.TestingSuite(nil)

// TestGRPCGaugeByID tests querying gauges via gRPC returns the correct response.
func (suite *KeeperTestSuite) TestGRPCGaugeByID() {
suite.SetupTest()

// create a gauge
gaugeID, _, coins, startTime := suite.SetupNewGauge(false, sdk.Coins{sdk.NewInt64Coin("stake", 10)})

Expand Down Expand Up @@ -49,8 +47,6 @@ func (suite *KeeperTestSuite) TestGRPCGaugeByID() {

// TestGRPCGauges tests querying upcoming and active gauges via gRPC returns the correct response.
func (suite *KeeperTestSuite) TestGRPCGauges() {
suite.SetupTest()

// ensure initially querying gauges returns no gauges
res, err := suite.querier.Gauges(sdk.WrapSDKContext(suite.Ctx), &types.GaugesRequest{})
suite.Require().NoError(err)
Expand Down Expand Up @@ -94,8 +90,6 @@ func (suite *KeeperTestSuite) TestGRPCGauges() {

// TestGRPCActiveGauges tests querying active gauges via gRPC returns the correct response.
func (suite *KeeperTestSuite) TestGRPCActiveGauges() {
suite.SetupTest()

// ensure initially querying active gauges returns no gauges
res, err := suite.querier.ActiveGauges(sdk.WrapSDKContext(suite.Ctx), &types.ActiveGaugesRequest{})
suite.Require().NoError(err)
Expand Down Expand Up @@ -152,8 +146,6 @@ func (suite *KeeperTestSuite) TestGRPCActiveGauges() {

// TestGRPCActiveGaugesPerDenom tests querying active gauges by denom via gRPC returns the correct response.
func (suite *KeeperTestSuite) TestGRPCActiveGaugesPerDenom() {
suite.SetupTest()

// ensure initially querying gauges by denom returns no gauges
res, err := suite.querier.ActiveGaugesPerDenom(sdk.WrapSDKContext(suite.Ctx), &types.ActiveGaugesPerDenomRequest{})
suite.Require().NoError(err)
Expand Down Expand Up @@ -215,8 +207,6 @@ func (suite *KeeperTestSuite) TestGRPCActiveGaugesPerDenom() {

// TestGRPCUpcomingGauges tests querying upcoming gauges via gRPC returns the correct response.
func (suite *KeeperTestSuite) TestGRPCUpcomingGauges() {
suite.SetupTest()

// ensure initially querying upcoming gauges returns no gauges
res, err := suite.querier.UpcomingGauges(sdk.WrapSDKContext(suite.Ctx), &types.UpcomingGaugesRequest{})
suite.Require().NoError(err)
Expand Down Expand Up @@ -271,8 +261,6 @@ func (suite *KeeperTestSuite) TestGRPCUpcomingGauges() {

// TestGRPCUpcomingGaugesPerDenom tests querying upcoming gauges by denom via gRPC returns the correct response.
func (suite *KeeperTestSuite) TestGRPCUpcomingGaugesPerDenom() {
suite.SetupTest()

// ensure initially querying upcoming gauges by denom returns no gauges
upcomingGaugeRequest := types.UpcomingGaugesPerDenomRequest{Denom: "lptoken", Pagination: nil}
res, err := suite.querier.UpcomingGaugesPerDenom(sdk.WrapSDKContext(suite.Ctx), &upcomingGaugeRequest)
Expand Down Expand Up @@ -342,8 +330,6 @@ func (suite *KeeperTestSuite) TestGRPCUpcomingGaugesPerDenom() {

// TestGRPCToDistributeCoins tests querying coins that are going to be distributed via gRPC returns the correct response.
func (suite *KeeperTestSuite) TestGRPCToDistributeCoins() {
suite.SetupTest()

// ensure initially querying to distribute coins returns no coins
res, err := suite.querier.ModuleToDistributeCoins(sdk.WrapSDKContext(suite.Ctx), &types.ModuleToDistributeCoinsRequest{})
suite.Require().NoError(err)
Expand Down Expand Up @@ -407,8 +393,6 @@ func (suite *KeeperTestSuite) TestGRPCToDistributeCoins() {

// TestGRPCDistributedCoins tests querying coins that have been distributed via gRPC returns the correct response.
func (suite *KeeperTestSuite) TestGRPCDistributedCoins() {
suite.SetupTest()

// create two locks with different durations
addr1 := sdk.AccAddress([]byte("addr1---------------"))
addr2 := sdk.AccAddress([]byte("addr2---------------"))
Expand Down
2 changes: 0 additions & 2 deletions x/incentives/keeper/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ func (suite *KeeperTestSuite) TestGaugeReferencesManagement() {
key1 := []byte{0x11}
key2 := []byte{0x12}

suite.SetupTest()

// set two gauge references to key 1 and three gauge references to key 2
_ = suite.App.IncentivesKeeper.AddGaugeRefByKey(suite.Ctx, key1, 1)
_ = suite.App.IncentivesKeeper.AddGaugeRefByKey(suite.Ctx, key2, 1)
Expand Down
81 changes: 47 additions & 34 deletions x/rollapp/keeper/block_height_to_finalization_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ func (suite *RollappTestSuite) TestFinalizeRollapps() {
}, {
rollappId: "rollappa_2345-1",
stateUpdates: []stateUpdate{{
blockHeight: initialHeight, startHeight: 1, numOfBlocks: 10}},
blockHeight: initialHeight, startHeight: 1, numOfBlocks: 10,
}},
},
},
finalizations: []blockEnd{
Expand All @@ -155,7 +156,8 @@ func (suite *RollappTestSuite) TestFinalizeRollapps() {
{
rollappId: "rollapp_1234-1",
stateUpdates: []stateUpdate{{
blockHeight: initialHeight, startHeight: 1, numOfBlocks: 10}},
blockHeight: initialHeight, startHeight: 1, numOfBlocks: 10,
}},
}, {
rollappId: "rollappa_2345-1",
stateUpdates: []stateUpdate{{
Expand All @@ -170,7 +172,8 @@ func (suite *RollappTestSuite) TestFinalizeRollapps() {
rollappsLeft: []rollappQueue{{
rollappId: "rollappa_2345-1",
index: 1,
}}}},
}},
}},
},
},
},
Expand Down Expand Up @@ -216,54 +219,64 @@ func (suite *RollappTestSuite) TestFinalizeRollapps() {
{
// first finalization: 4 states finalized, 3 states left
wantNumFinalized: 4,
wantQueue: []queue{{
rollappsLeft: []rollappQueue{
{
rollappId: "rollappi_4567-1",
index: 1,
}, {
rollappId: "rollappo_5678-1",
index: 1,
}}}, {
rollappsLeft: []rollappQueue{
{
rollappId: "rollappi_4567-1",
index: 2,
wantQueue: []queue{
{
rollappsLeft: []rollappQueue{
{
rollappId: "rollappi_4567-1",
index: 1,
}, {
rollappId: "rollappo_5678-1",
index: 1,
},
},
}},
}, {
rollappsLeft: []rollappQueue{
{
rollappId: "rollappi_4567-1",
index: 2,
},
},
},
},
}, {
// second finalization: 1 state finalized from first finalization, 2 states left
wantNumFinalized: 1,
recovers: map[types.StateInfoIndex]struct{}{
{RollappId: "rollappi_4567-1", Index: 1}: {},
},
wantQueue: []queue{{
rollappsLeft: []rollappQueue{
{
rollappId: "rollappo_5678-1",
index: 1,
}}}, {
rollappsLeft: []rollappQueue{
{
rollappId: "rollappi_4567-1",
index: 2,
wantQueue: []queue{
{
rollappsLeft: []rollappQueue{
{
rollappId: "rollappo_5678-1",
index: 1,
},
},
}},
}, {
rollappsLeft: []rollappQueue{
{
rollappId: "rollappi_4567-1",
index: 2,
},
},
},
},
}, {
// third finalization: 1 state finalized from first finalization, 1 state left
wantNumFinalized: 1,
recovers: map[types.StateInfoIndex]struct{}{
{RollappId: "rollappo_5678-1", Index: 1}: {},
},
wantQueue: []queue{{
rollappsLeft: []rollappQueue{
{
rollappId: "rollappi_4567-1",
index: 2,
wantQueue: []queue{
{
rollappsLeft: []rollappQueue{
{
rollappId: "rollappi_4567-1",
index: 2,
},
},
}},
},
},
}, {
// fourth finalization: 1 state finalized from first finalization, 0 states left
Expand Down
8 changes: 1 addition & 7 deletions x/rollapp/keeper/fraud_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

func (suite *RollappTestSuite) TestHandleFraud() {
var err error
suite.SetupTest()

ctx := &suite.Ctx
keeper := suite.App.RollappKeeper
initialheight := uint64(10)
Expand Down Expand Up @@ -61,7 +61,6 @@ func (suite *RollappTestSuite) TestHandleFraud() {

// Fail - Invalid rollapp
func (suite *RollappTestSuite) TestHandleFraud_InvalidRollapp() {
suite.SetupTest()
ctx := &suite.Ctx
keeper := suite.App.RollappKeeper

Expand All @@ -75,7 +74,6 @@ func (suite *RollappTestSuite) TestHandleFraud_InvalidRollapp() {

// Fail - Wrong height
func (suite *RollappTestSuite) TestHandleFraud_WrongHeight() {
suite.SetupTest()
ctx := &suite.Ctx
keeper := suite.App.RollappKeeper

Expand All @@ -89,7 +87,6 @@ func (suite *RollappTestSuite) TestHandleFraud_WrongHeight() {

// Fail - Wrong sequencer address
func (suite *RollappTestSuite) TestHandleFraud_WrongSequencer() {
suite.SetupTest()
ctx := &suite.Ctx
keeper := suite.App.RollappKeeper

Expand All @@ -103,7 +100,6 @@ func (suite *RollappTestSuite) TestHandleFraud_WrongSequencer() {

// Fail - Wrong channel-ID
func (suite *RollappTestSuite) TestHandleFraud_WrongChannelID() {
suite.SetupTest()
ctx := &suite.Ctx
keeper := suite.App.RollappKeeper

Expand All @@ -117,7 +113,6 @@ func (suite *RollappTestSuite) TestHandleFraud_WrongChannelID() {

// Fail - Disputing already reverted state
func (suite *RollappTestSuite) TestHandleFraud_AlreadyReverted() {
suite.SetupTest()
var err error
ctx := &suite.Ctx
keeper := suite.App.RollappKeeper
Expand Down Expand Up @@ -148,7 +143,6 @@ func (suite *RollappTestSuite) TestHandleFraud_AlreadyReverted() {

// Fail - Disputing already finalized state
func (suite *RollappTestSuite) TestHandleFraud_AlreadyFinalized() {
suite.SetupTest()
ctx := &suite.Ctx
keeper := suite.App.RollappKeeper

Expand Down
2 changes: 0 additions & 2 deletions x/rollapp/keeper/invariants_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
)

func (suite *RollappTestSuite) TestInvariants() {
suite.SetupTest()
initialheight := int64(10)
suite.Ctx = suite.Ctx.WithBlockHeight(initialheight)

Expand Down Expand Up @@ -57,7 +56,6 @@ func (suite *RollappTestSuite) TestInvariants() {
}

func (suite *RollappTestSuite) TestRollappFinalizedStateInvariant() {
suite.SetupTest()
ctx := suite.Ctx
rollapp1, rollapp2, rollapp3 := "rollapp_1234-1", "unrollapp_2345-1", "trollapp_3456-1"
cases := []struct {
Expand Down
2 changes: 0 additions & 2 deletions x/rollapp/keeper/msg_server_transfer_ownership_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ func (suite *RollappTestSuite) TestTransferOwnership() {

for _, tc := range tests {
suite.Run(tc.name, func() {
suite.SetupTest()

rollapp := types.Rollapp{
RollappId: rollappId,
Owner: alice,
Expand Down
4 changes: 0 additions & 4 deletions x/rollapp/keeper/msg_server_update_rollapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ func (suite *RollappTestSuite) TestUpdateRollapp() {

for _, tc := range tests {
suite.Run(tc.name, func() {
suite.SetupTest()

goCtx := sdk.WrapSDKContext(suite.Ctx)
rollapp := types.Rollapp{
RollappId: rollappId,
Expand Down Expand Up @@ -154,8 +152,6 @@ func (suite *RollappTestSuite) TestUpdateRollapp() {
}

func (suite *RollappTestSuite) TestCreateAndUpdateRollapp() {
suite.SetupTest()

const rollappId = "rollapp_1234-1"

// 1. register rollapp
Expand Down
Loading
Loading