Disable block timeouts in E2E test network (#19)
- The E2E tests sometimes fail with error `timeout exceeded waiting for block` in CI (always passed locally) - Update the test network setup to disable timeouts when waiting for blocks Reviewed-on: deep-stack/laconic2d#19 Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
This commit is contained in:
parent
8c0540bdb5
commit
67cbbf7088
@ -110,6 +110,9 @@ func (ets *E2ETestSuite) createAuctionAndBid(createAuction, createBid bool) stri
|
|||||||
resp, err := ets.executeTx(cli.GetCmdCreateAuction(), auctionArgs, ownerAccount)
|
resp, err := ets.executeTx(cli.GetCmdCreateAuction(), auctionArgs, ownerAccount)
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
sr.Zero(resp.Code)
|
sr.Zero(resp.Code)
|
||||||
|
err = ets.network.WaitForNextBlock()
|
||||||
|
sr.NoError(err)
|
||||||
|
|
||||||
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cli.GetCmdList(), queryJSONFlag)
|
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cli.GetCmdList(), queryJSONFlag)
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
var queryResponse types.QueryAuctionsResponse
|
var queryResponse types.QueryAuctionsResponse
|
||||||
|
@ -149,7 +149,7 @@ func (ets *E2ETestSuite) reserveName(authorityName string) {
|
|||||||
cmd := cli.GetCmdReserveAuthority()
|
cmd := cli.GetCmdReserveAuthority()
|
||||||
args := []string{
|
args := []string{
|
||||||
authorityName,
|
authorityName,
|
||||||
fmt.Sprintf("--owner=%s", ets.accountAddress),
|
ets.accountAddress,
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, ets.accountName),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, ets.accountName),
|
||||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||||
@ -177,7 +177,7 @@ func (ets *E2ETestSuite) createNameRecord(authorityName string) {
|
|||||||
cmd := cli.GetCmdReserveAuthority()
|
cmd := cli.GetCmdReserveAuthority()
|
||||||
args := []string{
|
args := []string{
|
||||||
authorityName,
|
authorityName,
|
||||||
fmt.Sprintf("--owner=%s", ets.accountAddress),
|
ets.accountAddress,
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, ets.accountName),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, ets.accountName),
|
||||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||||
|
@ -676,8 +676,6 @@ func (n *Network) LatestHeight() (int64, error) {
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-timeout.C:
|
|
||||||
return latestHeight, errors.New("timeout exceeded waiting for block")
|
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
@ -695,26 +693,17 @@ func (n *Network) LatestHeight() (int64, error) {
|
|||||||
return latestHeight, nil
|
return latestHeight, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
default: //nolint: all
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WaitForHeight performs a blocking check where it waits for a block to be
|
// WaitForHeight performs a blocking check where it waits for a block to be
|
||||||
// committed after a given block. If that height is not reached within a timeout,
|
// committed after a given block.
|
||||||
// an error is returned. Regardless, the latest height queried is returned.
|
|
||||||
func (n *Network) WaitForHeight(h int64) (int64, error) {
|
func (n *Network) WaitForHeight(h int64) (int64, error) {
|
||||||
return n.WaitForHeightWithTimeout(h, 10*time.Second)
|
|
||||||
}
|
|
||||||
|
|
||||||
// WaitForHeightWithTimeout is the same as WaitForHeight except the caller can
|
|
||||||
// provide a custom timeout.
|
|
||||||
func (n *Network) WaitForHeightWithTimeout(h int64, t time.Duration) (int64, error) {
|
|
||||||
ticker := time.NewTicker(time.Second)
|
ticker := time.NewTicker(time.Second)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
|
||||||
timeout := time.NewTimer(t)
|
|
||||||
defer timeout.Stop()
|
|
||||||
|
|
||||||
if len(n.Validators) == 0 {
|
if len(n.Validators) == 0 {
|
||||||
return 0, errors.New("no validators available")
|
return 0, errors.New("no validators available")
|
||||||
}
|
}
|
||||||
@ -725,8 +714,6 @@ func (n *Network) WaitForHeightWithTimeout(h int64, t time.Duration) (int64, err
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-timeout.C:
|
|
||||||
return latestHeight, errors.New("timeout exceeded waiting for block")
|
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
|
|
||||||
res, err := queryClient.GetLatestBlock(context.Background(), &cmtservice.GetLatestBlockRequest{})
|
res, err := queryClient.GetLatestBlock(context.Background(), &cmtservice.GetLatestBlockRequest{})
|
||||||
@ -736,6 +723,7 @@ func (n *Network) WaitForHeightWithTimeout(h int64, t time.Duration) (int64, err
|
|||||||
return latestHeight, nil
|
return latestHeight, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
default: //nolint: all
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,27 +88,16 @@ func GetPayloadFromFile(filePath string) (*registrytypes.ReadablePayload, error)
|
|||||||
// GetCmdReserveAuthority is the CLI command for reserving a name.
|
// GetCmdReserveAuthority is the CLI command for reserving a name.
|
||||||
func GetCmdReserveAuthority() *cobra.Command {
|
func GetCmdReserveAuthority() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "reserve-name [name]",
|
Use: "reserve-authority [name]",
|
||||||
Short: "Reserve name.",
|
Short: "Reserve authority name",
|
||||||
Long: strings.TrimSpace(
|
Args: cobra.ExactArgs(2),
|
||||||
fmt.Sprintf(`Reserver name with owner address .
|
|
||||||
Example:
|
|
||||||
$ %s tx %s reserve-name [name] --owner [ownerAddress]
|
|
||||||
`,
|
|
||||||
version.AppName, registrytypes.ModuleName,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Args: cobra.ExactArgs(1),
|
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
clientCtx, err := client.GetClientTxContext(cmd)
|
clientCtx, err := client.GetClientTxContext(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
owner, err := cmd.Flags().GetString("owner")
|
|
||||||
if err != nil {
|
ownerAddress, err := sdk.AccAddressFromBech32(args[1])
|
||||||
return err
|
|
||||||
}
|
|
||||||
ownerAddress, err := sdk.AccAddressFromBech32(owner)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user