Skip to content
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

Add Fuji Tests #2398

Draft
wants to merge 8 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
2 changes: 2 additions & 0 deletions cmd/blockchaincmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,12 +823,14 @@ func deployBlockchain(cmd *cobra.Command, args []string) error {
if createSubnet {
subnetID, err = deployer.DeploySubnet(controlKeys, threshold)
if err != nil {
fmt.Printf("we have err here %s \n", err)
return err
}
deployer.CleanCacheWallet()
// get the control keys in the same order as the tx
_, controlKeys, threshold, err = txutils.GetOwners(network, subnetID)
if err != nil {
fmt.Printf("we have err here 2 %s \n", err)
return err
}
}
Expand Down
8 changes: 7 additions & 1 deletion pkg/keychain/keychain.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package keychain
import (
"errors"
"fmt"
"github.com/ava-labs/avalanche-cli/pkg/constants"
"os"

"github.com/ava-labs/avalanche-cli/cmd/flags"
"github.com/ava-labs/avalanche-cli/pkg/application"
Expand Down Expand Up @@ -153,7 +155,7 @@ func GetKeychainFromCmdLineFlags(
}
}
case network.Kind == models.Fuji:
if useEwoq {
if !simulatedPublicNetwork() && useEwoq {
return nil, ErrEwoqKeyOnFuji
}
// prompt the user if no key source was provided
Expand All @@ -178,6 +180,10 @@ func GetKeychainFromCmdLineFlags(
return GetKeychain(app, useEwoq, useLedger, ledgerAddresses, keyName, network, requiredFunds)
}

func simulatedPublicNetwork() bool {
return os.Getenv(constants.SimulatePublicNetwork) != ""
}

func GetKeychain(
app *application.Avalanche,
useEwoq bool,
Expand Down
2 changes: 2 additions & 0 deletions pkg/subnet/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,12 @@ func (d *PublicDeployer) DeploySubnet(
) (ids.ID, error) {
wallet, err := d.loadWallet()
if err != nil {
fmt.Printf("we have err loadWallet %s \n", err)
return ids.Empty, err
}
subnetID, err := d.createSubnetTx(controlKeys, threshold, wallet)
if err != nil {
fmt.Printf("we have err createSubnetTx %s \n", err)
return ids.Empty, err
}
ux.Logger.PrintToUser("Subnet has been created with ID: %s", subnetID.String())
Expand Down
29 changes: 28 additions & 1 deletion tests/e2e/commands/etna.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const (

const (
etnaDevnetFlag = "--etna-devnet"
fujiFlag = "--fuji"
PoSString = "proof-of-stake"
PoAString = "proof-of-authority"
)
Expand Down Expand Up @@ -104,6 +105,32 @@ func CreateLocalEtnaDevnetNode(
return string(output), err
}

func CreateLocalFujiNode(
clusterName string,
numNodes int,
) (string, error) {
cmd := exec.Command(
CLIBinary,
"node",
"local",
"start",
clusterName,
fujiFlag,
"--num-nodes",
fmt.Sprintf("%d", numNodes),
"--"+constants.SkipUpdateFlag,
)
fmt.Println(cmd)
output, err := cmd.CombinedOutput()
if err != nil {
fmt.Println(cmd.String())
fmt.Println(string(output))
utils.PrintStdErr(err)
}
gomega.Expect(err).Should(gomega.BeNil())
return string(output), err
}

func DestroyLocalNode(
clusterName string,
) (string, error) {
Expand Down Expand Up @@ -171,7 +198,7 @@ func DeployEtnaSubnetToCluster(
return string(output), err
}

func TrackLocalEtnaSubnet(
func TrackLocalSubnet(
clusterName string,
subnetName string,
) (string, error) {
Expand Down
12 changes: 11 additions & 1 deletion tests/e2e/commands/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func CreateSubnetEvmConfigNonSOV(subnetName string, genesisPath string) (string,
gomega.Expect(err).Should(gomega.BeNil())
// let's use a SubnetEVM version which has a guaranteed compatible avago
CreateSubnetEvmConfigWithVersionNonSOV(subnetName, genesisPath, mapping[utils.LatestEVM2AvagoKey])
return mapping[utils.LatestEVM2AvagoKey], mapping[utils.LatestAvago2EVMKey]
return mapping[utils.LatestEVM2AvagoKey], "v1.12.0-fuji"
}

func CreateSubnetEvmConfigSOV(subnetName string, genesisPath string) (string, string) {
Expand All @@ -44,6 +44,15 @@ func CreateSubnetEvmConfigSOV(subnetName string, genesisPath string) (string, st
return mapping[utils.LatestEVM2AvagoKey], mapping[utils.LatestAvago2EVMKey]
}

func CreateSubnetEvmConfigSOVNew(subnetName string, genesisPath 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])
return mapping[utils.LatestEVM2AvagoKey], "v1.12.0-fuji"
}

/* #nosec G204 */
func CreateSubnetEvmConfigWithVersionNonSOV(subnetName string, genesisPath string, version string) {
// Check config does not already exist
Expand Down Expand Up @@ -517,6 +526,7 @@ func SimulateFujiDeployNonSOV(
"--"+constants.SkipUpdateFlag,
)
output, err := cmd.CombinedOutput()
fmt.Printf("command obtained %s \n", cmd.String())
if err != nil {
fmt.Println(cmd.String())
fmt.Println(string(output))
Expand Down
3 changes: 0 additions & 3 deletions tests/e2e/testcases/subnet/non-sov/public/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ const (
subnetName = "e2eSubnetTest"
controlKeys = "P-custom18jma8ppw3nhx5r4ap8clazz0dps7rv5u9xde7p"
keyName = "ewoq"
stakeAmount = "2000"
stakeDuration = "336h"
localNetwork = "Local Network"
ledger1Seed = "ledger1"
ledger2Seed = "ledger2"
ledger3Seed = "ledger3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ var _ = ginkgo.Describe("[Etna AddRemove Validator SOV PoA]", func() {
})

ginkgo.It("Can make cluster track a subnet", func() {
output, err := commands.TrackLocalEtnaSubnet(testLocalNodeName, subnetName)
output, err := commands.TrackLocalSubnet(testLocalNodeName, subnetName)
gomega.Expect(err).Should(gomega.BeNil())
fmt.Println(output)
// parse blockchainID from output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var _ = ginkgo.Describe("[Etna AddRemove Validator SOV PoS]", func() {
})

ginkgo.It("Can make cluster track a subnet", func() {
output, err := commands.TrackLocalEtnaSubnet(testLocalNodeName, subnetName)
output, err := commands.TrackLocalSubnet(testLocalNodeName, subnetName)
gomega.Expect(err).Should(gomega.BeNil())
fmt.Println(output)
// parse blockchainID from output
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/testcases/subnet/sov/etna/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ var _ = ginkgo.Describe("[Etna Subnet SOV]", func() {
gomega.Expect(err).Should(gomega.BeNil())
createEtnaSubnetEvmConfig(true, false)
deployEtnaSubnetClusterFlagConvertOnly(testLocalNodeName)
_, err = commands.TrackLocalEtnaSubnet(testLocalNodeName, subnetName)
_, err = commands.TrackLocalSubnet(testLocalNodeName, subnetName)
gomega.Expect(err).Should(gomega.BeNil())
err = initValidatorManagerClusterFlag(subnetName, testLocalNodeName)
gomega.Expect(err).Should(gomega.BeNil())
Expand All @@ -394,15 +394,15 @@ var _ = ginkgo.Describe("[Etna Subnet SOV]", func() {
gomega.Expect(err).Should(gomega.BeNil())
createEtnaSubnetEvmConfig(true, false)
deployEtnaSubnetClusterFlagConvertOnly(testLocalNodeName)
_, err = commands.TrackLocalEtnaSubnet(testLocalNodeName, subnetName)
_, err = commands.TrackLocalSubnet(testLocalNodeName, subnetName)
gomega.Expect(err).Should(gomega.BeNil())
_, err = initValidatorManagerEtnaFlag(subnetName)
gomega.Expect(err).Should(gomega.BeNil())
})
ginkgo.It("Mix and match network and cluster flags test 2", func() {
createEtnaSubnetEvmConfig(true, false)
deployEtnaSubnetEtnaFlagConvertOnly()
_, err := commands.TrackLocalEtnaSubnet(testLocalNodeName, subnetName)
_, err := commands.TrackLocalSubnet(testLocalNodeName, subnetName)
gomega.Expect(err).Should(gomega.BeNil())
err = initValidatorManagerClusterFlag(subnetName, testLocalNodeName)
gomega.Expect(err).Should(gomega.BeNil())
Expand Down
Loading
Loading