@@ -7,8 +7,10 @@ import (
77 "fmt"
88 "strconv"
99
10+ "github.com/ava-labs/avalanche-cli/cmd"
1011 "github.com/ava-labs/avalanche-cli/pkg/constants"
1112 "github.com/ava-labs/avalanche-cli/tests/e2e/commands"
13+ "github.com/ava-labs/avalanche-cli/tests/e2e/utils"
1214 ginkgo "github.com/onsi/ginkgo/v2"
1315 "github.com/onsi/gomega"
1416)
@@ -62,4 +64,125 @@ var _ = ginkgo.Describe("[Local Network] Start", ginkgo.Ordered, func() {
6264 gomega .Expect (err ).Should (gomega .BeNil ())
6365 gomega .Expect (out ).Should (gomega .ContainSubstring ("Network is Up" ))
6466 })
67+
68+ ginkgo .It ("can start stopped network with preserved state - default snapshot" , func () {
69+ // start network with given number of nodes
70+ numOfNodes := uint (5 )
71+ out , err := commands .StartNetworkWithParams (map [string ]interface {}{
72+ "num-nodes" : strconv .FormatUint (uint64 (numOfNodes ), 10 ),
73+ })
74+ gomega .Expect (err ).Should (gomega .BeNil ())
75+ gomega .Expect (out ).Should (gomega .ContainSubstring ("Network ready to use" ))
76+
77+ // check network status - number of nodes
78+ out , err = commands .GetNetworkStatus ()
79+ gomega .Expect (err ).Should (gomega .BeNil ())
80+ gomega .Expect (out ).Should (gomega .ContainSubstring ("Network is Up" ))
81+ gomega .Expect (out ).Should (gomega .ContainSubstring (fmt .Sprintf ("Number of Nodes: %d" , numOfNodes )))
82+
83+ // stop the network
84+ err = commands .StopNetwork ()
85+ gomega .Expect (err ).Should (gomega .BeNil ())
86+
87+ // now start the network again with no arguments
88+ out , err = commands .StartNetwork ()
89+ gomega .Expect (err ).Should (gomega .BeNil ())
90+ gomega .Expect (out ).Should (gomega .ContainSubstring ("Network ready to use" ))
91+
92+ // check network status - number of nodes should be preserved
93+ out , err = commands .GetNetworkStatus ()
94+ gomega .Expect (err ).Should (gomega .BeNil ())
95+ gomega .Expect (out ).Should (gomega .ContainSubstring ("Network is Up" ))
96+ gomega .Expect (out ).Should (gomega .ContainSubstring (fmt .Sprintf ("Number of Nodes: %d" , numOfNodes )))
97+ })
98+
99+ ginkgo .It ("can start properly with given snapshot - custom snapshot" , func () {
100+ // start network with given number of nodes
101+ numOfNodes := uint (5 )
102+ out , err := commands .StartNetworkWithParams (map [string ]interface {}{
103+ "num-nodes" : strconv .FormatUint (uint64 (numOfNodes ), 10 ),
104+ })
105+ gomega .Expect (err ).Should (gomega .BeNil ())
106+ gomega .Expect (out ).Should (gomega .ContainSubstring ("Network ready to use" ))
107+
108+ // stop with snapshot name
109+ testSnapshotName := "test-snapshot"
110+ err = commands .StopNetwork ("--snapshot-name" , testSnapshotName )
111+ gomega .Expect (err ).Should (gomega .BeNil ())
112+
113+ // check snapshot exists
114+ snapshotExists := utils .CheckSnapshotExists (testSnapshotName )
115+ gomega .Expect (snapshotExists ).Should (gomega .BeTrue (),
116+ fmt .Sprintf ("snapshot %s should exist" , testSnapshotName ))
117+
118+ // start the network with snapshot name
119+ out , err = commands .StartNetworkWithParams (map [string ]interface {}{
120+ "snapshot-name" : testSnapshotName ,
121+ })
122+ gomega .Expect (err ).Should (gomega .BeNil ())
123+ gomega .Expect (out ).Should (gomega .ContainSubstring ("Network ready to use" ))
124+
125+ // check network status - number of nodes should be preserved
126+ out , err = commands .GetNetworkStatus ()
127+ gomega .Expect (err ).Should (gomega .BeNil ())
128+ gomega .Expect (out ).Should (gomega .ContainSubstring ("Network is Up" ))
129+ gomega .Expect (out ).Should (gomega .ContainSubstring (fmt .Sprintf ("Number of Nodes: %d" , numOfNodes )))
130+
131+ utils .DeleteSnapshot (testSnapshotName )
132+ })
133+
134+ ginkgo .It ("can start a deployed but stopped L1" , func () {
135+ testSubnetName := "test-subnet-1"
136+ commands .CreateEtnaSubnetEvmConfig (testSubnetName , utils .EwoqEVMAddress , commands .PoA )
137+
138+ // Deploy a local L1
139+ out , err := commands .DeployBlockchain (
140+ testSubnetName ,
141+ utils.TestFlags {
142+ "local" : true ,
143+ "skip-icm-deploy" : true ,
144+ "skip-update-check" : true ,
145+ },
146+ )
147+ gomega .Expect (out ).Should (gomega .ContainSubstring ("L1 is successfully deployed on Local Network" ))
148+ gomega .Expect (err ).Should (gomega .BeNil ())
149+
150+ // stop the network
151+ err = commands .StopNetwork ()
152+ gomega .Expect (err ).Should (gomega .BeNil ())
153+
154+ // now restart the network
155+ out , err = commands .StartNetwork ()
156+ gomega .Expect (err ).Should (gomega .BeNil ())
157+ gomega .Expect (out ).Should (gomega .ContainSubstring ("Network ready to use" ))
158+
159+ // check L1 status - should be back and running
160+ out , err = utils .TestCommand (
161+ cmd .BlockchainCmd ,
162+ "stats" ,
163+ []string {
164+ testSubnetName ,
165+ "--local" ,
166+ "--" + constants .SkipUpdateFlag ,
167+ },
168+ utils.GlobalFlags {},
169+ utils.TestFlags {},
170+ )
171+ gomega .Expect (err ).Should (gomega .BeNil ())
172+ gomega .Expect (out ).Should (gomega .ContainSubstring ("already validating the subnet" ))
173+
174+ commands .DeleteSubnetConfig (testSubnetName )
175+ })
176+
177+ ginkgo .It ("can start with given avalanchego version" , func () {
178+ // subnet config
179+ _ = utils .DeleteConfigs (utils .BlockchainName )
180+ _ , avagoVersion := commands .CreateSubnetEvmConfigSOV (utils .BlockchainName , utils .SubnetEvmGenesisPath )
181+
182+ // local network
183+ _ , err := commands .StartNetworkWithParams (map [string ]interface {}{
184+ "avalanchego-version" : avagoVersion ,
185+ })
186+ gomega .Expect (err ).Should (gomega .BeNil ())
187+ })
65188})
0 commit comments