Skip to content

E2E Fuji Script #2744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions bootstrap_validators.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"NodeID":"NodeID-GpzpffsNMw23XCrFY55LLfuV1JfF5uZyq","Weight":100,"Balance":100000000,"BLSPublicKey":"0xa150e9289102920d5c5dcb631496f8a5dc524699382d6c1ca14a2b0214ee46376bf94aae16f8e488d7f9b5fcb8a156ea","BLSProofOfPossession":"0xb129d7192da980d89832719277997cdfb04a261065460822e9456f2c33801febb3b8f790c15be99dda00807822a782590f045eaf70676c5ab40664edf6d55bc33d43297eca2258bd5c51e3fb2d5ae6c4abcbfea20d7b67a42c3d2a971196a9fe","ChangeOwnerAddr":"P-fuji1377nx80rx3pzneup5qywgdgdsmzntql7trcqlg","ValidationID":""},{"NodeID":"NodeID-H77h3dVKC7zeVJM7hBpFSNMj48pSq3jRK","Weight":100,"Balance":100000000,"BLSPublicKey":"0x84e80935f121b80efbe17b038b0b41d16def4f4acbf9c97b6168d91601c98bf943f7888e9d53d222552b276e0043cb7f","BLSProofOfPossession":"0xa12beb8fe978e87bd51400508fb1d2e817e4fe85ee919c52a51bbc11a834c476295c266c9dff505d98f24ec52380bfef0e39ff3849ede1b823968f07b70381b55b32ddc748281e19004dc95baab9679724996e959bf4fb60c707a62555c1f3f7","ChangeOwnerAddr":"P-fuji1377nx80rx3pzneup5qywgdgdsmzntql7trcqlg","ValidationID":""}]
6 changes: 4 additions & 2 deletions cmd/blockchaincmd/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ func StartLocalMachine(
availableBalance uint64,
httpPorts []uint,
stakingPorts []uint,
cmd *cobra.Command,
) (bool, error) {
var err error
if network.Kind == models.Local {
Expand All @@ -147,7 +148,7 @@ func StartLocalMachine(
useLocalMachine = true
}
// ask user if we want to use local machine if cluster is not provided
if !useLocalMachine && clusterNameFlagValue == "" {
if !cmd.Flags().Changed("use-local-machine") && !useLocalMachine && clusterNameFlagValue == "" {
ux.Logger.PrintToUser("You can use your local machine as a bootstrap validator on the blockchain")
ux.Logger.PrintToUser("This means that you don't have to to set up a remote server on a cloud service (e.g. AWS / GCP) to be a validator on the blockchain.")

Expand Down Expand Up @@ -538,7 +539,7 @@ func convertSubnetToL1(
}

// convertBlockchain is the cobra command run for converting subnets into sovereign L1
func convertBlockchain(_ *cobra.Command, args []string) error {
func convertBlockchain(cmd *cobra.Command, args []string) error {
blockchainName := args[0]

chains, err := ValidateSubnetNameAndGetChains(args)
Expand Down Expand Up @@ -673,6 +674,7 @@ func convertBlockchain(_ *cobra.Command, args []string) error {
availableBalance,
httpPorts,
stakingPorts,
cmd,
); err != nil {
return err
} else if cancel {
Expand Down
123 changes: 63 additions & 60 deletions cmd/blockchaincmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,73 +581,76 @@ func deployBlockchain(cmd *cobra.Command, args []string) error {
deployBalance := uint64(deployBalanceAVAX * float64(units.Avax))
// whether user has created Avalanche Nodes when blockchain deploy command is called
if sidecar.Sovereign {
if changeOwnerAddress == "" {
// use provided key as change owner unless already set
if pAddr, err := kc.PChainFormattedStrAddresses(); err == nil && len(pAddr) > 0 {
changeOwnerAddress = pAddr[0]
ux.Logger.PrintToUser("Using [%s] to be set as a change owner for leftover AVAX", changeOwnerAddress)
}
}
if !generateNodeID {
if cancel, err := StartLocalMachine(
network,
sidecar,
blockchainName,
deployBalance,
availableBalance,
httpPorts,
stakingPorts,
); err != nil {
return err
} else if cancel {
return nil
}
}
switch {
case len(bootstrapEndpoints) > 0:
if len(bootstrapValidators) == 0 {
if changeOwnerAddress == "" {
changeOwnerAddress, err = blockchain.GetKeyForChangeOwner(app, network)
if err != nil {
return err
// use provided key as change owner unless already set
if pAddr, err := kc.PChainFormattedStrAddresses(); err == nil && len(pAddr) > 0 {
changeOwnerAddress = pAddr[0]
ux.Logger.PrintToUser("Using [%s] to be set as a change owner for leftover AVAX", changeOwnerAddress)
}
}
for _, endpoint := range bootstrapEndpoints {
infoClient := info.NewClient(endpoint)
ctx, cancel := utils.GetAPILargeContext()
defer cancel()
nodeID, proofOfPossession, err := infoClient.GetNodeID(ctx)
if err != nil {
if !generateNodeID {
if cancel, err := StartLocalMachine(
network,
sidecar,
blockchainName,
deployBalance,
availableBalance,
httpPorts,
stakingPorts,
cmd,
); err != nil {
return err
} else if cancel {
return nil
}
publicKey = "0x" + hex.EncodeToString(proofOfPossession.PublicKey[:])
pop = "0x" + hex.EncodeToString(proofOfPossession.ProofOfPossession[:])

bootstrapValidators = append(bootstrapValidators, models.SubnetValidator{
NodeID: nodeID.String(),
Weight: constants.BootstrapValidatorWeight,
Balance: deployBalance,
BLSPublicKey: publicKey,
BLSProofOfPossession: pop,
ChangeOwnerAddr: changeOwnerAddress,
})
}
case clusterNameFlagValue != "":
// for remote clusters we don't need to ask for bootstrap validators and can read it from filesystem
bootstrapValidators, err = getClusterBootstrapValidators(clusterNameFlagValue, network, deployBalance)
if err != nil {
return fmt.Errorf("error getting bootstrap validators from cluster %s: %w", clusterNameFlagValue, err)
}
switch {
case len(bootstrapEndpoints) > 0:
if changeOwnerAddress == "" {
changeOwnerAddress, err = blockchain.GetKeyForChangeOwner(app, network)
if err != nil {
return err
}
}
for _, endpoint := range bootstrapEndpoints {
infoClient := info.NewClient(endpoint)
ctx, cancel := utils.GetAPILargeContext()
defer cancel()
nodeID, proofOfPossession, err := infoClient.GetNodeID(ctx)
if err != nil {
return err
}
publicKey = "0x" + hex.EncodeToString(proofOfPossession.PublicKey[:])
pop = "0x" + hex.EncodeToString(proofOfPossession.ProofOfPossession[:])

bootstrapValidators = append(bootstrapValidators, models.SubnetValidator{
NodeID: nodeID.String(),
Weight: constants.BootstrapValidatorWeight,
Balance: deployBalance,
BLSPublicKey: publicKey,
BLSProofOfPossession: pop,
ChangeOwnerAddr: changeOwnerAddress,
})
}
case clusterNameFlagValue != "":
// for remote clusters we don't need to ask for bootstrap validators and can read it from filesystem
bootstrapValidators, err = getClusterBootstrapValidators(clusterNameFlagValue, network, deployBalance)
if err != nil {
return fmt.Errorf("error getting bootstrap validators from cluster %s: %w", clusterNameFlagValue, err)
}

default:
bootstrapValidators, err = promptBootstrapValidators(
network,
changeOwnerAddress,
numBootstrapValidators,
deployBalance,
availableBalance,
)
if err != nil {
return err
default:
bootstrapValidators, err = promptBootstrapValidators(
network,
changeOwnerAddress,
numBootstrapValidators,
deployBalance,
availableBalance,
)
if err != nil {
return err
}
}
}
} else if network.Kind == models.Local {
Expand Down
61 changes: 61 additions & 0 deletions compatibility_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package main

import (
"testing"

"github.com/ava-labs/avalanche-cli/internal/mocks"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
)

func TestGetLatestCLISupportedDependencyVersion(t *testing.T) {
testCases := []struct {
name string
dependency string
expectedError bool
expectedResult string
}{
{
name: "valid dependency",
dependency: "github.com/example/package",
expectedError: false,
expectedResult: "v1.0.0",
},
{
name: "empty dependency",
dependency: "",
expectedError: true,
expectedResult: "",
},
{
name: "invalid dependency format",
dependency: "invalid/format",
expectedError: true,
expectedResult: "",
},
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
result, err := GetLatestCLISupportedDependencyVersion(tc.dependency)

Check failure on line 40 in compatibility_test.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (ubuntu-24.04)

undefined: GetLatestCLISupportedDependencyVersion

Check failure on line 40 in compatibility_test.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (macos-14)

undefined: GetLatestCLISupportedDependencyVersion

Check failure on line 40 in compatibility_test.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: GetLatestCLISupportedDependencyVersion

if tc.expectedError {
require.Error(t, err)
} else {
require.NoError(t, err)
require.Equal(t, tc.expectedResult, result)
}
})
}
}

func TestDownloader(t *testing.T) {
mockDownloader := &mocks.Downloader{}
mockDownloader.On("Download", mock.MatchedBy(func(url string) bool {
return url == "https://github.com/ava-labs/avalanchego/releases/download/v1.17.1/avalanchego-linux-amd64-v1.17.1.tar.gz"
})).Return(zipBytes1, nil)

Check failure on line 56 in compatibility_test.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (ubuntu-24.04)

undefined: zipBytes1

Check failure on line 56 in compatibility_test.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (macos-14)

undefined: zipBytes1

Check failure on line 56 in compatibility_test.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: zipBytes1

mockDownloader.On("Download", mock.MatchedBy(func(url string) bool {
return url == "https://github.com/ava-labs/avalanchego/releases/download/v1.18.5/avalanchego-macos-v1.18.5.zip"
})).Return(zipBytes2, nil)

Check failure on line 60 in compatibility_test.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (ubuntu-24.04)

undefined: zipBytes2

Check failure on line 60 in compatibility_test.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (macos-14)

undefined: zipBytes2

Check failure on line 60 in compatibility_test.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: zipBytes2 (typecheck)
}
Loading
Loading