From 67cbbf70888413f209da19062b4036b017c3b90b Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 12 Mar 2024 04:35:20 +0000 Subject: [PATCH] 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: https://git.vdb.to/deep-stack/laconic2d/pulls/19 Co-authored-by: Prathamesh Musale Co-committed-by: Prathamesh Musale --- tests/e2e/auction/suite.go | 3 +++ tests/e2e/registry/suite.go | 4 ++-- testutil/network/network.go | 18 +++--------------- x/registry/client/cli/tx.go | 21 +++++---------------- 4 files changed, 13 insertions(+), 33 deletions(-) diff --git a/tests/e2e/auction/suite.go b/tests/e2e/auction/suite.go index 37d2ff10..13a3f19c 100644 --- a/tests/e2e/auction/suite.go +++ b/tests/e2e/auction/suite.go @@ -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 diff --git a/tests/e2e/registry/suite.go b/tests/e2e/registry/suite.go index 3ac4f37c..4d605715 100644 --- a/tests/e2e/registry/suite.go +++ b/tests/e2e/registry/suite.go @@ -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), diff --git a/testutil/network/network.go b/testutil/network/network.go index a401a9b3..ceed27e1 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -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 } } } diff --git a/x/registry/client/cli/tx.go b/x/registry/client/cli/tx.go index f0c63f72..c2d400d9 100644 --- a/x/registry/client/cli/tx.go +++ b/x/registry/client/cli/tx.go @@ -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 }