chore(test): fix lint and refactor test (#20213)

This commit is contained in:
Hoa Nguyen 2024-04-30 18:56:09 +07:00 committed by GitHub
parent 8a36d9d3d0
commit 128bb968b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 17 additions and 17 deletions

View File

@ -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

View File

@ -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)))
})
@ -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()))
})
@ -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

View File

@ -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)))
})
@ -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()))
})

View File

@ -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,
},
@ -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)))
@ -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()))
})
@ -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)))
})

View File

@ -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)))
})
@ -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()))
})

View File

@ -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
}