Skip to content

Commit

Permalink
chore(test): fix lint and refactor test (cosmos#20213)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoank101 authored Apr 30, 2024
1 parent 8a36d9d commit 128bb96
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
3 changes: 1 addition & 2 deletions store/snapshots/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,7 @@ func TestStore_Save(t *testing.T) {
assert.Equal(t, []uint64{7, 7}, gotErrHeights)
}

type ReadCloserMock struct {
}
type ReadCloserMock struct{}

func (r ReadCloserMock) Read(p []byte) (n int, err error) {
return len(p), io.EOF
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/accounts/lockup/continous_lockup_test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (s *E2ETestSuite) TestContinuousLockingAccount() {
require.NotNil(t, del)

// check if tracking is updated accordingly
lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr)
lockupAccountInfoResponse := s.queryLockupAccInfo(ctx, app, accountAddr)
delLocking := lockupAccountInfoResponse.DelegatedLocking
require.True(t, delLocking.AmountOf("stake").Equal(math.NewInt(100)))
})
Expand Down Expand Up @@ -164,7 +164,7 @@ func (s *E2ETestSuite) TestContinuousLockingAccount() {
require.Equal(t, len(ubd.Entries), 1)

// check if tracking is updated accordingly
lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr)
lockupAccountInfoResponse := s.queryLockupAccInfo(ctx, app, accountAddr)
delLocking := lockupAccountInfoResponse.DelegatedLocking
require.True(t, delLocking.AmountOf("stake").Equal(math.ZeroInt()))
})
Expand Down Expand Up @@ -194,7 +194,7 @@ func (s *E2ETestSuite) TestContinuousLockingAccount() {
require.NotNil(t, del)

// check if tracking is updated accordingly
lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr)
lockupAccountInfoResponse := s.queryLockupAccInfo(ctx, app, accountAddr)
delLocking := lockupAccountInfoResponse.DelegatedLocking
require.True(t, delLocking.AmountOf("stake").Equal(math.ZeroInt()))
delFree := lockupAccountInfoResponse.DelegatedFree
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/accounts/lockup/delayed_lockup_test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (s *E2ETestSuite) TestDelayedLockingAccount() {
require.NotNil(t, del)

// check if tracking is updated accordingly
lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr)
lockupAccountInfoResponse := s.queryLockupAccInfo(ctx, app, accountAddr)
delLocking := lockupAccountInfoResponse.DelegatedLocking
require.True(t, delLocking.AmountOf("stake").Equal(math.NewInt(100)))
})
Expand Down Expand Up @@ -126,7 +126,7 @@ func (s *E2ETestSuite) TestDelayedLockingAccount() {
require.Equal(t, len(ubd.Entries), 1)

// check if tracking is updated accordingly
lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr)
lockupAccountInfoResponse := s.queryLockupAccInfo(ctx, app, accountAddr)
delLocking := lockupAccountInfoResponse.DelegatedLocking
require.True(t, delLocking.AmountOf("stake").Equal(math.ZeroInt()))
})
Expand Down
9 changes: 5 additions & 4 deletions tests/e2e/accounts/lockup/periodic_lockup_test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ func (s *E2ETestSuite) TestPeriodicLockingAccount() {
{
Amount: sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(500))),
Length: time.Minute,
}, {
},
{
Amount: sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(500))),
Length: time.Minute,
},
Expand Down Expand Up @@ -153,7 +154,7 @@ func (s *E2ETestSuite) TestPeriodicLockingAccount() {
require.NotNil(t, del)

// check if tracking is updated accordingly
lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr)
lockupAccountInfoResponse := s.queryLockupAccInfo(ctx, app, accountAddr)
fmt.Println(lockupAccountInfoResponse)
delLocking := lockupAccountInfoResponse.DelegatedLocking
require.True(t, delLocking.AmountOf("stake").Equal(math.NewInt(100)))
Expand Down Expand Up @@ -187,7 +188,7 @@ func (s *E2ETestSuite) TestPeriodicLockingAccount() {
require.Equal(t, len(ubd.Entries), 1)

// check if tracking is updated accordingly
lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr)
lockupAccountInfoResponse := s.queryLockupAccInfo(ctx, app, accountAddr)
delLocking := lockupAccountInfoResponse.DelegatedLocking
require.True(t, delLocking.AmountOf("stake").Equal(math.ZeroInt()))
})
Expand Down Expand Up @@ -217,7 +218,7 @@ func (s *E2ETestSuite) TestPeriodicLockingAccount() {
require.NotNil(t, del)

// check if tracking is updated accordingly
lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr)
lockupAccountInfoResponse := s.queryLockupAccInfo(ctx, app, accountAddr)
delFree := lockupAccountInfoResponse.DelegatedFree
require.True(t, delFree.AmountOf("stake").Equal(math.NewInt(100)))
})
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/accounts/lockup/permanent_lockup_test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (s *E2ETestSuite) TestPermanentLockingAccount() {
require.NotNil(t, del)

// check if tracking is updated accordingly
lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr)
lockupAccountInfoResponse := s.queryLockupAccInfo(ctx, app, accountAddr)
delLocking := lockupAccountInfoResponse.DelegatedLocking
require.True(t, delLocking.AmountOf("stake").Equal(math.NewInt(100)))
})
Expand Down Expand Up @@ -110,7 +110,7 @@ func (s *E2ETestSuite) TestPermanentLockingAccount() {
require.Equal(t, len(ubd.Entries), 1)

// check if tracking is updated accordingly
lockupAccountInfoResponse := s.queryLockupAccInfo(t, ctx, app, accountAddr)
lockupAccountInfoResponse := s.queryLockupAccInfo(ctx, app, accountAddr)
delLocking := lockupAccountInfoResponse.DelegatedLocking
require.True(t, delLocking.AmountOf("stake").Equal(math.ZeroInt()))
})
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/accounts/lockup/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ func (s *E2ETestSuite) fundAccount(app *simapp.SimApp, ctx sdk.Context, addr sdk
require.NoError(s.T(), testutil.FundAccount(ctx, app.BankKeeper, addr, amt))
}

func (s *E2ETestSuite) queryLockupAccInfo(t *testing.T, ctx sdk.Context, app *simapp.SimApp, accAddr []byte) *types.QueryLockupAccountInfoResponse {
func (s *E2ETestSuite) queryLockupAccInfo(ctx sdk.Context, app *simapp.SimApp, accAddr []byte) *types.QueryLockupAccountInfoResponse {
req := &types.QueryLockupAccountInfoRequest{}
resp, err := s.queryAcc(ctx, req, app, accAddr)
require.NoError(t, err)
require.NotNil(t, resp)
require.NoError(s.T(), err)
require.NotNil(s.T(), resp)

lockupAccountInfoResponse, ok := resp.(*types.QueryLockupAccountInfoResponse)
require.True(t, ok)
require.True(s.T(), ok)

return lockupAccountInfoResponse
}

0 comments on commit 128bb96

Please sign in to comment.