-
Notifications
You must be signed in to change notification settings - Fork 607
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
begin modularizing e2e test in preparation for upgrade
- Loading branch information
Showing
13 changed files
with
525 additions
and
497 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.