Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
"\\[Error handling\\]",
"\\[Key\\]",
"\\[ICM\\]",
"\\[Local Network\\]",
"\\[Network\\]",
"\\[Blockchain Configure\\]",
"\\[Package Management\\]",
Expand All @@ -31,8 +32,8 @@ jobs:
"\\[Etna AddRemove Validator SOV PoS\\]",
"\\[Etna Add Validator SOV Local\\]",
"\\[Subnet\\]",
"\\[Upgrade expect network failure\\]",
"\\[Upgrade public network\\]",
"\\[Upgrade expect network failure",
"\\[Upgrade public network",
"\\[Upgrade local network\\]",
"\\[Node create\\]",
"\\[Node devnet\\]",
Expand Down Expand Up @@ -82,7 +83,7 @@ jobs:
npm install -g tsx

- name: Install Docker on MacOS
if: ${{ (matrix.os == 'macos-14') && (matrix.suite == '\\[Public Subnet non SOV\\]') }}
if: ${{ (matrix.os == 'macos-14') && (matrix.suite == '\[Public Subnet non SOV\]') }}
run: |
brew install docker
brew install colima
Expand Down
55 changes: 32 additions & 23 deletions pkg/application/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"net/http"
"os"
"strings"
"time"

"github.com/ava-labs/avalanche-cli/pkg/constants"
"github.com/ava-labs/avalanche-cli/pkg/utils"
Expand Down Expand Up @@ -46,17 +47,14 @@ func NewDownloader() Downloader {
return &downloader{}
}

func (downloader) Download(url string) ([]byte, error) {
resp, err := http.Get(url)
func (d downloader) Download(url string) ([]byte, error) {
token := os.Getenv(constants.GithubAPITokenEnvVarName)
body, err := d.doAPIRequest(url, token)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("unexpected http status code: %d", resp.StatusCode)
}

return io.ReadAll(resp.Body)
defer body.Close()
return io.ReadAll(body)
}

// GetLatestPreReleaseVersion returns the latest available pre release or release version from github
Expand Down Expand Up @@ -148,22 +146,33 @@ func (d downloader) GetAllReleasesForRepo(org, repo, component string, kind Rele
}

func (downloader) doAPIRequest(url, token string) (io.ReadCloser, error) {
request, err := http.NewRequest("GET", url, nil)
if err != nil {
return nil, fmt.Errorf("failed to create request for %s: %w", url, err)
}
if token != "" {
// avoid rate limitation issues at CI
request.Header.Set("authorization", fmt.Sprintf("Bearer %s", token))
}
resp, err := http.DefaultClient.Do(request)
if err != nil {
return nil, fmt.Errorf("failed doing request to %s: %w", url, err)
}
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("failed doing request %s: unexpected http status code: %d", url, resp.StatusCode)
retries := 0
for {
request, err := http.NewRequest("GET", url, nil)
if err != nil {
return nil, fmt.Errorf("failed to create request for %s: %w", url, err)
}
if token != "" {
// avoid rate limitation issues at CI
request.Header.Set("authorization", fmt.Sprintf("Bearer %s", token))
}
resp, err := http.DefaultClient.Do(request)
if err != nil {
return nil, fmt.Errorf("failed doing request to %s: %w", url, err)
}
if resp.StatusCode != http.StatusOK {
if resp.StatusCode == http.StatusTooManyRequests {
if retries <= 5 {
retries++
toSleep := time.Duration(retries) * 10 * time.Second
time.Sleep(toSleep)
continue
}
}
return nil, fmt.Errorf("failed doing request %s: unexpected http status code: %d", url, resp.StatusCode)
}
return resp.Body, nil
}
return resp.Body, nil
}

func (d downloader) getLatestReleaseVersion(org, repo string) (string, error) {
Expand Down
6 changes: 1 addition & 5 deletions pkg/localnet/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,8 @@ func TrackSubnet(
return err
}
ux.Logger.GreenCheckmarkToUser("%s successfully tracking %s", networkModel.Name(), blockchainName)
network, err := GetTmpNetNetwork(networkDir)
if err != nil {
return err
}
if networkModel.Kind == models.Local {
if err := TmpNetSetAlias(network.Nodes, blockchainID.String(), blockchainName, subnetID); err != nil {
if err := TmpNetSetDefaultAliases(ctx, networkDir); err != nil {
return err
}
}
Expand Down
47 changes: 45 additions & 2 deletions tests/e2e/testcases/packageman/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,51 @@ var _ = ginkgo.Describe("[Package Management]", ginkgo.Ordered, func() {
commands.DeleteSubnetConfig(secondSubnetName)
})

ginkgo.It("can deploy multiple subnet-evm versions SOV", func() {
// check subnet-evm install precondition
gomega.Expect(utils.CheckSubnetEVMExists(binaryToVersion[utils.SoloSubnetEVMKey1])).Should(gomega.BeFalse())
gomega.Expect(utils.CheckSubnetEVMExists(binaryToVersion[utils.SoloSubnetEVMKey2])).Should(gomega.BeFalse())

commands.CreateSubnetEvmConfigWithVersionSOV(subnetName, utils.SubnetEvmGenesisPoaPath, binaryToVersion[utils.SoloSubnetEVMKey1])
commands.CreateSubnetEvmConfigWithVersionSOV(secondSubnetName, utils.SubnetEvmGenesisPoaPath, binaryToVersion[utils.SoloSubnetEVMKey2])

deployOutput := commands.DeploySubnetLocallySOV(subnetName)
rpcs1, err := utils.ParseRPCsFromOutput(deployOutput)
if err != nil {
fmt.Println(deployOutput)
}
gomega.Expect(err).Should(gomega.BeNil())
gomega.Expect(rpcs1).Should(gomega.HaveLen(1))

deployOutput = commands.DeploySubnetLocallySOV(secondSubnetName)
rpcs2, err := utils.ParseRPCsFromOutput(deployOutput)
if err != nil {
fmt.Println(deployOutput)
}
gomega.Expect(err).Should(gomega.BeNil())
gomega.Expect(rpcs2).Should(gomega.HaveLen(1))

err = utils.SetHardhatRPC(rpcs1[0])
gomega.Expect(err).Should(gomega.BeNil())

err = utils.RunHardhatTests(utils.BaseTest)
gomega.Expect(err).Should(gomega.BeNil())

err = utils.SetHardhatRPC(rpcs2[0])
gomega.Expect(err).Should(gomega.BeNil())

err = utils.RunHardhatTests(utils.BaseTest)
gomega.Expect(err).Should(gomega.BeNil())

// check subnet-evm install
gomega.Expect(utils.CheckSubnetEVMExists(binaryToVersion[utils.SoloSubnetEVMKey1])).Should(gomega.BeTrue())
gomega.Expect(utils.CheckSubnetEVMExists(binaryToVersion[utils.SoloSubnetEVMKey2])).Should(gomega.BeTrue())

commands.DeleteSubnetConfig(subnetName)
commands.DeleteSubnetConfig(secondSubnetName)
})

ginkgo.It("can deploy with multiple avalanchego versions non SOV", func() {
ginkgo.Skip("skipped until two consecutive avago version with dynamic fees are available")
// check avago install precondition
gomega.Expect(utils.CheckAvalancheGoExists(binaryToVersion[utils.MultiAvago1Key])).Should(gomega.BeFalse())
gomega.Expect(utils.CheckAvalancheGoExists(binaryToVersion[utils.MultiAvago2Key])).Should(gomega.BeFalse())
Expand Down Expand Up @@ -205,7 +248,7 @@ var _ = ginkgo.Describe("[Package Management]", ginkgo.Ordered, func() {
})

ginkgo.It("can deploy with multiple avalanchego versions SOV", func() {
ginkgo.Skip("skipped until two consecutive avago version with fortuna support are available")
ginkgo.Skip("this needs two avalanchego compatible at signature aggregation level, which currently is prone to issues")
evmVersion := binaryToVersion[utils.MultiAvagoSubnetEVMKey]
avagoVersion1 := binaryToVersion[utils.MultiAvago1Key]
avagoVersion2 := binaryToVersion[utils.MultiAvago2Key]
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/utils/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
"strconv"
"sync"

"github.com/ava-labs/avalanche-cli/pkg/dependencies"

"github.com/ava-labs/avalanche-cli/pkg/application"
"github.com/ava-labs/avalanche-cli/pkg/binutils"
"github.com/ava-labs/avalanche-cli/pkg/constants"
"github.com/ava-labs/avalanche-cli/pkg/dependencies"
"github.com/ava-labs/avalanche-cli/pkg/models"
"github.com/ava-labs/avalanchego/utils/logging"

"golang.org/x/mod/semver"
)

Expand Down
Loading