Skip to content
Closed
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 .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
"\\[Node create\\]",
"\\[Node devnet\\]",
"\\[Docker\\]",
"\\[Blockchain Deploy Flags\\]",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure we want to start modifying CI at this stage

]
os: [ubuntu-24.04, macos-14]
exclude:
Expand Down
15 changes: 13 additions & 2 deletions cmd/blockchaincmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@
cmd.Flags().StringVar(&icmSpec.RegistryBydecodePath, "teleporter-registry-bytecode-path", "", "path to an ICM Registry bytecode file")
cmd.Flags().StringVar(&bootstrapValidatorsJSONFilePath, "bootstrap-filepath", "", "JSON file path that provides details about bootstrap validators, leave Node-ID and BLS values empty if using --generate-node-id=true")
cmd.Flags().BoolVar(&generateNodeID, "generate-node-id", false, "whether to create new node id for bootstrap validators (Node-ID and BLS values in bootstrap JSON file will be overridden if --bootstrap-filepath flag is used)")
cmd.Flags().StringSliceVar(&bootstrapEndpoints, "bootstrap-endpoints", nil, "take validator node info from the given endpoints")
cmd.Flags().StringSliceVar(&bootstrapEndpoints, "bootstrap-endpoints", nil, "take validator node info from the given endpoints (not for local network)")
cmd.Flags().BoolVar(&convertOnly, "convert-only", false, "avoid node track, restart and poa manager setup")
cmd.Flags().BoolVar(&useLocalMachine, "use-local-machine", false, "use local machine as a blockchain validator")
cmd.Flags().IntVar(&numBootstrapValidators, "num-bootstrap-validators", 0, "(only if --generate-node-id is true) number of bootstrap validators to set up in sovereign L1 validator)")
cmd.Flags().IntVar(&numBootstrapValidators, "num-bootstrap-validators", 0, "number of bootstrap validators to set up in sovereign L1 validator (only if --generate-node-id is true)")
cmd.Flags().Float64Var(
&deployBalanceAVAX,
"balance",
Expand Down Expand Up @@ -381,6 +381,14 @@
}
return app.UpdateSidecar(sc)
}
func deployLocalNetworkPreCheck(cmd *cobra.Command, network models.Network) error {

Check failure on line 384 in cmd/blockchaincmd/deploy.go

View workflow job for this annotation

GitHub Actions / Lint

File is not properly formatted (gofumpt)
if network.Kind == models.Local {
if cmd.Flags().Changed("use-local-machine") && !useLocalMachine {
return fmt.Errorf("deploying blockchain on local network requires local machine to be used as bootstrap validator")
}
}
return nil
}

// deployBlockchain is the cobra command run for deploying subnets
func deployBlockchain(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -478,6 +486,9 @@
ux.Logger.PrintToUser("Deploying %s to %s", chains, network.Name())

if network.Kind == models.Local {
if err = deployLocalNetworkPreCheck(cmd, network); err != nil {
return err
}
app.Log.Debug("Deploy local")

avagoVersion := userProvidedAvagoVersion
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/commands/etna.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const (
PoAString = "proof-of-authority"
)

func CreateEtnaSubnetEvmConfig(
func CreateSubnetEvmConfigSOV(
subnetName string,
ewoqEVMAddress string,
subnetManagementType SubnetManagementType,
Expand Down
18 changes: 9 additions & 9 deletions tests/e2e/commands/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

const (
subnetEVMMainnetChainID = 11
poaValidatorManagerOwner = "0x2e6FcBb9d4E17eC4cF67eddfa7D32eabC4cdCFc6"
PoaValidatorManagerOwner = "0x2e6FcBb9d4E17eC4cF67eddfa7D32eabC4cdCFc6"
bootstrapFilepathFlag = "--bootstrap-filepath"
avalancheGoPath = "--avalanchego-path"
localNodeClusterName = "testLocalNode"
Expand All @@ -35,12 +35,12 @@ func CreateSubnetEvmConfigNonSOV(subnetName string, genesisPath string) (string,
return mapping[utils.LatestEVM2AvagoKey], mapping[utils.LatestAvago2EVMKey]
}

func CreateSubnetEvmConfigSOV(subnetName string, genesisPath string) (string, string) {
func CreateSubnetEvmConfigSOVWithGenesisPath(subnetName string, genesisPath string, validatorManagerOwner string) (string, string) {
mapper := utils.NewVersionMapper()
mapping, err := utils.GetVersionMapping(mapper)
gomega.Expect(err).Should(gomega.BeNil())
// let's use a SubnetEVM version which has a guaranteed compatible avago
CreateSubnetEvmConfigWithVersionSOV(subnetName, genesisPath, mapping[utils.LatestEVM2AvagoKey])
CreateSubnetEvmConfigGenesisPathWithVersionSOV(subnetName, genesisPath, mapping[utils.LatestEVM2AvagoKey], validatorManagerOwner)
return mapping[utils.LatestEVM2AvagoKey], mapping[utils.LatestAvago2EVMKey]
}

Expand Down Expand Up @@ -85,7 +85,7 @@ func CreateSubnetEvmConfigWithVersionNonSOV(subnetName string, genesisPath strin
gomega.Expect(exists).Should(gomega.BeTrue())
}

func CreateSubnetEvmConfigWithVersionSOV(subnetName string, genesisPath string, version string) {
func CreateSubnetEvmConfigGenesisPathWithVersionSOV(subnetName string, genesisPath string, version string, validatorManagerOwner string) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need a generic function that just take the command name, the non flag args, and a map for flags, and
stopping doing this

// Check config does not already exist
exists, err := utils.SubnetConfigExists(subnetName)
gomega.Expect(err).Should(gomega.BeNil())
Expand All @@ -101,9 +101,9 @@ func CreateSubnetEvmConfigWithVersionSOV(subnetName string, genesisPath string,
subnetName,
"--proof-of-authority",
"--validator-manager-owner",
poaValidatorManagerOwner,
validatorManagerOwner,
"--proxy-contract-owner",
poaValidatorManagerOwner,
validatorManagerOwner,
"--" + constants.SkipUpdateFlag,
"--icm=false",
"--evm-token",
Expand Down Expand Up @@ -217,7 +217,7 @@ func CreateCustomVMConfigNonSOV(subnetName string, genesisPath string, vmPath st
gomega.Expect(exists).Should(gomega.BeTrue())
}

func CreateCustomVMConfigSOV(subnetName string, genesisPath string, vmPath string) {
func CreateCustomVMConfigSOV(subnetName string, genesisPath string, vmPath string, validatorManagerOwner string) {
// Check config does not already exist
exists, err := utils.SubnetConfigExists(subnetName)
gomega.Expect(err).Should(gomega.BeNil())
Expand All @@ -236,9 +236,9 @@ func CreateCustomVMConfigSOV(subnetName string, genesisPath string, vmPath strin
genesisPath,
"--proof-of-authority",
"--validator-manager-owner",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also need to stop using flag constants here, and take those from cmd/flags

poaValidatorManagerOwner,
validatorManagerOwner,
"--proxy-contract-owner",
poaValidatorManagerOwner,
validatorManagerOwner,
"--custom",
subnetName,
"--custom-vm-path",
Expand Down
111 changes: 111 additions & 0 deletions tests/e2e/commandse2e/blockchain/deploy/deploy_tests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this cmd tree. probably this can have a default name, like test_table.json

"globalFlags": {
"local": true,
"skip-icm-deploy": true,
"skip-update-check": true
},
"happyPath": [
{
"name": "local deploy default",
"flags": {},
"expectedContain": [
"L1 is successfully deployed on Local Network"
]
},
{
"name": "local deploy and use provided subnet id",
"flags": {
"subnet-id": ""
},
"expectedContain": [
"Deploying into pre-existent subnet ID",
"CreateChainTx fee",
"ConvertSubnetToL1Tx fee",
"L1 is successfully deployed on Local Network"
],
"expectedNotContain": [
"CreateSubnetTx fee"
]
},
{
"name": "local deploy using provided avalanchego path in flag",
"flags": {
"avalanchego-path": "tests/e2e/assets/avalanchego"
},
"expectedContain": [
"AvalancheGo path: {avalanchego-path}"
]
},
{
"name": "local deploy convert only",
"flags": {
"convert-only": true
},
"expectedContain": [
"To finish conversion to sovereign L1, create the corresponding Avalanche node(s) with the provided Node ID and BLS Info",
"Ensure that the P2P port is exposed and 'public-ip' config value is set",
"Once the Avalanche Node(s) are created and are tracking the blockchain, call `avalanche contract initValidatorManager testSubnet` to finish conversion to sovereign L1"
],
"expectedNotContain": [
"CreateChainTx fee",
"ConvertSubnetToL1Tx fee",
"L1 is successfully deployed on Local Network"
]
},
{
"name": "local deploy using provided avalanchego path in flag",
"flags": {
"num-bootstrap-validators": ""
}
},
{
"name": "local deploy using provided avalanchego path in flag",
"flags": {
"balance": ""
}
},
{
"name": "local deploy using provided avalanchego path in flag",
"flags": {
"num-local-nodes": ""
}
}
],
"notHappyPath": [
{
"name": "invalid_version",
"flags": {
"avalanchego-version": "invalid_version"
},
"expectedError": "invalid version string"
},
{
"name": "local deploy using invalid avalanchego path",
"flags": {
"avalanchego-path": "invalid_avago_path"
},
"expectedError": "invalid version string"
},
{
"name": "local deploy and use provided subnet id, but subnet id is invalid",
"flags": {
"subnet-id": "invalid_subnet_id"
},
"expectedError": "invalid version string"
},
{
"name": "invalid_version",
"flags": {
"use-local-machine": false
},
"expectedError": "invalid version string"
},
{
"name": "local deploy and generate node id",
"flags": {
"generate-node-id": true
},
"expectedError": "invalid version string"
}
]
}
83 changes: 83 additions & 0 deletions tests/e2e/commandse2e/blockchain/deploy/suite.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Copyright (C) 2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package deploy

import (
"fmt"

"github.com/ava-labs/avalanche-cli/tests/e2e/commandse2e"

"github.com/ava-labs/avalanche-cli/tests/e2e/commands"
ginkgo "github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
)

const (
deployTestJSONPath = "tests/e2e/commandse2e/blockchain/deploy/deploy_tests.json"
subnetName = "testSubnet"
)

var (
config *commandse2e.TestJSONConfig
err error
)

const ewoqEVMAddress = "0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC"

var _ = ginkgo.Describe("[Blockchain Deploy Flags]", ginkgo.Ordered, func() {
_ = ginkgo.BeforeEach(func() {
// Create test subnet config
commands.CreateSubnetEvmConfigSOV(subnetName, ewoqEVMAddress, commands.PoA)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this should be added to the json spec (how to setup required env)


// Read test configuration
config, err = commandse2e.ReadTestConfig(deployTestJSONPath)
gomega.Expect(err).Should(gomega.BeNil())
})

ginkgo.AfterEach(func() {
commands.CleanNetwork()
// Cleanup test subnet config
commands.DeleteSubnetConfig(subnetName)
})
blockchainCmdArgs := []string{subnetName}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should belong to the json test case IMO

ginkgo.It("should successfully deploy a blockchain", func() {
// Run each happy path test case
for _, testCase := range config.HappyPath {
ginkgo.By(fmt.Sprintf("Running test case: %s", testCase.Name))
output, err := commandse2e.TestCommandWithJSONConfig(
commandse2e.BlockchainCmd,
"deploy",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be a constant on cmd/blockchaincmd/

blockchainCmdArgs,
deployTestJSONPath,
&testCase,
)
if len(testCase.ExpectedContain) > 0 {
for _, expectedOutput := range testCase.ExpectedContain {
gomega.Expect(output).Should(gomega.ContainSubstring(expectedOutput))
}
}
if len(testCase.ExpectedNotContain) > 0 {
for _, expectedOutput := range testCase.ExpectedNotContain {
gomega.Expect(output).ShouldNot(gomega.ContainSubstring(expectedOutput))
}
}
gomega.Expect(err).Should(gomega.BeNil())
}
})

ginkgo.It("should handle error cases", func() {
// Run each not happy path test case
for _, testCase := range config.NotHappyPath {
ginkgo.By(fmt.Sprintf("Running test case: %s", testCase.Name))
_, err = commandse2e.TestCommandWithJSONConfig(
commandse2e.BlockchainCmd,
"deploy",
blockchainCmdArgs,
deployTestJSONPath,
&testCase,
)
gomega.Expect(err).Should(gomega.HaveOccurred())
}
})
})
Loading
Loading