Skip to content

Commit

Permalink
fix timeouts
Browse files Browse the repository at this point in the history
enable image pulling
  • Loading branch information
ramilexe committed May 10, 2023
1 parent 9682243 commit a76763a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
4 changes: 2 additions & 2 deletions chain/avalanche/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ func (n *AvalancheNode) StartSubnets(ctx context.Context) error {

time.Sleep(4 * time.Second)

startTime := time.Now().Add(time.Minute)
startTime := time.Now().Add(20 * time.Second)
duration := 2 * 7 * 24 * time.Hour // 2 weeks
weight := units.Schmeckle
addValidatorStartTime := time.Now()
Expand Down Expand Up @@ -627,7 +627,7 @@ func (n *AvalancheNode) StartSubnets(ctx context.Context) error {
n.options.Subnets[i].subnet = createSubnetTxID
n.options.Subnets[i].chain = createChainTxID

time.Sleep(100 * time.Second)
time.Sleep(30 * time.Second)
}

n.logger.Info("stopping container")
Expand Down
35 changes: 18 additions & 17 deletions chain/avalanche/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package avalanche
import (
"context"
"fmt"
"io"
"net"
"time"

Expand Down Expand Up @@ -64,23 +65,23 @@ func (c *AvalancheChain) Config() ibc.ChainConfig {

// Initialize initializes node structs so that things like initializing keys can be done before starting the chain
func (c *AvalancheChain) Initialize(ctx context.Context, testName string, cli *client.Client, networkID string) error {
//for _, image := range c.Config().Images {
// rc, err := cli.ImagePull(
// ctx,
// image.Repository+":"+image.Version,
// types.ImagePullOptions{},
// )
// if err != nil {
// c.log.Error("Failed to pull image",
// zap.Error(err),
// zap.String("repository", image.Repository),
// zap.String("tag", image.Version),
// )
// } else {
// _, _ = io.Copy(io.Discard, rc)
// _ = rc.Close()
// }
//}
for _, image := range c.Config().Images {
rc, err := cli.ImagePull(
ctx,
image.Repository+":"+image.Version,
types.ImagePullOptions{},
)
if err != nil {
c.log.Error("Failed to pull image",
zap.Error(err),
zap.String("repository", image.Repository),
zap.String("tag", image.Version),
)
} else {
_, _ = io.Copy(io.Discard, rc)
_ = rc.Close()
}
}

rawChainID := c.Config().ChainID
if rawChainID == "" {
Expand Down
12 changes: 10 additions & 2 deletions examples/avalanche/avalanche_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,21 @@ func TestAvalancheChainStart(t *testing.T) {

eg := new(errgroup.Group)
eg.Go(func() error {
return chain.SendFunds(subnetCtx, "56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027", ibc.WalletAmount{
err := chain.SendFunds(subnetCtx, "56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027", ibc.WalletAmount{
Address: "0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC",
Amount: 1000000,
})
if err != nil {
return err
}
return chain.SendFunds(subnetCtx, "56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027", ibc.WalletAmount{
Address: "0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FD",
Amount: 2000000,
})

})
eg.Go(func() error {
return testutil.WaitForBlocks(subnetCtx, 2, chain)
return testutil.WaitForBlocks(subnetCtx, 1, chain)
})

require.NoError(t, eg.Wait(), "avalanche chain failed to make blocks")
Expand Down

0 comments on commit a76763a

Please sign in to comment.