Disable block timeouts in E2E test network #19

Merged
ashwin merged 5 commits from pm-variable-timeout into main 2024-03-12 04:35:21 +00:00
4 changed files with 13 additions and 33 deletions

View File

@ -110,6 +110,9 @@ func (ets *E2ETestSuite) createAuctionAndBid(createAuction, createBid bool) stri
resp, err := ets.executeTx(cli.GetCmdCreateAuction(), auctionArgs, ownerAccount)
sr.NoError(err)
sr.Zero(resp.Code)
err = ets.network.WaitForNextBlock()
sr.NoError(err)
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cli.GetCmdList(), queryJSONFlag)
sr.NoError(err)
var queryResponse types.QueryAuctionsResponse

View File

@ -149,7 +149,7 @@ func (ets *E2ETestSuite) reserveName(authorityName string) {
cmd := cli.GetCmdReserveAuthority()
args := []string{
authorityName,
fmt.Sprintf("--owner=%s", ets.accountAddress),
ets.accountAddress,
fmt.Sprintf("--%s=%s", flags.FlagFrom, ets.accountName),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=json", flags.FlagOutput),
@ -177,7 +177,7 @@ func (ets *E2ETestSuite) createNameRecord(authorityName string) {
cmd := cli.GetCmdReserveAuthority()
args := []string{
authorityName,
fmt.Sprintf("--owner=%s", ets.accountAddress),
ets.accountAddress,
fmt.Sprintf("--%s=%s", flags.FlagFrom, ets.accountName),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=json", flags.FlagOutput),

View File

@ -676,8 +676,6 @@ func (n *Network) LatestHeight() (int64, error) {
for {
select {
case <-timeout.C:
return latestHeight, errors.New("timeout exceeded waiting for block")
case <-ticker.C:
done := make(chan struct{})
go func() {
@ -695,26 +693,17 @@ func (n *Network) LatestHeight() (int64, error) {
return latestHeight, nil
}
}
default: //nolint: all
}
}
}
// 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,
// an error is returned. Regardless, the latest height queried is returned.
// committed after a given block.
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)
defer ticker.Stop()
timeout := time.NewTimer(t)
defer timeout.Stop()
if len(n.Validators) == 0 {
return 0, errors.New("no validators available")
}
@ -725,8 +714,6 @@ func (n *Network) WaitForHeightWithTimeout(h int64, t time.Duration) (int64, err
for {
select {
case <-timeout.C:
return latestHeight, errors.New("timeout exceeded waiting for block")
case <-ticker.C:
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
}
}
default: //nolint: all
}
}
}

View File

@ -88,27 +88,16 @@ func GetPayloadFromFile(filePath string) (*registrytypes.ReadablePayload, error)
// GetCmdReserveAuthority is the CLI command for reserving a name.
func GetCmdReserveAuthority() *cobra.Command {
cmd := &cobra.Command{
Use: "reserve-name [name]",
Short: "Reserve name.",
Long: strings.TrimSpace(
fmt.Sprintf(`Reserver name with owner address .
Example:
$ %s tx %s reserve-name [name] --owner [ownerAddress]
`,
version.AppName, registrytypes.ModuleName,
),
),
Args: cobra.ExactArgs(1),
Use: "reserve-authority [name]",
Short: "Reserve authority name",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
owner, err := cmd.Flags().GetString("owner")
if err != nil {
return err
}
ownerAddress, err := sdk.AccAddressFromBech32(owner)
ownerAddress, err := sdk.AccAddressFromBech32(args[1])
if err != nil {
return err
}