Skip to content

Commit 2afe7a2

Browse files
author
Tony Zhang
committed
Adding e2e test for local node start
1 parent ff59daa commit 2afe7a2

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

tests/e2e/commands/node.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"gopkg.in/yaml.v3"
1616

1717
"github.com/ava-labs/avalanche-cli/pkg/constants"
18+
"github.com/ava-labs/avalanche-cli/tests/e2e/utils"
1819
"github.com/onsi/gomega"
1920
)
2021

@@ -207,6 +208,25 @@ func NodeImport(filename string, clusterName string) string {
207208
return runCmd(cmd, ExpectSuccess)
208209
}
209210

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

tests/e2e/e2e_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
_ "github.com/ava-labs/avalanche-cli/tests/e2e/testcases/network/stop"
2222
_ "github.com/ava-labs/avalanche-cli/tests/e2e/testcases/node/create"
2323
_ "github.com/ava-labs/avalanche-cli/tests/e2e/testcases/node/devnet"
24+
_ "github.com/ava-labs/avalanche-cli/tests/e2e/testcases/node/local/start"
2425
_ "github.com/ava-labs/avalanche-cli/tests/e2e/testcases/node/monitoring"
2526
_ "github.com/ava-labs/avalanche-cli/tests/e2e/testcases/packageman"
2627
_ "github.com/ava-labs/avalanche-cli/tests/e2e/testcases/root"
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+
})

tests/e2e/utils/command.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type CommandGroup string
1919

2020
const (
2121
BlockchainCmd CommandGroup = "blockchain"
22+
NodeCmd CommandGroup = "node"
2223
)
2324

2425
var avalancheBinaryPath = "./bin/avalanche"

0 commit comments

Comments
 (0)