Skip to content

Commit 5514b66

Browse files
committed
fixup Move networks to .testnetctl/networks
As per a comment from dasconnor, this supports storing non-network data in the .testnetctl path in the future.
1 parent 91dd7c3 commit 5514b66

File tree

4 files changed

+33
-27
lines changed

4 files changed

+33
-27
lines changed

tests/e2e/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ $ scripts/build_testnetctl.sh
5454
# Start a new network
5555
$ ./build/testnetctl start-network --avalanchego-path=/path/to/avalanchego
5656
...
57-
Started network 1337 @ /home/me/.testnetctl/1337-20230705-213938-1707053131
57+
Started network 1337 @ /home/me/.testnetctl/networks/1337-20230705-213938-1707053131
5858

5959
Configure testnetctl to target this network by default with one of the following statements:
60-
- source /home/me/.testnetctl/1337-20230705-213938-1707053131/network.env
61-
- export TESTNETCTL_NETWORK_DIR=/home/me/.testnetctl/1337-20230705-213938-1707053131
60+
- source /home/me/.testnetctl/networks/1337-20230705-213938-1707053131/network.env
61+
- export TESTNETCTL_NETWORK_DIR=/home/me/.testnetctl/networks/1337-20230705-213938-1707053131
6262

6363
# Start a new test run to use the persistent network
6464
ginkgo -v ./tests/e2e -- \

tests/fixture/testnet/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (c *NetworkConfig) PopulateNetworkConfig(networkID uint32, validatorIDs []i
8080
// - Randomly generate the network id (making sure it isn't a reserved ID)
8181
// - Use only the network id (without a datetime suffix) on the filesystem
8282
// - Support referring to a network by just the id against a default path
83-
// - e.g. ~/.testnetctl/[network id]
83+
// - e.g. ~/.testnetctl/networks/[network id]
8484
networkID = uint32(1337)
8585
}
8686

tests/fixture/testnet/local/README.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ $ scripts/build_testnetctl.sh
4040
# Start a new network
4141
$ ./build/testnetctl start-network --avalanchego-path=/path/to/avalanchego
4242
...
43-
Started network 1337 @ /home/me/.testnetctl/1337-20230705-213938-1707053131
43+
Started network 1337 @ /home/me/.testnetctl/networks/1337-20230705-213938-1707053131
4444

4545
Configure testnetctl to target this network by default with one of the following statements:
46-
- source /home/me/.testnetctl/1337-20230705-213938-1707053131/network.env
47-
- export TESTNETCTL_NETWORK_DIR=/home/me/.testnetctl/1337-20230705-213938-1707053131
46+
- source /home/me/.testnetctl/networks/1337-20230705-213938-1707053131/network.env
47+
- export TESTNETCTL_NETWORK_DIR=/home/me/.testnetctl/networks/1337-20230705-213938-1707053131
4848

4949
# Stop the network
5050
$ ./build/testnetctl stop-network --network-dir=/path/to/network
@@ -121,25 +121,26 @@ A local network relies on configuration written to disk in the following structu
121121

122122
```
123123
HOME
124-
└── .testnetctl // Default parent directory for local networks
125-
└── 1337-20230630-203525-2336789419 // Network path with form [network-id]-[timestamp]
126-
├── NodeID-37E8UK3x2YFsHE3RdALmfWcppcZ1eTuj9 // The id of a node is the name of its data dir
127-
│ ├── chainData
128-
│ │ └── ...
129-
│ ├── config.json // Node flags
130-
│ ├── db
131-
│ │ └── ...
132-
│ ├── logs
133-
│ │ └── ...
134-
│ ├── plugins
135-
│ │ └── ...
136-
│ └── runtime.json // Node runtime state (bootstrap IP, API URI, PID)
137-
├── chains
138-
│ └── C
139-
│ └── cchain_config.json // C-Chain config for all nodes
140-
├── defaults.json // Default flags and configuration for network
141-
├── genesis.json // Genesis for all nodes
142-
└── network.env // Sets network dir env to simplify use of network
124+
└── .testnetctl // Root path for tool
125+
└── networks // Default parent directory for local networks
126+
└── 1337-20230630-203525-2336789419 // Network path with form [network-id]-[timestamp]
127+
├── NodeID-37E8UK3x2YFsHE3RdALmfWcppcZ1eTuj9 // The id of a node is the name of its data dir
128+
│ ├── chainData
129+
│ │ └── ...
130+
│ ├── config.json // Node flags
131+
│ ├── db
132+
│ │ └── ...
133+
│ ├── logs
134+
│ │ └── ...
135+
│ ├── plugins
136+
│ │ └── ...
137+
│ └── runtime.json // Node runtime state (bootstrap IP, API URI, PID)
138+
├── chains
139+
│ └── C
140+
│ └── cchain_config.json // C-Chain config for all nodes
141+
├── defaults.json // Default flags and configuration for network
142+
├── genesis.json // Genesis for all nodes
143+
└── network.env // Sets network dir env to simplify use of network
143144
144145
```
145146

tests/fixture/testnet/local/network.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func GetDefaultRootDir() (string, error) {
2626
if err != nil {
2727
return "", err
2828
}
29-
return filepath.Join(homeDir, ".testnetctl"), nil
29+
return filepath.Join(homeDir, ".testnetctl", "networks"), nil
3030
}
3131

3232
// Defines the configuration required for a local network (i.e. one composed of local processes).
@@ -199,6 +199,11 @@ func (ln *LocalNetwork) Create(rootDir string) error {
199199
}
200200
}
201201

202+
// Ensure the directory exists
203+
if err := os.MkdirAll(rootDir, perms.ReadWriteExecute); err != nil {
204+
return fmt.Errorf("failed to create root network dir: %w", err)
205+
}
206+
202207
// Create the path for the network's configuration. Putting the runtime configuration of a
203208
// local network at a common path enables management of that network without a daemon.
204209
//

0 commit comments

Comments
 (0)