Wait for next block after creating an auction and clean up
All checks were successful
Integration Tests / test-integration (pull_request) Successful in 2m52s
Build / build (pull_request) Successful in 3m4s
Lint / Run golangci-lint (pull_request) Successful in 4m57s
Unit Tests / test-unit (pull_request) Successful in 2m4s
E2E Tests / test-e2e (pull_request) Successful in 2m49s
All checks were successful
Integration Tests / test-integration (pull_request) Successful in 2m52s
Build / build (pull_request) Successful in 3m4s
Lint / Run golangci-lint (pull_request) Successful in 4m57s
Unit Tests / test-unit (pull_request) Successful in 2m4s
E2E Tests / test-e2e (pull_request) Successful in 2m49s
This commit is contained in:
parent
8fbf645592
commit
c9b33ca00a
@ -15,7 +15,6 @@ import (
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"git.vdb.to/cerc-io/laconic2d/tests/e2e"
|
||||
"git.vdb.to/cerc-io/laconic2d/testutil/network"
|
||||
types "git.vdb.to/cerc-io/laconic2d/x/auction"
|
||||
"git.vdb.to/cerc-io/laconic2d/x/auction/client/cli"
|
||||
@ -50,7 +49,7 @@ func (ets *E2ETestSuite) SetupSuite() { //nolint: all
|
||||
ets.network, err = network.New(ets.T(), ets.T().TempDir(), ets.cfg)
|
||||
sr.NoError(err)
|
||||
|
||||
_, err = ets.network.WaitForHeight(1, e2e.TenSeconds)
|
||||
_, err = ets.network.WaitForHeight(1)
|
||||
sr.NoError(err)
|
||||
|
||||
// setting up random owner and bidder accounts
|
||||
@ -91,7 +90,7 @@ func (ets *E2ETestSuite) createAccountWithBalance(accountName string, accountAdd
|
||||
*accountAddress = newAddr.String()
|
||||
|
||||
// wait for tx to take effect
|
||||
err = ets.network.WaitForNextBlock(e2e.TenSeconds)
|
||||
err = ets.network.WaitForNextBlock()
|
||||
sr.NoError(err)
|
||||
}
|
||||
|
||||
@ -111,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
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"git.vdb.to/cerc-io/laconic2d/tests/e2e"
|
||||
auctiontypes "git.vdb.to/cerc-io/laconic2d/x/auction"
|
||||
"git.vdb.to/cerc-io/laconic2d/x/auction/client/cli"
|
||||
)
|
||||
@ -97,7 +96,7 @@ func (ets *E2ETestSuite) executeTx(cmd *cobra.Command, args []string, caller str
|
||||
return sdk.TxResponse{}, err
|
||||
}
|
||||
|
||||
err = ets.network.WaitForNextBlock(e2e.TenSeconds)
|
||||
err = ets.network.WaitForNextBlock()
|
||||
if err != nil {
|
||||
return sdk.TxResponse{}, err
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ import (
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"git.vdb.to/cerc-io/laconic2d/tests/e2e"
|
||||
"git.vdb.to/cerc-io/laconic2d/testutil/network"
|
||||
bondtypes "git.vdb.to/cerc-io/laconic2d/x/bond"
|
||||
"git.vdb.to/cerc-io/laconic2d/x/bond/client/cli"
|
||||
@ -42,7 +41,7 @@ func (ets *E2ETestSuite) SetupSuite() { //nolint: all
|
||||
ets.network, err = network.New(ets.T(), ets.T().TempDir(), ets.cfg)
|
||||
sr.NoError(err)
|
||||
|
||||
_, err = ets.network.WaitForHeight(1, e2e.TenSeconds)
|
||||
_, err = ets.network.WaitForHeight(1)
|
||||
sr.NoError(err)
|
||||
|
||||
// setting up random account
|
||||
@ -79,7 +78,7 @@ func (ets *E2ETestSuite) createAccountWithBalance(accountName string, accountAdd
|
||||
*accountAddress = newAddr.String()
|
||||
|
||||
// wait for tx to take effect
|
||||
err = ets.network.WaitForNextBlock(e2e.TenSeconds)
|
||||
err = ets.network.WaitForNextBlock()
|
||||
sr.NoError(err)
|
||||
}
|
||||
|
||||
@ -103,7 +102,7 @@ func (ets *E2ETestSuite) createBond() string {
|
||||
sr.Zero(d.Code)
|
||||
|
||||
// wait for tx to take effect
|
||||
err = ets.network.WaitForNextBlock(e2e.TenSeconds)
|
||||
err = ets.network.WaitForNextBlock()
|
||||
sr.NoError(err)
|
||||
|
||||
// getting the bonds list and returning the bond-id
|
||||
|
@ -15,7 +15,6 @@ import (
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"git.vdb.to/cerc-io/laconic2d/tests/e2e"
|
||||
"git.vdb.to/cerc-io/laconic2d/testutil/network"
|
||||
bondtypes "git.vdb.to/cerc-io/laconic2d/x/bond"
|
||||
bondcli "git.vdb.to/cerc-io/laconic2d/x/bond/client/cli"
|
||||
@ -59,7 +58,7 @@ func (ets *E2ETestSuite) SetupSuite() {
|
||||
ets.network, err = network.New(ets.T(), ets.T().TempDir(), ets.cfg)
|
||||
sr.NoError(err)
|
||||
|
||||
_, err = ets.network.WaitForHeight(2, 2*e2e.TenSeconds)
|
||||
_, err = ets.network.WaitForHeight(2)
|
||||
sr.NoError(err)
|
||||
|
||||
// setting up random account
|
||||
@ -98,7 +97,7 @@ func (ets *E2ETestSuite) createAccountWithBalance(accountName string, accountAdd
|
||||
*accountAddress = newAddr.String()
|
||||
|
||||
// wait for tx to take effect
|
||||
err = ets.network.WaitForNextBlock(e2e.TenSeconds)
|
||||
err = ets.network.WaitForNextBlock()
|
||||
sr.NoError(err)
|
||||
}
|
||||
|
||||
@ -122,7 +121,7 @@ func (ets *E2ETestSuite) createBond() string {
|
||||
sr.Zero(d.Code)
|
||||
|
||||
// wait for tx to take effect
|
||||
err = ets.network.WaitForNextBlock(e2e.TenSeconds)
|
||||
err = ets.network.WaitForNextBlock()
|
||||
sr.NoError(err)
|
||||
|
||||
// getting the bonds list and returning the bond-id
|
||||
@ -165,7 +164,7 @@ func (ets *E2ETestSuite) reserveName(authorityName string) {
|
||||
sr.NoError(err)
|
||||
sr.Zero(d.Code)
|
||||
|
||||
err = ets.network.WaitForNextBlock(e2e.TenSeconds)
|
||||
err = ets.network.WaitForNextBlock()
|
||||
sr.NoError(err)
|
||||
}
|
||||
|
||||
@ -192,7 +191,7 @@ func (ets *E2ETestSuite) createNameRecord(authorityName string) {
|
||||
sr.NoError(err)
|
||||
sr.Zero(d.Code)
|
||||
|
||||
err = ets.network.WaitForNextBlock(e2e.TenSeconds)
|
||||
err = ets.network.WaitForNextBlock()
|
||||
sr.NoError(err)
|
||||
|
||||
// Get the bond-id
|
||||
@ -215,7 +214,7 @@ func (ets *E2ETestSuite) createNameRecord(authorityName string) {
|
||||
sr.NoError(err)
|
||||
sr.Zero(d.Code)
|
||||
|
||||
err = ets.network.WaitForNextBlock(e2e.TenSeconds)
|
||||
err = ets.network.WaitForNextBlock()
|
||||
sr.NoError(err)
|
||||
|
||||
args = []string{
|
||||
@ -236,7 +235,7 @@ func (ets *E2ETestSuite) createNameRecord(authorityName string) {
|
||||
sr.NoError(err)
|
||||
sr.Zero(d.Code)
|
||||
|
||||
err = ets.network.WaitForNextBlock(e2e.TenSeconds)
|
||||
err = ets.network.WaitForNextBlock()
|
||||
sr.NoError(err)
|
||||
}
|
||||
|
||||
@ -266,7 +265,7 @@ func (ets *E2ETestSuite) createRecord(bondId string) {
|
||||
sr.NoError(err)
|
||||
sr.Zero(d.Code, d.RawLog)
|
||||
|
||||
err = ets.network.WaitForNextBlock(e2e.TenSeconds)
|
||||
err = ets.network.WaitForNextBlock()
|
||||
sr.NoError(err)
|
||||
}
|
||||
|
||||
|
@ -659,7 +659,7 @@ func trapSignal(cleanupFunc func()) {
|
||||
|
||||
// LatestHeight returns the latest height of the network or an error if the
|
||||
// query fails or no validators exist.
|
||||
func (n *Network) LatestHeight(t time.Duration) (int64, error) {
|
||||
func (n *Network) LatestHeight() (int64, error) {
|
||||
if len(n.Validators) == 0 {
|
||||
return 0, errors.New("no validators available")
|
||||
}
|
||||
@ -667,7 +667,7 @@ func (n *Network) LatestHeight(t time.Duration) (int64, error) {
|
||||
ticker := time.NewTicker(time.Second)
|
||||
defer ticker.Stop()
|
||||
|
||||
timeout := time.NewTimer(t)
|
||||
timeout := time.NewTimer(time.Second * 5)
|
||||
defer timeout.Stop()
|
||||
|
||||
var latestHeight int64
|
||||
@ -676,8 +676,6 @@ func (n *Network) LatestHeight(t time.Duration) (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() {
|
||||
@ -701,21 +699,11 @@ func (n *Network) LatestHeight(t time.Duration) (int64, error) {
|
||||
}
|
||||
|
||||
// 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.
|
||||
func (n *Network) WaitForHeight(h int64, t time.Duration) (int64, error) {
|
||||
return n.WaitForHeightWithTimeout(h, t)
|
||||
}
|
||||
|
||||
// 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) {
|
||||
// committed after a given block.
|
||||
func (n *Network) WaitForHeight(h int64) (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")
|
||||
}
|
||||
@ -726,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{})
|
||||
@ -747,7 +733,7 @@ func (n *Network) WaitForHeightWithTimeout(h int64, t time.Duration) (int64, err
|
||||
// blocks has been reached.
|
||||
func (n *Network) RetryForBlocks(retryFunc func() error, blocks int) error {
|
||||
for i := 0; i < blocks; i++ {
|
||||
_ = n.WaitForNextBlock(10 * time.Second)
|
||||
_ = n.WaitForNextBlock()
|
||||
err := retryFunc()
|
||||
if err == nil {
|
||||
return nil
|
||||
@ -762,13 +748,13 @@ func (n *Network) RetryForBlocks(retryFunc func() error, blocks int) error {
|
||||
|
||||
// WaitForNextBlock waits for the next block to be committed, returning an error
|
||||
// upon failure.
|
||||
func (n *Network) WaitForNextBlock(t time.Duration) error {
|
||||
lastBlock, err := n.LatestHeight(t)
|
||||
func (n *Network) WaitForNextBlock() error {
|
||||
lastBlock, err := n.LatestHeight()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = n.WaitForHeight(lastBlock+1, t)
|
||||
_, err = n.WaitForHeight(lastBlock + 1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user