mirror of
https://github.com/luxfi/cli.git
synced 2026-10-30 17:01:20 +00:00
Rename Etna-named test scenarios and helper functions to Sov / sovL1 / local equivalents (sovereign-L1 chain creation is a Lux primitive, no need to keep the Apricot/Banff/.../Etna upgrade-era branding): - tests/e2e/commands/etna.go -> tests/e2e/commands/sov.go - Create/CreateLocal/Deploy/Track/Add/RemoveEtna* -> *Sov* - ginkgo Describe/It labels: [Etna ...] -> [Sov ...] - tests/e2e/testcases/chain/sov/etna -> tests/e2e/testcases/chain/sov/sovL1 - createEtnaEVMConfig... -> createSovEVMConfig... - deployEtnaChain*Flag* -> deploySovChain*Flag* - initValidatorManagerEtnaFlag -> initValidatorManagerLocalFlag Neutralized comments: - "Banff.10:" prefix in luxdConfig.go (key-rename note kept, brand removed) - "testnet durango" version annotation removed from dependencies.go
447 lines
12 KiB
Go
447 lines
12 KiB
Go
// Copyright (C) 2022-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
// Package chain contains chain E2E tests.
|
|
package chain
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
|
|
"github.com/luxfi/cli/tests/e2e/commands"
|
|
"github.com/luxfi/cli/tests/e2e/utils"
|
|
"github.com/luxfi/constants"
|
|
ginkgo "github.com/onsi/ginkgo/v2"
|
|
"github.com/onsi/gomega"
|
|
)
|
|
|
|
// Test constants.
|
|
const (
|
|
CLIBinary = "./bin/lux"
|
|
keyName = "treasury"
|
|
treasuryEVMAddress = "0x9011E888251AB053B7bD1cdB598Db4f9DEd94714"
|
|
treasuryPChainAddress = "P-custom18jma8ppw3nhx5r4ap8clazz0dps7rv5u9xde7p"
|
|
)
|
|
|
|
func createSovEVMConfig(poa, pos bool) string {
|
|
// Check config does not already exist
|
|
exists, err := utils.ChainConfigExists(utils.BlockchainName)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
gomega.Expect(exists).Should(gomega.BeFalse())
|
|
|
|
cmdArgs := []string{
|
|
"blockchain",
|
|
"create",
|
|
utils.BlockchainName,
|
|
"--evm",
|
|
"--validator-manager-owner",
|
|
treasuryEVMAddress,
|
|
"--proxy-contract-owner",
|
|
treasuryEVMAddress,
|
|
"--production-defaults",
|
|
"--evm-chain-id=99999",
|
|
"--evm-token=TOK",
|
|
"--warp=false",
|
|
"--" + constants.SkipUpdateFlag,
|
|
}
|
|
if poa {
|
|
cmdArgs = append(cmdArgs, "--proof-of-authority")
|
|
} else if pos {
|
|
cmdArgs = append(cmdArgs, "--proof-of-stake")
|
|
}
|
|
|
|
cmd := exec.Command(CLIBinary, cmdArgs...) //nolint:gosec // G204: Running our own CLI binary in tests
|
|
output, err := cmd.CombinedOutput()
|
|
fmt.Println(string(output))
|
|
if err != nil {
|
|
fmt.Println(cmd.String())
|
|
utils.PrintStdErr(err)
|
|
}
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
|
|
// Config should now exist
|
|
exists, err = utils.ChainConfigExists(utils.BlockchainName)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
gomega.Expect(exists).Should(gomega.BeTrue())
|
|
|
|
// return binary versions for this conf
|
|
mapper := utils.NewVersionMapper()
|
|
mapping, err := utils.GetVersionMapping(mapper)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
return mapping[utils.LatestLuxd2EVMKey]
|
|
}
|
|
|
|
func createSovEVMConfigWithoutProxyOwner(poa, pos bool) {
|
|
// Check config does not already exist
|
|
exists, err := utils.ChainConfigExists(utils.BlockchainName)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
gomega.Expect(exists).Should(gomega.BeFalse())
|
|
|
|
cmdArgs := []string{
|
|
"blockchain",
|
|
"create",
|
|
utils.BlockchainName,
|
|
"--evm",
|
|
"--validator-manager-owner",
|
|
treasuryEVMAddress,
|
|
"--production-defaults",
|
|
"--evm-chain-id=99999",
|
|
"--evm-token=TOK",
|
|
"--warp=false",
|
|
"--" + constants.SkipUpdateFlag,
|
|
}
|
|
if poa {
|
|
cmdArgs = append(cmdArgs, "--proof-of-authority")
|
|
} else if pos {
|
|
cmdArgs = append(cmdArgs, "--proof-of-stake")
|
|
}
|
|
|
|
cmd := exec.Command(CLIBinary, cmdArgs...) //nolint:gosec // G204: Running our own CLI binary in tests
|
|
output, err := cmd.CombinedOutput()
|
|
fmt.Println(string(output))
|
|
if err != nil {
|
|
fmt.Println(cmd.String())
|
|
utils.PrintStdErr(err)
|
|
}
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
|
|
// Config should now exist
|
|
exists, err = utils.ChainConfigExists(utils.BlockchainName)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
gomega.Expect(exists).Should(gomega.BeTrue())
|
|
}
|
|
|
|
func createSovEVMConfigValidatorManagerFlagKeyname(poa, pos bool) {
|
|
// Check config does not already exist
|
|
exists, err := utils.ChainConfigExists(utils.BlockchainName)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
gomega.Expect(exists).Should(gomega.BeFalse())
|
|
|
|
cmdArgs := []string{
|
|
"blockchain",
|
|
"create",
|
|
utils.BlockchainName,
|
|
"--evm",
|
|
"--validator-manager-owner",
|
|
treasuryEVMAddress,
|
|
"--proxy-contract-owner",
|
|
treasuryEVMAddress,
|
|
"--production-defaults",
|
|
"--evm-chain-id=99999",
|
|
"--evm-token=TOK",
|
|
"--warp=false",
|
|
"--" + constants.SkipUpdateFlag,
|
|
}
|
|
if poa {
|
|
cmdArgs = append(cmdArgs, "--proof-of-authority")
|
|
} else if pos {
|
|
cmdArgs = append(cmdArgs, "--proof-of-stake")
|
|
}
|
|
|
|
cmd := exec.Command(CLIBinary, cmdArgs...) //nolint:gosec // G204: Running our own CLI binary in tests
|
|
output, err := cmd.CombinedOutput()
|
|
fmt.Println(string(output))
|
|
if err != nil {
|
|
fmt.Println(cmd.String())
|
|
utils.PrintStdErr(err)
|
|
}
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
|
|
// Config should now exist
|
|
exists, err = utils.ChainConfigExists(utils.BlockchainName)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
gomega.Expect(exists).Should(gomega.BeTrue())
|
|
}
|
|
|
|
func createSovEVMConfigValidatorManagerFlagPChain(poa, pos bool) {
|
|
// Check config does not already exist
|
|
exists, err := utils.ChainConfigExists(utils.BlockchainName)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
gomega.Expect(exists).Should(gomega.BeFalse())
|
|
|
|
cmdArgs := []string{
|
|
"blockchain",
|
|
"create",
|
|
utils.BlockchainName,
|
|
"--evm",
|
|
"--validator-manager-owner",
|
|
treasuryPChainAddress,
|
|
"--proxy-contract-owner",
|
|
treasuryPChainAddress,
|
|
"--production-defaults",
|
|
"--evm-chain-id=99999",
|
|
"--evm-token=TOK",
|
|
"--warp=false",
|
|
"--" + constants.SkipUpdateFlag,
|
|
}
|
|
if poa {
|
|
cmdArgs = append(cmdArgs, "--proof-of-authority")
|
|
} else if pos {
|
|
cmdArgs = append(cmdArgs, "--proof-of-stake")
|
|
}
|
|
|
|
cmd := exec.Command(CLIBinary, cmdArgs...) //nolint:gosec // G204: Running our own CLI binary in tests
|
|
output, err := cmd.CombinedOutput()
|
|
fmt.Println(string(output))
|
|
if err != nil {
|
|
fmt.Println(cmd.String())
|
|
utils.PrintStdErr(err)
|
|
}
|
|
gomega.Expect(err).ShouldNot(gomega.BeNil())
|
|
}
|
|
|
|
func destroyLocalNode() {
|
|
_, err := os.Stat(utils.TestLocalNodeName)
|
|
if os.IsNotExist(err) {
|
|
return
|
|
}
|
|
cmd := exec.Command( //nolint:gosec // G204: Running our own CLI binary in tests
|
|
CLIBinary,
|
|
"node",
|
|
"local",
|
|
"destroy",
|
|
utils.TestLocalNodeName,
|
|
"--"+constants.SkipUpdateFlag,
|
|
)
|
|
output, err := cmd.CombinedOutput()
|
|
if err != nil {
|
|
fmt.Println(cmd.String())
|
|
fmt.Println(string(output))
|
|
utils.PrintStdErr(err)
|
|
}
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
}
|
|
|
|
func deploySovChainLocalFlag() {
|
|
// Check config exists
|
|
exists, err := utils.ChainConfigExists(utils.BlockchainName)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
gomega.Expect(exists).Should(gomega.BeTrue())
|
|
|
|
// Deploy chain on sov local network with local machine as bootstrap validator
|
|
cmd := exec.Command( //nolint:gosec // G204: Running our own CLI binary in tests
|
|
CLIBinary,
|
|
"blockchain",
|
|
"deploy",
|
|
utils.BlockchainName,
|
|
"--local",
|
|
"--num-bootstrap-validators=1",
|
|
"--treasury",
|
|
"--change-owner-address",
|
|
treasuryPChainAddress,
|
|
"--"+constants.SkipUpdateFlag,
|
|
)
|
|
output, err := cmd.CombinedOutput()
|
|
fmt.Println(string(output))
|
|
if err != nil {
|
|
fmt.Println(cmd.String())
|
|
utils.PrintStdErr(err)
|
|
}
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
}
|
|
|
|
func deploySovChainLocalFlagConvertOnly() {
|
|
// Check config exists
|
|
exists, err := utils.ChainConfigExists(utils.BlockchainName)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
gomega.Expect(exists).Should(gomega.BeTrue())
|
|
|
|
// Deploy chain on sov local network with local machine as bootstrap validator
|
|
cmd := exec.Command( //nolint:gosec // G204: Running our own CLI binary in tests
|
|
CLIBinary,
|
|
"blockchain",
|
|
"deploy",
|
|
utils.BlockchainName,
|
|
"--local",
|
|
"--num-bootstrap-validators=1",
|
|
"--convert-only",
|
|
"--treasury",
|
|
"--change-owner-address",
|
|
treasuryPChainAddress,
|
|
"--"+constants.SkipUpdateFlag,
|
|
)
|
|
output, err := cmd.CombinedOutput()
|
|
fmt.Println(string(output))
|
|
if err != nil {
|
|
fmt.Println(cmd.String())
|
|
utils.PrintStdErr(err)
|
|
}
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
}
|
|
|
|
func deploySovChainClusterFlagConvertOnly(clusterName string) {
|
|
// Check config exists
|
|
exists, err := utils.ChainConfigExists(utils.BlockchainName)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
gomega.Expect(exists).Should(gomega.BeTrue())
|
|
|
|
// Deploy chain on sov local network with local machine as bootstrap validator
|
|
cmd := exec.Command( //nolint:gosec // G204: Running our own CLI binary in tests
|
|
CLIBinary,
|
|
"blockchain",
|
|
"deploy",
|
|
utils.BlockchainName,
|
|
fmt.Sprintf("--cluster=%s", clusterName),
|
|
"--convert-only",
|
|
"--treasury",
|
|
"--change-owner-address",
|
|
treasuryPChainAddress,
|
|
"--"+constants.SkipUpdateFlag,
|
|
)
|
|
output, err := cmd.CombinedOutput()
|
|
fmt.Println(string(output))
|
|
if err != nil {
|
|
fmt.Println(cmd.String())
|
|
utils.PrintStdErr(err)
|
|
}
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
}
|
|
|
|
func initValidatorManagerClusterFlag(
|
|
chainName string,
|
|
clusterName string,
|
|
) error {
|
|
cmd := exec.Command( //nolint:gosec // G204: Running our own CLI binary in tests
|
|
CLIBinary,
|
|
"contract",
|
|
"initValidatorManager",
|
|
chainName,
|
|
"--cluster",
|
|
clusterName,
|
|
"--genesis-key",
|
|
"--"+constants.SkipUpdateFlag,
|
|
)
|
|
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 err
|
|
}
|
|
|
|
func initValidatorManagerLocalFlag(
|
|
chainName string,
|
|
) (string, error) {
|
|
cmd := exec.Command( //nolint:gosec // G204: Running our own CLI binary in tests
|
|
CLIBinary,
|
|
"contract",
|
|
"initValidatorManager",
|
|
chainName,
|
|
"--local",
|
|
"--genesis-key",
|
|
"--"+constants.SkipUpdateFlag,
|
|
)
|
|
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
|
|
}
|
|
|
|
var luxdVersion string
|
|
|
|
var _ = ginkgo.Describe("[Sov Chain SOV]", func() {
|
|
ginkgo.BeforeEach(func() {
|
|
// key
|
|
_ = utils.DeleteKey(keyName)
|
|
output, err := commands.CreateKeyFromPath(keyName, utils.LocalKeyPath)
|
|
if err != nil {
|
|
fmt.Println(output)
|
|
utils.PrintStdErr(err)
|
|
}
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
// chain config
|
|
_ = utils.DeleteConfigs(utils.BlockchainName)
|
|
destroyLocalNode()
|
|
})
|
|
|
|
ginkgo.AfterEach(func() {
|
|
destroyLocalNode()
|
|
commands.DeleteChainConfig(utils.BlockchainName)
|
|
_ = utils.DeleteKey(keyName)
|
|
commands.CleanNetwork()
|
|
})
|
|
|
|
ginkgo.It("Test Create Sov POA Chain Config With Key Name for Validator Manager Flag", func() {
|
|
createSovEVMConfigValidatorManagerFlagKeyname(true, false)
|
|
})
|
|
|
|
ginkgo.It("Test Create Sov POA Chain Config Without Proxy Owner Flag", func() {
|
|
createSovEVMConfigWithoutProxyOwner(true, false)
|
|
})
|
|
|
|
ginkgo.It("Create Sov POA Chain Config & Deploy the Chain To Sov Local Network On Local Machine", func() {
|
|
createSovEVMConfig(true, false)
|
|
deploySovChainLocalFlag()
|
|
})
|
|
|
|
ginkgo.It("Create Sov POS Chain Config & Deploy the Chain To Sov Local Network On Local Machine", func() {
|
|
createSovEVMConfig(false, true)
|
|
deploySovChainLocalFlag()
|
|
})
|
|
|
|
ginkgo.It("Start Local Node on Sov & Deploy the Chain To Sov Local Network using cluster flag", func() {
|
|
luxdVersion = createSovEVMConfig(true, false)
|
|
_ = commands.StartNetworkWithVersion(luxdVersion)
|
|
_, err := commands.CreateLocalSovNode(luxdVersion, utils.TestLocalNodeName, 1)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
deploySovChainClusterFlagConvertOnly(utils.TestLocalNodeName)
|
|
_, err = commands.TrackLocalSovChain(utils.TestLocalNodeName, utils.BlockchainName)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
err = initValidatorManagerClusterFlag(utils.BlockchainName, utils.TestLocalNodeName)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
})
|
|
|
|
ginkgo.It("Mix and match network and cluster flags test 1", func() {
|
|
luxdVersion = createSovEVMConfig(true, false)
|
|
_ = commands.StartNetworkWithVersion(luxdVersion)
|
|
_, err := commands.CreateLocalSovNode(luxdVersion, utils.TestLocalNodeName, 1)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
deploySovChainClusterFlagConvertOnly(utils.TestLocalNodeName)
|
|
_, err = commands.TrackLocalSovChain(utils.TestLocalNodeName, utils.BlockchainName)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
_, err = initValidatorManagerLocalFlag(utils.BlockchainName)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
})
|
|
ginkgo.It("Mix and match network and cluster flags test 2", func() {
|
|
createSovEVMConfig(true, false)
|
|
deploySovChainLocalFlagConvertOnly()
|
|
_, err := commands.TrackLocalSovChain(utils.TestLocalNodeName, utils.BlockchainName)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
err = initValidatorManagerClusterFlag(utils.BlockchainName, utils.TestLocalNodeName)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
})
|
|
})
|
|
|
|
var _ = ginkgo.Describe("[Sov Chain SOV With Errors]", func() {
|
|
ginkgo.BeforeEach(func() {
|
|
// key
|
|
_ = utils.DeleteKey(keyName)
|
|
output, err := commands.CreateKeyFromPath(keyName, utils.LocalKeyPath)
|
|
if err != nil {
|
|
fmt.Println(output)
|
|
utils.PrintStdErr(err)
|
|
}
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
// chain config
|
|
_ = utils.DeleteConfigs(utils.BlockchainName)
|
|
destroyLocalNode()
|
|
})
|
|
|
|
ginkgo.AfterEach(func() {
|
|
err := utils.DeleteKey(keyName)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
commands.CleanNetwork()
|
|
})
|
|
|
|
ginkgo.It("Test Create Sov POA Chain Config With P Chain Address for Validator Manager Flag", func() {
|
|
createSovEVMConfigValidatorManagerFlagPChain(true, false)
|
|
})
|
|
})
|