Disable block timeouts in E2E test network #19
@ -15,6 +15,7 @@ import (
|
|||||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
|
||||||
|
"git.vdb.to/cerc-io/laconic2d/tests/e2e"
|
||||||
"git.vdb.to/cerc-io/laconic2d/testutil/network"
|
"git.vdb.to/cerc-io/laconic2d/testutil/network"
|
||||||
types "git.vdb.to/cerc-io/laconic2d/x/auction"
|
types "git.vdb.to/cerc-io/laconic2d/x/auction"
|
||||||
"git.vdb.to/cerc-io/laconic2d/x/auction/client/cli"
|
"git.vdb.to/cerc-io/laconic2d/x/auction/client/cli"
|
||||||
@ -49,7 +50,7 @@ func (ets *E2ETestSuite) SetupSuite() { //nolint: all
|
|||||||
ets.network, err = network.New(ets.T(), ets.T().TempDir(), ets.cfg)
|
ets.network, err = network.New(ets.T(), ets.T().TempDir(), ets.cfg)
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
|
|
||||||
_, err = ets.network.WaitForHeight(1)
|
_, err = ets.network.WaitForHeight(1, e2e.TenSeconds)
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
|
|
||||||
// setting up random owner and bidder accounts
|
// setting up random owner and bidder accounts
|
||||||
@ -90,7 +91,7 @@ func (ets *E2ETestSuite) createAccountWithBalance(accountName string, accountAdd
|
|||||||
*accountAddress = newAddr.String()
|
*accountAddress = newAddr.String()
|
||||||
|
|
||||||
// wait for tx to take effect
|
// wait for tx to take effect
|
||||||
err = ets.network.WaitForNextBlock()
|
err = ets.network.WaitForNextBlock(e2e.TenSeconds)
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"git.vdb.to/cerc-io/laconic2d/tests/e2e"
|
||||||
auctiontypes "git.vdb.to/cerc-io/laconic2d/x/auction"
|
auctiontypes "git.vdb.to/cerc-io/laconic2d/x/auction"
|
||||||
"git.vdb.to/cerc-io/laconic2d/x/auction/client/cli"
|
"git.vdb.to/cerc-io/laconic2d/x/auction/client/cli"
|
||||||
)
|
)
|
||||||
@ -96,7 +97,7 @@ func (ets *E2ETestSuite) executeTx(cmd *cobra.Command, args []string, caller str
|
|||||||
return sdk.TxResponse{}, err
|
return sdk.TxResponse{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ets.network.WaitForNextBlock()
|
err = ets.network.WaitForNextBlock(e2e.TenSeconds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sdk.TxResponse{}, err
|
return sdk.TxResponse{}, err
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
|
||||||
|
"git.vdb.to/cerc-io/laconic2d/tests/e2e"
|
||||||
"git.vdb.to/cerc-io/laconic2d/testutil/network"
|
"git.vdb.to/cerc-io/laconic2d/testutil/network"
|
||||||
bondtypes "git.vdb.to/cerc-io/laconic2d/x/bond"
|
bondtypes "git.vdb.to/cerc-io/laconic2d/x/bond"
|
||||||
"git.vdb.to/cerc-io/laconic2d/x/bond/client/cli"
|
"git.vdb.to/cerc-io/laconic2d/x/bond/client/cli"
|
||||||
@ -41,7 +42,7 @@ func (ets *E2ETestSuite) SetupSuite() { //nolint: all
|
|||||||
ets.network, err = network.New(ets.T(), ets.T().TempDir(), ets.cfg)
|
ets.network, err = network.New(ets.T(), ets.T().TempDir(), ets.cfg)
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
|
|
||||||
_, err = ets.network.WaitForHeight(1)
|
_, err = ets.network.WaitForHeight(1, e2e.TenSeconds)
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
|
|
||||||
// setting up random account
|
// setting up random account
|
||||||
@ -78,7 +79,7 @@ func (ets *E2ETestSuite) createAccountWithBalance(accountName string, accountAdd
|
|||||||
*accountAddress = newAddr.String()
|
*accountAddress = newAddr.String()
|
||||||
|
|
||||||
// wait for tx to take effect
|
// wait for tx to take effect
|
||||||
err = ets.network.WaitForNextBlock()
|
err = ets.network.WaitForNextBlock(e2e.TenSeconds)
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +103,7 @@ func (ets *E2ETestSuite) createBond() string {
|
|||||||
sr.Zero(d.Code)
|
sr.Zero(d.Code)
|
||||||
|
|
||||||
// wait for tx to take effect
|
// wait for tx to take effect
|
||||||
err = ets.network.WaitForNextBlock()
|
err = ets.network.WaitForNextBlock(e2e.TenSeconds)
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
|
|
||||||
// getting the bonds list and returning the bond-id
|
// getting the bonds list and returning the bond-id
|
||||||
|
@ -3,6 +3,7 @@ package e2e
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"cosmossdk.io/log"
|
"cosmossdk.io/log"
|
||||||
pruningtypes "cosmossdk.io/store/pruning/types"
|
pruningtypes "cosmossdk.io/store/pruning/types"
|
||||||
@ -25,6 +26,10 @@ import (
|
|||||||
"git.vdb.to/cerc-io/laconic2d/testutil/network"
|
"git.vdb.to/cerc-io/laconic2d/testutil/network"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
TenSeconds = 10 * time.Second
|
||||||
|
)
|
||||||
|
|
||||||
// NewTestNetworkFixture returns a new LaconicApp AppConstructor for network simulation tests
|
// NewTestNetworkFixture returns a new LaconicApp AppConstructor for network simulation tests
|
||||||
func NewTestNetworkFixture() network.TestFixture {
|
func NewTestNetworkFixture() network.TestFixture {
|
||||||
dir, err := os.MkdirTemp("", "laconic")
|
dir, err := os.MkdirTemp("", "laconic")
|
||||||
|
@ -15,6 +15,7 @@ import (
|
|||||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
|
||||||
|
"git.vdb.to/cerc-io/laconic2d/tests/e2e"
|
||||||
"git.vdb.to/cerc-io/laconic2d/testutil/network"
|
"git.vdb.to/cerc-io/laconic2d/testutil/network"
|
||||||
bondtypes "git.vdb.to/cerc-io/laconic2d/x/bond"
|
bondtypes "git.vdb.to/cerc-io/laconic2d/x/bond"
|
||||||
bondcli "git.vdb.to/cerc-io/laconic2d/x/bond/client/cli"
|
bondcli "git.vdb.to/cerc-io/laconic2d/x/bond/client/cli"
|
||||||
@ -58,7 +59,7 @@ func (ets *E2ETestSuite) SetupSuite() {
|
|||||||
ets.network, err = network.New(ets.T(), ets.T().TempDir(), ets.cfg)
|
ets.network, err = network.New(ets.T(), ets.T().TempDir(), ets.cfg)
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
|
|
||||||
_, err = ets.network.WaitForHeight(2)
|
_, err = ets.network.WaitForHeight(2, 2*e2e.TenSeconds)
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
|
|
||||||
// setting up random account
|
// setting up random account
|
||||||
@ -97,7 +98,7 @@ func (ets *E2ETestSuite) createAccountWithBalance(accountName string, accountAdd
|
|||||||
*accountAddress = newAddr.String()
|
*accountAddress = newAddr.String()
|
||||||
|
|
||||||
// wait for tx to take effect
|
// wait for tx to take effect
|
||||||
err = ets.network.WaitForNextBlock()
|
err = ets.network.WaitForNextBlock(e2e.TenSeconds)
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +122,7 @@ func (ets *E2ETestSuite) createBond() string {
|
|||||||
sr.Zero(d.Code)
|
sr.Zero(d.Code)
|
||||||
|
|
||||||
// wait for tx to take effect
|
// wait for tx to take effect
|
||||||
err = ets.network.WaitForNextBlock()
|
err = ets.network.WaitForNextBlock(e2e.TenSeconds)
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
|
|
||||||
// getting the bonds list and returning the bond-id
|
// getting the bonds list and returning the bond-id
|
||||||
@ -164,7 +165,7 @@ func (ets *E2ETestSuite) reserveName(authorityName string) {
|
|||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
sr.Zero(d.Code)
|
sr.Zero(d.Code)
|
||||||
|
|
||||||
err = ets.network.WaitForNextBlock()
|
err = ets.network.WaitForNextBlock(e2e.TenSeconds)
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +192,7 @@ func (ets *E2ETestSuite) createNameRecord(authorityName string) {
|
|||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
sr.Zero(d.Code)
|
sr.Zero(d.Code)
|
||||||
|
|
||||||
err = ets.network.WaitForNextBlock()
|
err = ets.network.WaitForNextBlock(e2e.TenSeconds)
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
|
|
||||||
// Get the bond-id
|
// Get the bond-id
|
||||||
@ -214,7 +215,7 @@ func (ets *E2ETestSuite) createNameRecord(authorityName string) {
|
|||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
sr.Zero(d.Code)
|
sr.Zero(d.Code)
|
||||||
|
|
||||||
err = ets.network.WaitForNextBlock()
|
err = ets.network.WaitForNextBlock(e2e.TenSeconds)
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
|
|
||||||
args = []string{
|
args = []string{
|
||||||
@ -235,7 +236,7 @@ func (ets *E2ETestSuite) createNameRecord(authorityName string) {
|
|||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
sr.Zero(d.Code)
|
sr.Zero(d.Code)
|
||||||
|
|
||||||
err = ets.network.WaitForNextBlock()
|
err = ets.network.WaitForNextBlock(e2e.TenSeconds)
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +266,7 @@ func (ets *E2ETestSuite) createRecord(bondId string) {
|
|||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
sr.Zero(d.Code, d.RawLog)
|
sr.Zero(d.Code, d.RawLog)
|
||||||
|
|
||||||
err = ets.network.WaitForNextBlock()
|
err = ets.network.WaitForNextBlock(e2e.TenSeconds)
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -659,7 +659,7 @@ func trapSignal(cleanupFunc func()) {
|
|||||||
|
|
||||||
// LatestHeight returns the latest height of the network or an error if the
|
// LatestHeight returns the latest height of the network or an error if the
|
||||||
// query fails or no validators exist.
|
// query fails or no validators exist.
|
||||||
func (n *Network) LatestHeight() (int64, error) {
|
func (n *Network) LatestHeight(t time.Duration) (int64, error) {
|
||||||
if len(n.Validators) == 0 {
|
if len(n.Validators) == 0 {
|
||||||
return 0, errors.New("no validators available")
|
return 0, errors.New("no validators available")
|
||||||
}
|
}
|
||||||
@ -667,7 +667,7 @@ func (n *Network) LatestHeight() (int64, error) {
|
|||||||
ticker := time.NewTicker(time.Second)
|
ticker := time.NewTicker(time.Second)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
|
||||||
timeout := time.NewTimer(time.Second * 5)
|
timeout := time.NewTimer(t)
|
||||||
defer timeout.Stop()
|
defer timeout.Stop()
|
||||||
|
|
||||||
var latestHeight int64
|
var latestHeight int64
|
||||||
@ -702,8 +702,8 @@ func (n *Network) LatestHeight() (int64, error) {
|
|||||||
// 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. If that height is not reached within a timeout,
|
||||||
// an error is returned. Regardless, the latest height queried is returned.
|
// 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, t time.Duration) (int64, error) {
|
||||||
return n.WaitForHeightWithTimeout(h, 10*time.Second)
|
return n.WaitForHeightWithTimeout(h, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WaitForHeightWithTimeout is the same as WaitForHeight except the caller can
|
// WaitForHeightWithTimeout is the same as WaitForHeight except the caller can
|
||||||
@ -745,7 +745,7 @@ func (n *Network) WaitForHeightWithTimeout(h int64, t time.Duration) (int64, err
|
|||||||
// blocks has been reached.
|
// blocks has been reached.
|
||||||
func (n *Network) RetryForBlocks(retryFunc func() error, blocks int) error {
|
func (n *Network) RetryForBlocks(retryFunc func() error, blocks int) error {
|
||||||
for i := 0; i < blocks; i++ {
|
for i := 0; i < blocks; i++ {
|
||||||
_ = n.WaitForNextBlock()
|
_ = n.WaitForNextBlock(10 * time.Second)
|
||||||
err := retryFunc()
|
err := retryFunc()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return nil
|
return nil
|
||||||
@ -760,13 +760,13 @@ func (n *Network) RetryForBlocks(retryFunc func() error, blocks int) error {
|
|||||||
|
|
||||||
// WaitForNextBlock waits for the next block to be committed, returning an error
|
// WaitForNextBlock waits for the next block to be committed, returning an error
|
||||||
// upon failure.
|
// upon failure.
|
||||||
func (n *Network) WaitForNextBlock() error {
|
func (n *Network) WaitForNextBlock(t time.Duration) error {
|
||||||
lastBlock, err := n.LatestHeight()
|
lastBlock, err := n.LatestHeight(t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = n.WaitForHeight(lastBlock + 1)
|
_, err = n.WaitForHeight(lastBlock+1, t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user