From e2742dca3fba110146f1dfa9245cb607e6244f35 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 5 Jul 2022 15:45:21 -0400 Subject: [PATCH] e2e: refactor initialization with single node logic (#1963) * e2e: refactor initialization with single node logic * lint and remove redundant getters from node * restore accidental change * rename init to InitChain * persistentPeers typo (cherry picked from commit 1da14b8b7946b4f4aec011f1585c37d75078e777) # Conflicts: # tests/e2e/e2e_setup_test.go # tests/e2e/e2e_test.go # tests/e2e/e2e_util_test.go # tests/e2e/initialization/init.go # tests/e2e/initialization/init_test.go # tests/e2e/initialization/node/main.go --- tests/e2e/e2e_setup_test.go | 22 ++++++++++++++++++++++ tests/e2e/e2e_test.go | 9 +++++++++ tests/e2e/e2e_util_test.go | 9 +++++++++ tests/e2e/initialization/init.go | 4 ++++ tests/e2e/initialization/init_test.go | 4 ++++ tests/e2e/initialization/node/main.go | 4 ++++ 6 files changed, 52 insertions(+) diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 4d64a646c71..b49fa62b071 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -422,8 +422,23 @@ func (s *IntegrationTestSuite) configureChain(chainId string, validatorConfigs [ numVal := float32(len(validatorConfigs)) newChainConfig := chainConfig{ +<<<<<<< HEAD votingPeriod: propDepositBlocks + numVal*propVoteBlocks + propBufferBlocks, skipRunValidatorIndexes: skipValidatorIndexes, +======= + votingPeriod: propDepositBlocks + numVal*propVoteBlocks + propBufferBlocks, + } + + // If upgrade is skipped, we can use the chain initialization logic from + // current branch directly. As a result, there is no need to run this + // via Docker. + + if s.skipUpgrade { + initializedChain, err := initialization.InitChain(chainId, tmpDir, validatorConfigs, time.Duration(newChainConfig.votingPeriod), s.forkHeight) + s.Require().NoError(err) + s.initializeChainConfig(&newChainConfig, initializedChain) + return +>>>>>>> 1da14b8b (e2e: refactor initialization with single node logic (#1963)) } votingPeriodDuration := time.Duration(int(newChainConfig.votingPeriod) * 1000000000) @@ -488,8 +503,15 @@ func (s *IntegrationTestSuite) configureDockerResources(chainIDOne, chainIDTwo s s.dkrPool, err = dockertest.NewPool("") s.Require().NoError(err) +<<<<<<< HEAD s.dkrNet, err = s.dkrPool.CreateNetwork(fmt.Sprintf("%s-%s-testnet", chainIDOne, chainIDTwo)) s.Require().NoError(err) +======= + chainConfig.validators = make([]*validatorConfig, 0, len(initializedChain.Nodes)) + for _, val := range initializedChain.Nodes { + chainConfig.validators = append(chainConfig.validators, &validatorConfig{validator: *val}) + } +>>>>>>> 1da14b8b (e2e: refactor initialization with single node logic (#1963)) s.valResources = make(map[string][]*dockertest.Resource) } diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 4e9b7ae013a..b48961733dd 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -17,7 +17,16 @@ func (s *IntegrationTestSuite) TestIBCTokenTransfer() { } func (s *IntegrationTestSuite) TestSuperfluidVoting() { +<<<<<<< HEAD const walletName = "wallet" +======= + if s.skipUpgrade { + // TODO: https://github.com/osmosis-labs/osmosis/issues/1843 + s.T().Skip("Superfluid tests are broken when upgrade is skipped. To be fixed in #1843") + } + const walletName = "superfluid-wallet" + +>>>>>>> 1da14b8b (e2e: refactor initialization with single node logic (#1963)) chainA := s.chainConfigs[0] s.submitSuperfluidProposal(chainA, "gamm/pool/1") s.depositProposal(chainA) diff --git a/tests/e2e/e2e_util_test.go b/tests/e2e/e2e_util_test.go index 6d9f34dc5e6..27d4e42231d 100644 --- a/tests/e2e/e2e_util_test.go +++ b/tests/e2e/e2e_util_test.go @@ -261,9 +261,18 @@ func (s *IntegrationTestSuite) queryPropTally(endpoint, addr string) (sdk.Int, s func (s *IntegrationTestSuite) createPool(c *chainConfig, poolFile string, from string) { s.T().Logf("creating pool for chain-id: %s", c.meta.Id) +<<<<<<< HEAD cmd := []string{"osmosisd", "tx", "gamm", "create-pool", fmt.Sprintf("--pool-file=/osmosis/%s", poolFile), fmt.Sprintf("--chain-id=%s", c.meta.Id), "--from=val", "-b=block", "--yes", "--keyring-backend=test"} s.ExecTx(c.meta.Id, 0, cmd, "code: 0") s.T().Logf("successfully created pool from %s container: %s", s.valResources[c.meta.Id][0].Container.Name[1:], s.valResources[c.meta.Id][0].Container.ID) +======= + cmd := []string{"osmosisd", "tx", "gamm", "create-pool", fmt.Sprintf("--pool-file=/osmosis/%s", poolFile), fmt.Sprintf("--chain-id=%s", c.meta.Id), fmt.Sprintf("--from=%s", from), "-b=block", "--yes", "--keyring-backend=test"} + _, _, err := s.containerManager.ExecCmd(s.T(), c.meta.Id, 0, cmd, "code: 0") + s.Require().NoError(err) + validatorResource, exists := s.containerManager.GetValidatorResource(c.meta.Id, 0) + s.Require().True(exists) + s.T().Logf("successfully created pool from %s container: %s", validatorResource.Container.Name[1:], validatorResource.Container.ID) +>>>>>>> 1da14b8b (e2e: refactor initialization with single node logic (#1963)) } func (s *IntegrationTestSuite) lockTokens(config *chainConfig, i int, tokens string, duration string, from string) { diff --git a/tests/e2e/initialization/init.go b/tests/e2e/initialization/init.go index 427dbdad3a5..592b53e74ae 100644 --- a/tests/e2e/initialization/init.go +++ b/tests/e2e/initialization/init.go @@ -6,7 +6,11 @@ import ( "path/filepath" "time" +<<<<<<< HEAD "github.com/osmosis-labs/osmosis/v10/tests/e2e/util" +======= + "github.com/osmosis-labs/osmosis/v7/tests/e2e/util" +>>>>>>> 1da14b8b (e2e: refactor initialization with single node logic (#1963)) ) func InitChain(id, dataDir string, nodeConfigs []*NodeConfig, votingPeriod time.Duration, forkHeight int) (*Chain, error) { diff --git a/tests/e2e/initialization/init_test.go b/tests/e2e/initialization/init_test.go index e4a8f55d093..2681723bbe9 100644 --- a/tests/e2e/initialization/init_test.go +++ b/tests/e2e/initialization/init_test.go @@ -11,7 +11,11 @@ import ( "github.com/stretchr/testify/require" +<<<<<<< HEAD "github.com/osmosis-labs/osmosis/v10/tests/e2e/initialization" +======= + "github.com/osmosis-labs/osmosis/v7/tests/e2e/initialization" +>>>>>>> 1da14b8b (e2e: refactor initialization with single node logic (#1963)) ) const forkHeight = 10 diff --git a/tests/e2e/initialization/node/main.go b/tests/e2e/initialization/node/main.go index 14ea881783b..b76137e1e96 100644 --- a/tests/e2e/initialization/node/main.go +++ b/tests/e2e/initialization/node/main.go @@ -7,7 +7,11 @@ import ( "strings" "time" +<<<<<<< HEAD "github.com/osmosis-labs/osmosis/v10/tests/e2e/initialization" +======= + "github.com/osmosis-labs/osmosis/v7/tests/e2e/initialization" +>>>>>>> 1da14b8b (e2e: refactor initialization with single node logic (#1963)) ) func main() {