MCPcopy Create free account
hub / github.com/tendermint/tendermint / LoadTestnet

Function LoadTestnet

test/e2e/pkg/testnet.go:110–293  ·  view source on GitHub ↗

LoadTestnet loads a testnet from a manifest file, using the filename to determine the testnet name and directory (from the basename of the file). The testnet generation must be deterministic, since it is generated separately by the runner and the test cases. For this reason, testnets use a random se

(file string)

Source from the content-addressed store, hash-verified

108// separately by the runner and the test cases. For this reason, testnets use a
109// random seed to generate e.g. keys.
110func LoadTestnet(file string) (*Testnet, error) {
111 manifest, err := LoadManifest(file)
112 if err != nil {
113 return nil, err
114 }
115 dir := strings.TrimSuffix(file, filepath.Ext(file))
116
117 // Set up resource generators. These must be deterministic.
118 netAddress := networkIPv4
119 if manifest.IPv6 {
120 netAddress = networkIPv6
121 }
122 _, ipNet, err := net.ParseCIDR(netAddress)
123 if err != nil {
124 return nil, fmt.Errorf("invalid IP network address %q: %w", netAddress, err)
125 }
126
127 ipGen := newIPGenerator(ipNet)
128 keyGen := newKeyGenerator(randomSeed)
129 proxyPortGen := newPortGenerator(proxyPortFirst)
130
131 testnet := &Testnet{
132 Name: filepath.Base(dir),
133 File: file,
134 Dir: dir,
135 IP: ipGen.Network(),
136 InitialHeight: 1,
137 InitialState: manifest.InitialState,
138 Validators: map[*Node]int64{},
139 ValidatorUpdates: map[int64]map[*Node]int64{},
140 Nodes: []*Node{},
141 Evidence: manifest.Evidence,
142 KeyType: "ed25519",
143 LogLevel: manifest.LogLevel,
144 TxSize: manifest.TxSize,
145 ABCIProtocol: manifest.ABCIProtocol,
146 }
147 if len(manifest.KeyType) != 0 {
148 testnet.KeyType = manifest.KeyType
149 }
150 if testnet.TxSize <= 0 {
151 testnet.TxSize = 1024
152 }
153 if manifest.InitialHeight > 0 {
154 testnet.InitialHeight = manifest.InitialHeight
155 }
156 if testnet.ABCIProtocol == "" {
157 testnet.ABCIProtocol = string(ProtocolBuiltin)
158 }
159
160 // Set up nodes, in alphabetical order (IPs and ports get same order).
161 nodeNames := []string{}
162 for name := range manifest.Nodes {
163 nodeNames = append(nodeNames, name)
164 }
165 sort.Strings(nodeNames)
166
167 for _, name := range nodeNames {

Callers

nothing calls this directly

Calls 13

LookupNodeMethod · 0.95
ValidateMethod · 0.95
LoadManifestFunction · 0.85
newIPGeneratorFunction · 0.85
newKeyGeneratorFunction · 0.85
newPortGeneratorFunction · 0.85
ModeTypeAlias · 0.85
PerturbationTypeAlias · 0.85
NetworkMethod · 0.80
GenerateMethod · 0.80
ProtocolTypeAlias · 0.70
BaseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…