fix: increase timers for nameservice tests

This commit is contained in:
nabarun 2022-04-21 00:45:52 +05:30
parent 2ea883bc50
commit 9d4c381e1a
4 changed files with 19 additions and 15 deletions

View File

@ -52,8 +52,8 @@ func (s *IntegrationTestSuite) TestGRPCQueryParams() {
sr.NoError(err) sr.NoError(err)
params := nstypes.DefaultParams() params := nstypes.DefaultParams()
params.RecordRent = sdk.NewCoin(s.cfg.BondDenom, nstypes.DefaultRecordRent) params.RecordRent = sdk.NewCoin(s.cfg.BondDenom, nstypes.DefaultRecordRent)
params.RecordRentDuration = 5 * time.Second params.RecordRentDuration = 10 * time.Second
params.AuthorityGracePeriod = 5 * time.Second params.AuthorityGracePeriod = 10 * time.Second
sr.Equal(response.GetParams().String(), params.String()) sr.Equal(response.GetParams().String(), params.String())
} }
}) })
@ -237,8 +237,8 @@ func (s *IntegrationTestSuite) TestGRPCQueryRecordExpiryQueue() {
if !tc.expectErr { if !tc.expectErr {
tc.preRun(s.bondId) tc.preRun(s.bondId)
} }
// wait 7 seconds for records expires // wait 12 seconds for records expires
time.Sleep(time.Second * 7) time.Sleep(time.Second * 12)
resp, _ := rest.GetRequest(tc.url) resp, _ := rest.GetRequest(tc.url)
require := s.Require() require := s.Require()
if tc.expectErr { if tc.expectErr {
@ -307,8 +307,8 @@ func (s *IntegrationTestSuite) TestGRPCQueryAuthorityExpiryQueue() {
if !tc.expectErr { if !tc.expectErr {
tc.preRun("QueryAuthorityExpiryQueue") tc.preRun("QueryAuthorityExpiryQueue")
} }
// wait 7 seconds to name authorites expires // wait 12 seconds to name authorites expires
time.Sleep(time.Second * 7) time.Sleep(time.Second * 12)
resp, _ := rest.GetRequest(tc.url) resp, _ := rest.GetRequest(tc.url)
require := s.Require() require := s.Require()
@ -318,7 +318,8 @@ func (s *IntegrationTestSuite) TestGRPCQueryAuthorityExpiryQueue() {
var response nstypes.QueryGetAuthorityExpiryQueueResponse var response nstypes.QueryGetAuthorityExpiryQueueResponse
err := val.ClientCtx.Codec.UnmarshalJSON(resp, &response) err := val.ClientCtx.Codec.UnmarshalJSON(resp, &response)
sr.NoError(err) sr.NoError(err)
sr.NotZero(len(response.GetAuthorities())) // removed from expiry queue as no bond set
sr.Zero(len(response.GetAuthorities()))
} }
}) })
} }

View File

@ -40,8 +40,8 @@ func (s *IntegrationTestSuite) TestGetCmdQueryParams() {
sr.NoError(err) sr.NoError(err)
params := types.DefaultParams() params := types.DefaultParams()
params.RecordRent = sdk.NewCoin(s.cfg.BondDenom, types.DefaultRecordRent) params.RecordRent = sdk.NewCoin(s.cfg.BondDenom, types.DefaultRecordRent)
params.RecordRentDuration = 5 * time.Second params.RecordRentDuration = 10 * time.Second
params.AuthorityGracePeriod = 5 * time.Second params.AuthorityGracePeriod = 10 * time.Second
sr.Equal(param.GetParams().String(), params.String()) sr.Equal(param.GetParams().String(), params.String())
}) })
} }
@ -433,7 +433,7 @@ func (s *IntegrationTestSuite) GetRecordExpiryQueue() {
s.Run(tc.name, func() { s.Run(tc.name, func() {
if !tc.expErr { if !tc.expErr {
tc.preRun(authorityName, s) tc.preRun(authorityName, s)
time.Sleep(time.Second * 7) time.Sleep(time.Second * 12)
} }
cmd := cli.GetRecordExpiryQueue() cmd := cli.GetRecordExpiryQueue()
clientCtx := val.ClientCtx clientCtx := val.ClientCtx

View File

@ -47,8 +47,8 @@ func (s *IntegrationTestSuite) SetupSuite() {
s.Require().NoError(s.cfg.Codec.UnmarshalJSON(genesisState[nstypes.ModuleName], &nsData)) s.Require().NoError(s.cfg.Codec.UnmarshalJSON(genesisState[nstypes.ModuleName], &nsData))
nsData.Params.RecordRent = sdk.NewCoin(s.cfg.BondDenom, nstypes.DefaultRecordRent) nsData.Params.RecordRent = sdk.NewCoin(s.cfg.BondDenom, nstypes.DefaultRecordRent)
nsData.Params.RecordRentDuration = 5 * time.Second nsData.Params.RecordRentDuration = 10 * time.Second
nsData.Params.AuthorityGracePeriod = 5 * time.Second nsData.Params.AuthorityGracePeriod = 10 * time.Second
nsDataBz, err := s.cfg.Codec.MarshalJSON(&nsData) nsDataBz, err := s.cfg.Codec.MarshalJSON(&nsData)
s.Require().NoError(err) s.Require().NoError(err)
genesisState[nstypes.ModuleName] = nsDataBz genesisState[nstypes.ModuleName] = nsDataBz

View File

@ -3,9 +3,10 @@ package keeper_test
import ( import (
"context" "context"
"fmt" "fmt"
"os"
"github.com/tharsis/ethermint/x/nameservice/client/cli" "github.com/tharsis/ethermint/x/nameservice/client/cli"
nameservicetypes "github.com/tharsis/ethermint/x/nameservice/types" nameservicetypes "github.com/tharsis/ethermint/x/nameservice/types"
"os"
) )
func (suite *KeeperTestSuite) TestGrpcQueryParams() { func (suite *KeeperTestSuite) TestGrpcQueryParams() {
@ -62,12 +63,13 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
sr.NoError(err) sr.NoError(err)
payload, err := cli.GetPayloadFromFile(dir + "/../helpers/examples/example1.yml") payload, err := cli.GetPayloadFromFile(dir + "/../helpers/examples/example1.yml")
sr.NoError(err) sr.NoError(err)
err = suite.app.NameServiceKeeper.ProcessSetRecord(ctx, nameservicetypes.MsgSetRecord{ record, err := suite.app.NameServiceKeeper.ProcessSetRecord(ctx, nameservicetypes.MsgSetRecord{
BondId: suite.bond.GetId(), BondId: suite.bond.GetId(),
Signer: suite.accounts[0].String(), Signer: suite.accounts[0].String(),
Payload: payload.ToPayload(), Payload: payload.ToPayload(),
}) })
sr.NoError(err) sr.NoError(err)
sr.NotNil(record.Id)
} }
resp, err := grpcClient.ListRecords(context.Background(), test.req) resp, err := grpcClient.ListRecords(context.Background(), test.req)
if test.expErr { if test.expErr {
@ -192,12 +194,13 @@ func (suite *KeeperTestSuite) TestGrpcQueryNameserviceModuleBalance() {
sr.NoError(err) sr.NoError(err)
payload, err := cli.GetPayloadFromFile(dir + "/../helpers/examples/example1.yml") payload, err := cli.GetPayloadFromFile(dir + "/../helpers/examples/example1.yml")
sr.NoError(err) sr.NoError(err)
err = suite.app.NameServiceKeeper.ProcessSetRecord(ctx, nameservicetypes.MsgSetRecord{ record, err := suite.app.NameServiceKeeper.ProcessSetRecord(ctx, nameservicetypes.MsgSetRecord{
BondId: suite.bond.GetId(), BondId: suite.bond.GetId(),
Signer: suite.accounts[0].String(), Signer: suite.accounts[0].String(),
Payload: payload.ToPayload(), Payload: payload.ToPayload(),
}) })
sr.NoError(err) sr.NoError(err)
sr.NotNil(record.Id)
} }
resp, err := grpcClient.GetNameServiceModuleBalance(context.Background(), test.req) resp, err := grpcClient.GetNameServiceModuleBalance(context.Background(), test.req)
if test.expErr { if test.expErr {