mirror of
https://github.com/luxfi/cli.git
synced 2026-10-30 17:01:20 +00:00
109 lines
3.1 KiB
Go
109 lines
3.1 KiB
Go
// Copyright (C) 2022, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package network
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/luxfi/cli/v2/tests/e2e/commands"
|
|
"github.com/luxfi/cli/v2/tests/e2e/utils"
|
|
ginkgo "github.com/onsi/ginkgo/v2"
|
|
"github.com/onsi/gomega"
|
|
)
|
|
|
|
const (
|
|
subnetName = "e2eSubnetTest"
|
|
)
|
|
|
|
var _ = ginkgo.Describe("[Network]", ginkgo.Ordered, func() {
|
|
ginkgo.AfterEach(func() {
|
|
commands.CleanNetwork()
|
|
err := utils.DeleteConfigs(subnetName)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
})
|
|
|
|
ginkgo.It("can stop and restart a deployed subnet", func() {
|
|
commands.CreateSubnetEvmConfig(subnetName, utils.SubnetEvmGenesisPath)
|
|
deployOutput := commands.DeploySubnetLocally(subnetName)
|
|
rpcs, err := utils.ParseRPCsFromOutput(deployOutput)
|
|
if err != nil {
|
|
fmt.Println(deployOutput)
|
|
}
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
gomega.Expect(rpcs).Should(gomega.HaveLen(1))
|
|
rpc := rpcs[0]
|
|
|
|
err = utils.SetHardhatRPC(rpc)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
|
|
// Deploy greeter contract
|
|
scriptOutput, scriptErr, err := utils.RunHardhatScript(utils.GreeterScript)
|
|
if scriptErr != "" {
|
|
fmt.Println(scriptOutput)
|
|
fmt.Println(scriptErr)
|
|
}
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
err = utils.ParseGreeterAddress(scriptOutput)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
|
|
// Check greeter script before stopping
|
|
scriptOutput, scriptErr, err = utils.RunHardhatScript(utils.GreeterCheck)
|
|
if scriptErr != "" {
|
|
fmt.Println(scriptOutput)
|
|
fmt.Println(scriptErr)
|
|
}
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
|
|
commands.StopNetwork()
|
|
restartOutput := commands.StartNetwork()
|
|
rpcs, err = utils.ParseRPCsFromOutput(restartOutput)
|
|
if err != nil {
|
|
fmt.Println(restartOutput)
|
|
}
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
gomega.Expect(rpcs).Should(gomega.HaveLen(1))
|
|
rpc = rpcs[0]
|
|
|
|
err = utils.SetHardhatRPC(rpc)
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
|
|
// Check greeter contract has right value
|
|
scriptOutput, scriptErr, err = utils.RunHardhatScript(utils.GreeterCheck)
|
|
if scriptErr != "" {
|
|
fmt.Println(scriptOutput)
|
|
fmt.Println(scriptErr)
|
|
}
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
|
|
commands.DeleteSubnetConfig(subnetName)
|
|
})
|
|
|
|
ginkgo.It("clean hard deletes plugin binaries", func() {
|
|
commands.CreateSubnetEvmConfig(subnetName, utils.SubnetEvmGenesisPath)
|
|
deployOutput := commands.DeploySubnetLocally(subnetName)
|
|
rpcs, err := utils.ParseRPCsFromOutput(deployOutput)
|
|
if err != nil {
|
|
fmt.Println(deployOutput)
|
|
}
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
gomega.Expect(rpcs).Should(gomega.HaveLen(1))
|
|
|
|
// check that plugin binaries exist
|
|
plugins, err := utils.GetPluginBinaries()
|
|
// should have only evm binary
|
|
gomega.Expect(len(plugins)).Should(gomega.Equal(1))
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
|
|
commands.CleanNetwork()
|
|
|
|
// check that plugin binaries exist
|
|
plugins, err = utils.GetPluginBinaries()
|
|
// should be empty
|
|
gomega.Expect(len(plugins)).Should(gomega.Equal(0))
|
|
gomega.Expect(err).Should(gomega.BeNil())
|
|
|
|
commands.DeleteSubnetConfig(subnetName)
|
|
})
|
|
})
|