-
Notifications
You must be signed in to change notification settings - Fork 613
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: begin modularizing e2e tests in preparation for upgrade (#1293
) * begin modularizing e2e test in preparation for upgrade * rename common package to util * move chain related constants from util to chain package * fix genesis.go * exctract initNodes into the genesis package * remove genesis package, move all logic to chain * continue cleaning up chain package and refactoring e2e * store chains in a slice * reuse common cdc from util package * lexicographical reorder of functions in config.go of chain package * clean up names
- Loading branch information
Showing
14 changed files
with
672 additions
and
622 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package chain | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
) | ||
|
||
const ( | ||
keyringPassphrase = "testpassphrase" | ||
keyringAppName = "testnet" | ||
) | ||
|
||
type Chain struct { | ||
DataDir string | ||
Id string | ||
Validators []*Validator | ||
} | ||
|
||
func new(id string) (*Chain, error) { | ||
tmpDir, err := ioutil.TempDir("", "osmosis-e2e-testnet-") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &Chain{ | ||
Id: id, | ||
DataDir: tmpDir, | ||
}, nil | ||
} | ||
|
||
func (c *Chain) configDir() string { | ||
return fmt.Sprintf("%s/%s", c.DataDir, c.Id) | ||
} | ||
|
||
func (c *Chain) createAndInitValidators(count int) error { | ||
for i := 0; i < count; i++ { | ||
node := c.createValidator(i) | ||
|
||
// generate genesis files | ||
if err := node.init(); err != nil { | ||
return err | ||
} | ||
|
||
c.Validators = append(c.Validators, node) | ||
|
||
// create keys | ||
if err := node.createKey("val"); err != nil { | ||
return err | ||
} | ||
if err := node.createNodeKey(); err != nil { | ||
return err | ||
} | ||
if err := node.createConsensusKey(); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (c *Chain) createAndInitValidatorsWithMnemonics(count int, mnemonics []string) error { | ||
for i := 0; i < count; i++ { | ||
// create node | ||
node := c.createValidator(i) | ||
|
||
// generate genesis files | ||
if err := node.init(); err != nil { | ||
return err | ||
} | ||
|
||
c.Validators = append(c.Validators, node) | ||
|
||
// create keys | ||
if err := node.createKeyFromMnemonic("val", mnemonics[i]); err != nil { | ||
return err | ||
} | ||
if err := node.createNodeKey(); err != nil { | ||
return err | ||
} | ||
if err := node.createConsensusKey(); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (c *Chain) createValidator(index int) *Validator { | ||
return &Validator{ | ||
chain: c, | ||
index: index, | ||
moniker: fmt.Sprintf("%s-osmosis-%d", c.Id, index), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.