Skip to content

Commit

Permalink
e2e: remove unused skipRunValidatorIndexes (#1923)
Browse files Browse the repository at this point in the history
* e2e: remove unused skipRunValidatorIndexes

* remove error log
  • Loading branch information
p0mvn authored Jun 30, 2022
1 parent e2d4911 commit 28fe669
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 48 deletions.
51 changes: 10 additions & 41 deletions tests/e2e/e2e_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,12 @@ type chainConfig struct {
// voting period is number of blocks it takes to deposit, 1.2 seconds per validator to vote on the prop, and a buffer.
votingPeriod float32
// upgrade proposal height for chain.
propHeight int
forkHeight int
// Indexes of the validators to skip from running during initialization.
// This is needed for testing functionality like state-sync where we would
// like to start a node during tests post-initialization.
skipRunValidatorIndexes map[int]struct{}
latestProposalNumber int
latestLockNumber int
meta initialization.ChainMeta
validators []*validatorConfig
propHeight int
forkHeight int
latestProposalNumber int
latestLockNumber int
meta initialization.ChainMeta
validators []*validatorConfig
}

const (
Expand Down Expand Up @@ -271,15 +267,7 @@ func (s *IntegrationTestSuite) TearDownSuite() {

func (s *IntegrationTestSuite) runValidators(chainConfig *chainConfig, portOffset int) {
s.T().Logf("starting %s validator containers...", chainConfig.meta.Id)
for i, val := range chainConfig.validators {
// Skip some validators from running during set up.
// This is needed for testing functionality like
// state-sync where we might want to start some validators during tests.
if _, ok := chainConfig.skipRunValidatorIndexes[i]; ok {
s.T().Logf("skipping %s validator with index %d from running...", val.validator.Name, i)
continue
}

for _, val := range chainConfig.validators {
validatorResource, err := s.containerManager.RunValidatorResource(chainConfig.meta.Id, val.validator.Name, val.validator.ConfigDir)
require.NoError(s.T(), err)
s.T().Logf("started %s validator container: %s", validatorResource.Container.Name[1:], validatorResource.Container.ID)
Expand Down Expand Up @@ -388,8 +376,7 @@ func (s *IntegrationTestSuite) configureChain(chainId string, validatorConfigs [
numVal := float32(len(validatorConfigs))

newChainConfig := chainConfig{
votingPeriod: propDepositBlocks + numVal*propVoteBlocks + propBufferBlocks,
skipRunValidatorIndexes: skipValidatorIndexes,
votingPeriod: propDepositBlocks + numVal*propVoteBlocks + propBufferBlocks,
}

// If upgrade is skipped, we can use the chain initialization logic from
Expand Down Expand Up @@ -470,10 +457,6 @@ func (s *IntegrationTestSuite) upgrade() {
// wait till all chains halt at upgrade height
for _, chainConfig := range s.chainConfigs {
for i := range chainConfig.validators {
if _, ok := chainConfig.skipRunValidatorIndexes[i]; ok {
continue
}

validatorResource, exists := s.containerManager.GetValidatorResource(chainConfig.meta.Id, i)
require.True(s.T(), exists)
containerId := validatorResource.Container.ID
Expand Down Expand Up @@ -505,10 +488,7 @@ func (s *IntegrationTestSuite) upgrade() {

// remove all containers so we can upgrade them to the new version
for _, chainConfig := range s.chainConfigs {
for valIdx, val := range chainConfig.validators {
if _, ok := chainConfig.skipRunValidatorIndexes[valIdx]; ok {
continue
}
for _, val := range chainConfig.validators {
containerName := val.validator.Name
err := s.containerManager.RemoveValidatorResource(chainConfig.meta.Id, containerName)
s.Require().NoError(err)
Expand All @@ -526,10 +506,6 @@ func (s *IntegrationTestSuite) upgradeFork() {
for _, chainConfig := range s.chainConfigs {

for i := range chainConfig.validators {
if _, ok := chainConfig.skipRunValidatorIndexes[i]; ok {
continue
}

validatorResource, exists := s.containerManager.GetValidatorResource(chainConfig.meta.Id, i)
require.True(s.T(), exists)
containerId := validatorResource.Container.ID
Expand Down Expand Up @@ -561,21 +537,14 @@ func (s *IntegrationTestSuite) upgradeContainers(chainConfig *chainConfig, propH
s.containerManager.OsmosisRepository = containers.CurrentBranchOsmoRepository
s.containerManager.OsmosisTag = containers.CurrentBranchOsmoTag

for i, val := range chain.validators {
if _, ok := chainConfig.skipRunValidatorIndexes[i]; ok {
continue
}
for _, val := range chain.validators {
validatorResource, err := s.containerManager.RunValidatorResource(chainConfig.meta.Id, val.validator.Name, val.validator.ConfigDir)
require.NoError(s.T(), err)
s.T().Logf("started %s validator container: %s", validatorResource.Container.Name[1:], validatorResource.Container.ID)
}

// check that we are creating blocks again
for i := range chain.validators {
if _, ok := chainConfig.skipRunValidatorIndexes[i]; ok {
continue
}

validatorResource, exists := s.containerManager.GetValidatorResource(chainConfig.meta.Id, i)
require.True(s.T(), exists)

Expand Down
7 changes: 0 additions & 7 deletions tests/e2e/e2e_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,6 @@ func (s *IntegrationTestSuite) voteProposal(c *chainConfig) {
s.T().Logf("voting yes on proposal for chain-id: %s", c.meta.Id)
cmd := []string{"osmosisd", "tx", "gov", "vote", propStr, "yes", "--from=val", fmt.Sprintf("--chain-id=%s", c.meta.Id), "-b=block", "--yes", "--keyring-backend=test"}
for i := range c.validators {
if _, ok := c.skipRunValidatorIndexes[i]; ok {
continue
}
_, _, err := s.containerManager.ExecCmd(s.T(), c.meta.Id, i, cmd, "code: 0")
s.Require().NoError(err)
validatorResource, exists := s.containerManager.GetValidatorResource(c.meta.Id, i)
Expand Down Expand Up @@ -267,10 +264,6 @@ func (s *IntegrationTestSuite) sendTx(c *chainConfig, validatorIndex int, amount

func (s *IntegrationTestSuite) extractValidatorOperatorAddresses(config *chainConfig) {
for i, val := range config.validators {
if _, ok := config.skipRunValidatorIndexes[i]; ok {
s.T().Logf("skipping %s validator with index %d from running...", val.validator.Name, i)
continue
}
cmd := []string{"osmosisd", "debug", "addr", val.validator.PublicKey}
s.T().Logf("extracting validator operator addresses for chain-id: %s", config.meta.Id)
_, errBuf, err := s.containerManager.ExecCmd(s.T(), config.meta.Id, i, cmd, "")
Expand Down

0 comments on commit 28fe669

Please sign in to comment.