Skip to content

Commit 8cda684

Browse files
author
Tony Zhang
committed
Adding e2e test for local node start
1 parent a3d48e0 commit 8cda684

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

cmd/constants.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ const (
1010
ValidatorCmd CommandGroup = "validator"
1111
ICMCmd CommandGroup = "icm"
1212
InterchainCmd CommandGroup = "interchain"
13+
NodeCmd CommandGroup = "node"
1314
)

tests/e2e/commands/node.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ import (
1414

1515
"gopkg.in/yaml.v3"
1616

17+
"github.com/ava-labs/avalanche-cli/cmd"
1718
"github.com/ava-labs/avalanche-cli/pkg/constants"
19+
"github.com/ava-labs/avalanche-cli/tests/e2e/utils"
1820
"github.com/onsi/gomega"
1921
)
2022

@@ -207,6 +209,25 @@ func NodeImport(filename string, clusterName string) string {
207209
return runCmd(cmd, ExpectSuccess)
208210
}
209211

212+
func NodeLocalStart(clusterName string) (string, error) {
213+
return utils.TestCommand(
214+
cmd.NodeCmd,
215+
"local",
216+
[]string{
217+
"start",
218+
clusterName,
219+
"--local",
220+
},
221+
utils.GlobalFlags{},
222+
utils.TestFlags{},
223+
)
224+
}
225+
226+
// TODO:
227+
// func NodeLocalStop()
228+
// func NodeLocalStatus()
229+
// func NodeLocalDestroy(clusterName string)
230+
210231
type StaticConfig struct {
211232
Targets []string `yaml:"targets"`
212233
}

tests/e2e/e2e_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
_ "github.com/ava-labs/avalanche-cli/tests/e2e/testcases/network/stop"
2626
_ "github.com/ava-labs/avalanche-cli/tests/e2e/testcases/node/create"
2727
_ "github.com/ava-labs/avalanche-cli/tests/e2e/testcases/node/devnet"
28+
_ "github.com/ava-labs/avalanche-cli/tests/e2e/testcases/node/local/start"
2829
_ "github.com/ava-labs/avalanche-cli/tests/e2e/testcases/node/monitoring"
2930
_ "github.com/ava-labs/avalanche-cli/tests/e2e/testcases/packageman"
3031
_ "github.com/ava-labs/avalanche-cli/tests/e2e/testcases/relayer/deploy"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (C) 2025, Ava Labs, Inc. All rights reserved.
2+
// See the file LICENSE for licensing terms.
3+
4+
package root
5+
6+
import (
7+
"github.com/ava-labs/avalanche-cli/tests/e2e/commands"
8+
"github.com/onsi/ginkgo/v2"
9+
"github.com/onsi/gomega"
10+
)
11+
12+
var _ = ginkgo.Describe("[Node local start]", func() {
13+
testClusterName := "test-cluster"
14+
15+
ginkgo.AfterEach(func() {
16+
commands.CleanNetwork()
17+
})
18+
19+
ginkgo.It("can create a local node with a started network", func() {
20+
output := commands.StartNetwork()
21+
gomega.Expect(output).Should(gomega.ContainSubstring("Network ready to use"))
22+
23+
output, err := commands.NodeLocalStart(testClusterName)
24+
gomega.Expect(err).Should(gomega.BeNil())
25+
gomega.Expect(output).Should(gomega.ContainSubstring("NodeID: NodeID-"))
26+
})
27+
28+
ginkgo.It("should not create local nodes without a started network", func() {
29+
output, _ := commands.NodeLocalStart(testClusterName)
30+
gomega.Expect(output).Should(gomega.ContainSubstring("network is not running"))
31+
})
32+
})

0 commit comments

Comments
 (0)