|
| 1 | +// Copyright (C) 2025, Ava Labs, Inc. All rights reserved. |
| 2 | +// See the file LICENSE for licensing terms. |
| 3 | + |
| 4 | +package network |
| 5 | + |
| 6 | +import ( |
| 7 | + "fmt" |
| 8 | + |
| 9 | + "github.com/ava-labs/avalanche-cli/tests/e2e/commands" |
| 10 | + ginkgo "github.com/onsi/ginkgo/v2" |
| 11 | + "github.com/onsi/gomega" |
| 12 | +) |
| 13 | + |
| 14 | +var _ = ginkgo.Describe("[Local Network] Start", ginkgo.Ordered, func() { |
| 15 | + ginkgo.AfterEach(func() { |
| 16 | + err := commands.StopNetwork() |
| 17 | + gomega.Expect(err).Should(gomega.BeNil()) |
| 18 | + _, _ = commands.CleanNetwork() |
| 19 | + }) |
| 20 | + |
| 21 | + ginkgo.It("can start network with default params", func() { |
| 22 | + out := commands.StartNetwork() |
| 23 | + gomega.Expect(out).Should(gomega.ContainSubstring("Network ready to use")) |
| 24 | + |
| 25 | + // https://github.com/ava-labs/avalanchego/blob/master/tests/fixture/tmpnet/defaults.go#L27 |
| 26 | + defaultNodeCount := 2 |
| 27 | + |
| 28 | + // check network status |
| 29 | + out, err := commands.GetNetworkStatus() |
| 30 | + gomega.Expect(err).Should(gomega.BeNil()) |
| 31 | + gomega.Expect(out).Should(gomega.ContainSubstring("Network is Up")) |
| 32 | + gomega.Expect(out).Should(gomega.ContainSubstring(fmt.Sprintf("Number of Nodes: %d", defaultNodeCount))) |
| 33 | + gomega.Expect(out).Should(gomega.ContainSubstring("Network Healthy: true")) |
| 34 | + gomega.Expect(out).Should(gomega.ContainSubstring("Blockchains Healthy: true")) |
| 35 | + }) |
| 36 | + |
| 37 | + ginkgo.It("can start network with given number of nodes", func() { |
| 38 | + numOfNodes := uint(3) |
| 39 | + out := commands.StartNetworkWithNodeNumber(numOfNodes) |
| 40 | + gomega.Expect(out).Should(gomega.ContainSubstring("Network ready to use")) |
| 41 | + |
| 42 | + // check network status |
| 43 | + out, err := commands.GetNetworkStatus() |
| 44 | + gomega.Expect(err).Should(gomega.BeNil()) |
| 45 | + gomega.Expect(out).Should(gomega.ContainSubstring("Network is Up")) |
| 46 | + gomega.Expect(out).Should(gomega.ContainSubstring(fmt.Sprintf("Number of Nodes: %d", numOfNodes))) |
| 47 | + gomega.Expect(out).Should(gomega.ContainSubstring("Network Healthy: true")) |
| 48 | + gomega.Expect(out).Should(gomega.ContainSubstring("Blockchains Healthy: true")) |
| 49 | + }) |
| 50 | + |
| 51 | + ginkgo.It("should not start network with already started network", func() { |
| 52 | + out := commands.StartNetwork() |
| 53 | + gomega.Expect(out).Should(gomega.ContainSubstring("Network ready to use")) |
| 54 | + |
| 55 | + out = commands.StartNetwork() |
| 56 | + gomega.Expect(out).Should(gomega.ContainSubstring("Network has already been booted")) |
| 57 | + |
| 58 | + out, err := commands.GetNetworkStatus() |
| 59 | + gomega.Expect(err).Should(gomega.BeNil()) |
| 60 | + gomega.Expect(out).Should(gomega.ContainSubstring("Network is Up")) |
| 61 | + }) |
| 62 | +}) |
0 commit comments