From 3f2d2787a18e344e2f931f3df45ae22be74e84bd Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Wed, 27 Apr 2022 16:11:54 +0000 Subject: [PATCH 01/19] commit for debug --- tests/e2e/chain/chain.go | 25 ++++++++++---- tests/e2e/chain/config.go | 6 ++-- tests/e2e/chain/validator.go | 66 +++++++++++++++++------------------ tests/e2e/chain_init/main.go | 48 ++++++++++++++++++++++++-- tests/e2e/e2e_setup_test.go | 67 +++++++++++++++++++++++++++--------- tests/e2e/e2e_test.go | 8 ++--- tests/e2e/e2e_util_test.go | 8 ++--- 7 files changed, 159 insertions(+), 69 deletions(-) diff --git a/tests/e2e/chain/chain.go b/tests/e2e/chain/chain.go index 0a4e0d3f4f3..a29cb78732b 100644 --- a/tests/e2e/chain/chain.go +++ b/tests/e2e/chain/chain.go @@ -9,20 +9,31 @@ const ( keyringAppName = "testnet" ) +type ChainMeta struct { + DataDir string + Id string +} + type Chain struct { - DataDir string - Id string + ChainMeta ChainMeta Validators []*Validator } func new(id, dataDir string) (*Chain, error) { - return &Chain{ + // return &ChainMeta{ + // Id: id, + // DataDir: dataDir, + // }, nil + chain := &ChainMeta{ Id: id, DataDir: dataDir, + } + return &Chain{ + ChainMeta: *chain, }, nil } -func (c *Chain) configDir() string { +func (c *ChainMeta) configDir() string { return fmt.Sprintf("%s/%s", c.DataDir, c.Id) } @@ -81,8 +92,8 @@ func (c *Chain) createAndInitValidatorsWithMnemonics(count int, mnemonics []stri func (c *Chain) createValidator(index int) *Validator { return &Validator{ - chain: c, - index: index, - moniker: fmt.Sprintf("%s-osmosis-%d", c.Id, index), + ChainMeta: c.ChainMeta, + Index: index, + Moniker: fmt.Sprintf("%s-osmosis-%d", c.ChainMeta.Id, index), } } diff --git a/tests/e2e/chain/config.go b/tests/e2e/chain/config.go index a5abf60041e..a6934aeef24 100644 --- a/tests/e2e/chain/config.go +++ b/tests/e2e/chain/config.go @@ -167,7 +167,7 @@ func initGenesis(c *Chain) error { genTxs := make([]json.RawMessage, len(c.Validators)) for i, val := range c.Validators { stakeAmountCoin := StakeAmountCoinA - if c.Id != ChainAID { + if c.ChainMeta.Id != ChainAID { stakeAmountCoin = StakeAmountCoinB } createValmsg, err := val.buildCreateValidatorMsg(stakeAmountCoin) @@ -225,11 +225,11 @@ func initNodes(c *Chain) error { // initialize a genesis file for the first validator val0ConfigDir := c.Validators[0].ConfigDir() for _, val := range c.Validators { - if c.Id == ChainAID { + if c.ChainMeta.Id == ChainAID { if err := addAccount(val0ConfigDir, "", InitBalanceStrA, val.GetKeyInfo().GetAddress()); err != nil { return err } - } else if c.Id == ChainBID { + } else if c.ChainMeta.Id == ChainBID { if err := addAccount(val0ConfigDir, "", InitBalanceStrB, val.GetKeyInfo().GetAddress()); err != nil { return err } diff --git a/tests/e2e/chain/validator.go b/tests/e2e/chain/validator.go index a494a5d2355..fe2ccd356e0 100644 --- a/tests/e2e/chain/validator.go +++ b/tests/e2e/chain/validator.go @@ -31,43 +31,43 @@ import ( ) type Validator struct { - chain *Chain - index int - moniker string - mnemonic string - keyInfo keyring.Info - privateKey cryptotypes.PrivKey - consensusKey privval.FilePVKey - consensusPrivKey cryptotypes.PrivKey - nodeKey p2p.NodeKey + ChainMeta ChainMeta + Index int + Moniker string + Mnemonic string + KeyInfo keyring.Info + PrivateKey cryptotypes.PrivKey + ConsensusKey privval.FilePVKey + ConsensusPrivKey cryptotypes.PrivKey + NodeKey p2p.NodeKey } func (v *Validator) InstanceName() string { - return fmt.Sprintf("%s%d", v.moniker, v.index) + return fmt.Sprintf("%s%d", v.Moniker, v.Index) } func (v *Validator) ConfigDir() string { - return fmt.Sprintf("%s/%s", v.chain.configDir(), v.InstanceName()) + return fmt.Sprintf("%s/%s", v.ChainMeta.configDir(), v.InstanceName()) } func (v *Validator) GetKeyInfo() keyring.Info { - return v.keyInfo + return v.KeyInfo } func (v *Validator) GetMoniker() string { - return v.moniker + return v.Moniker } func (v *Validator) GetMnemonic() string { - return v.mnemonic + return v.Mnemonic } func (v *Validator) GetIndex() int { - return v.index + return v.Index } func (v *Validator) buildCreateValidatorMsg(amount sdk.Coin) (sdk.Msg, error) { - description := stakingtypes.NewDescription(v.moniker, "", "", "", "") + description := stakingtypes.NewDescription(v.Moniker, "", "", "", "") commissionRates := stakingtypes.CommissionRates{ Rate: sdk.MustNewDecFromStr("0.1"), MaxRate: sdk.MustNewDecFromStr("0.2"), @@ -77,13 +77,13 @@ func (v *Validator) buildCreateValidatorMsg(amount sdk.Coin) (sdk.Msg, error) { // get the initial validator min self delegation minSelfDelegation, _ := sdk.NewIntFromString("1") - valPubKey, err := cryptocodec.FromTmPubKeyInterface(v.consensusKey.PubKey) + valPubKey, err := cryptocodec.FromTmPubKeyInterface(v.ConsensusKey.PubKey) if err != nil { return nil, err } return stakingtypes.NewMsgCreateValidator( - sdk.ValAddress(v.keyInfo.GetAddress()), + sdk.ValAddress(v.KeyInfo.GetAddress()), valPubKey, amount, description, @@ -102,14 +102,14 @@ func (v *Validator) createNodeKey() error { config := serverCtx.Config config.SetRoot(v.ConfigDir()) - config.Moniker = v.moniker + config.Moniker = v.Moniker nodeKey, err := p2p.LoadOrGenNodeKey(config.NodeKeyFile()) if err != nil { return err } - v.nodeKey = *nodeKey + v.NodeKey = *nodeKey return nil } @@ -118,7 +118,7 @@ func (v *Validator) createConsensusKey() error { config := serverCtx.Config config.SetRoot(v.ConfigDir()) - config.Moniker = v.moniker + config.Moniker = v.Moniker pvKeyFile := config.PrivValidatorKeyFile() if err := tmos.EnsureDir(filepath.Dir(pvKeyFile), 0o777); err != nil { @@ -131,7 +131,7 @@ func (v *Validator) createConsensusKey() error { } filePV := privval.LoadOrGenFilePV(pvKeyFile, pvStateFile) - v.consensusKey = filePV.Key + v.ConsensusKey = filePV.Key return nil } @@ -163,9 +163,9 @@ func (v *Validator) createKeyFromMnemonic(name, mnemonic string) error { return err } - v.keyInfo = info - v.mnemonic = mnemonic - v.privateKey = privKey + v.KeyInfo = info + v.Mnemonic = mnemonic + v.PrivateKey = privKey return nil } @@ -180,7 +180,7 @@ func (v *Validator) createKey(name string) error { } func (v *Validator) getNodeKey() *p2p.NodeKey { - return &v.nodeKey + return &v.NodeKey } func (v *Validator) getGenesisDoc() (*tmtypes.GenesisDoc, error) { @@ -216,7 +216,7 @@ func (v *Validator) init() error { config := serverCtx.Config config.SetRoot(v.ConfigDir()) - config.Moniker = v.moniker + config.Moniker = v.Moniker genDoc, err := v.getGenesisDoc() if err != nil { @@ -228,7 +228,7 @@ func (v *Validator) init() error { return fmt.Errorf("failed to JSON encode app genesis state: %w", err) } - genDoc.ChainID = v.chain.Id + genDoc.ChainID = v.ChainMeta.Id genDoc.Validators = nil genDoc.AppState = appState @@ -261,12 +261,12 @@ func (v *Validator) signMsg(msgs ...sdk.Msg) (*sdktx.Tx, error) { return nil, err } - txBuilder.SetMemo(fmt.Sprintf("%s@%s:26656", v.nodeKey.ID(), v.InstanceName())) + txBuilder.SetMemo(fmt.Sprintf("%s@%s:26656", v.NodeKey.ID(), v.InstanceName())) txBuilder.SetFeeAmount(sdk.NewCoins()) txBuilder.SetGasLimit(200000) signerData := authsigning.SignerData{ - ChainID: v.chain.Id, + ChainID: v.ChainMeta.Id, AccountNumber: 0, Sequence: 0, } @@ -280,7 +280,7 @@ func (v *Validator) signMsg(msgs ...sdk.Msg) (*sdktx.Tx, error) { // also doesn't affect its generated sign bytes, so for code's simplicity // sake, we put it here. sig := txsigning.SignatureV2{ - PubKey: v.keyInfo.GetPubKey(), + PubKey: v.KeyInfo.GetPubKey(), Data: &txsigning.SingleSignatureData{ SignMode: txsigning.SignMode_SIGN_MODE_DIRECT, Signature: nil, @@ -301,13 +301,13 @@ func (v *Validator) signMsg(msgs ...sdk.Msg) (*sdktx.Tx, error) { return nil, err } - sigBytes, err := v.privateKey.Sign(bytesToSign) + sigBytes, err := v.PrivateKey.Sign(bytesToSign) if err != nil { return nil, err } sig = txsigning.SignatureV2{ - PubKey: v.keyInfo.GetPubKey(), + PubKey: v.KeyInfo.GetPubKey(), Data: &txsigning.SingleSignatureData{ SignMode: txsigning.SignMode_SIGN_MODE_DIRECT, Signature: sigBytes, diff --git a/tests/e2e/chain_init/main.go b/tests/e2e/chain_init/main.go index edb26b0c199..52cca5eb040 100644 --- a/tests/e2e/chain_init/main.go +++ b/tests/e2e/chain_init/main.go @@ -1,6 +1,7 @@ package main import ( + "encoding/json" "flag" "fmt" "os" @@ -10,7 +11,10 @@ import ( func main() { var dataDir string + var chainId string + var m chain.Chain flag.StringVar(&dataDir, "data-dir", "", "chain data directory") + flag.StringVar(&chainId, "chain-id", "", "chain ID") flag.Parse() if len(dataDir) == 0 { @@ -21,9 +25,49 @@ func main() { panic(err) } - chain, err := chain.Init(chain.ChainAID, dataDir) + chain, err := chain.Init(chainId, dataDir) if err != nil { panic(err) } - fmt.Println(chain) + + // enc := gob.NewEncoder(f) + // if err := enc.Encode(chain); err != nil { + // log.Fatal(err) + // } + + // var b bytes.Buffer + // e := gob.NewEncoder(&b) + // if err := e.Encode(chain); err != nil { + // panic(err) + // } + // fmt.Println("Encoded Struct ", b) + + // fmt.Println(chain) + + // var buf bytes.Buffer + // enc := gob.NewEncoder(&buf) + + // if err := enc.Encode(chain); err != nil { + // log.Fatal(err) + // } + + // fmt.Println(buf.Bytes()) + fmt.Printf("test %+v", chain.Validators[0].KeyInfo) + b, err := json.Marshal(chain) + fmt.Println(b) + fmt.Println(m) + + fileName := fmt.Sprintf("%v/%v-encode", dataDir, chainId) + err2 := os.WriteFile(fileName, b, 0777) + if err2 != nil { + panic(err) + } + encJson, _ := os.ReadFile(fileName) + + err3 := json.Unmarshal(encJson, &m) + fmt.Println(err3) + fmt.Println(m) + fmt.Printf("TEEEEEEEEEST %+v\n", m.Validators[0]) + fmt.Printf("TEEEEEEEEEST %+v\n", m.Validators[1]) + } diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index b3f8988df21..9543814e0e7 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -32,6 +32,7 @@ type IntegrationTestSuite struct { dkrPool *dockertest.Pool dkrNet *dockertest.Network hermesResource *dockertest.Resource + initResource *dockertest.Resource valResources map[string][]*dockertest.Resource } @@ -52,10 +53,11 @@ func (s *IntegrationTestSuite) SetupSuite() { // 2. Start both networks. // 3. Run IBC relayer betweeen the two chains. // 4. Execute various e2e tests, including IBC. + s.configureDockerResources(chain.ChainAID, chain.ChainBID) + s.configureChain(chain.ChainAID) s.configureChain(chain.ChainBID) - - s.configureDockerResources() + s.T().Logf("TESTTESTIJETSETSETSET %v", s.chains[1].Validators[0].GetKeyInfo()) s.runValidators(s.chains[0], 0) s.runValidators(s.chains[1], 10) @@ -85,7 +87,7 @@ func (s *IntegrationTestSuite) TearDownSuite() { s.Require().NoError(s.dkrPool.RemoveNetwork(s.dkrNet)) for _, chain := range s.chains { - os.RemoveAll(chain.DataDir) + os.RemoveAll(chain.ChainMeta.DataDir) } for _, td := range s.tmpDirs { @@ -94,9 +96,9 @@ func (s *IntegrationTestSuite) TearDownSuite() { } func (s *IntegrationTestSuite) runValidators(c *chain.Chain, portOffset int) { - s.T().Logf("starting Osmosis %s validator containers...", c.Id) + s.T().Logf("starting Osmosis %s validator containers...", c.ChainMeta.Id) - s.valResources[c.Id] = make([]*dockertest.Resource, len(c.Validators)) + s.valResources[c.ChainMeta.Id] = make([]*dockertest.Resource, len(c.Validators)) for i, val := range c.Validators { runOpts := &dockertest.RunOptions{ Name: val.InstanceName(), @@ -127,8 +129,8 @@ func (s *IntegrationTestSuite) runValidators(c *chain.Chain, portOffset int) { resource, err := s.dkrPool.RunWithOptions(runOpts, noRestart) s.Require().NoError(err) - s.valResources[c.Id][i] = resource - s.T().Logf("started Osmosis %s validator container: %s", c.Id, resource.Container.ID) + s.valResources[c.ChainMeta.Id][i] = resource + s.T().Logf("started Osmosis %s validator container: %s", c.ChainMeta.Id, resource.Container.ID) } rpcClient, err := rpchttp.New("tcp://localhost:26657", "/websocket") @@ -177,7 +179,7 @@ func (s *IntegrationTestSuite) runIBCRelayer() { s.hermesResource, err = s.dkrPool.RunWithOptions( &dockertest.RunOptions{ - Name: fmt.Sprintf("%s-%s-relayer", s.chains[0].Id, s.chains[1].Id), + Name: fmt.Sprintf("%s-%s-relayer", s.chains[0].ChainMeta.Id, s.chains[1].ChainMeta.Id), Repository: "osmolabs/hermes", Tag: "0.13.0", NetworkID: s.dkrNet.Network.ID, @@ -195,12 +197,12 @@ func (s *IntegrationTestSuite) runIBCRelayer() { "3031/tcp": {{HostIP: "", HostPort: "3031"}}, }, Env: []string{ - fmt.Sprintf("OSMO_A_E2E_CHAIN_ID=%s", s.chains[0].Id), - fmt.Sprintf("OSMO_B_E2E_CHAIN_ID=%s", s.chains[1].Id), + fmt.Sprintf("OSMO_A_E2E_CHAIN_ID=%s", s.chains[0].ChainMeta.Id), + fmt.Sprintf("OSMO_B_E2E_CHAIN_ID=%s", s.chains[1].ChainMeta.Id), fmt.Sprintf("OSMO_A_E2E_VAL_MNEMONIC=%s", osmoAVal.GetMnemonic()), fmt.Sprintf("OSMO_B_E2E_VAL_MNEMONIC=%s", osmoBVal.GetMnemonic()), - fmt.Sprintf("OSMO_A_E2E_VAL_HOST=%s", s.valResources[s.chains[0].Id][0].Container.Name[1:]), - fmt.Sprintf("OSMO_B_E2E_VAL_HOST=%s", s.valResources[s.chains[1].Id][0].Container.Name[1:]), + fmt.Sprintf("OSMO_A_E2E_VAL_HOST=%s", s.valResources[s.chains[0].ChainMeta.Id][0].Container.Name[1:]), + fmt.Sprintf("OSMO_B_E2E_VAL_HOST=%s", s.valResources[s.chains[1].ChainMeta.Id][0].Container.Name[1:]), }, Entrypoint: []string{ "sh", @@ -255,18 +257,51 @@ func (s *IntegrationTestSuite) runIBCRelayer() { func (s *IntegrationTestSuite) configureChain(chainId string) { s.T().Logf("starting e2e infrastructure for chain-id: %s", chainId) tmpDir, err := ioutil.TempDir("", "osmosis-e2e-testnet-") + s.T().Log(tmpDir) s.Require().NoError(err) - newChain, err := chain.Init(chainId, tmpDir) - s.chains = append(s.chains, newChain) + //newChain, err := chain.Init(chainId, tmpDir) + // dataDir := "/temp" + s.initResource, err = s.dkrPool.RunWithOptions( + &dockertest.RunOptions{ + Name: fmt.Sprintf("%s", chainId), + Repository: "osmosis-e2e-chain-init", + Tag: "debug", + NetworkID: s.dkrNet.Network.ID, + Cmd: []string{ + fmt.Sprintf("--data-dir=%s", tmpDir), + fmt.Sprintf("--chain-id=%s", chainId), + }, + User: "root:root", + Mounts: []string{ + fmt.Sprintf("%s:%s", tmpDir, tmpDir), + }, + }, + noRestart, + ) s.Require().NoError(err) + + var newChain chain.Chain + fileName := fmt.Sprintf("%v/%v-encode", tmpDir, chainId) + time.Sleep(8 * time.Second) + s.T().Log(fileName) + encJson, _ := os.ReadFile(fileName) + s.T().Log(encJson) + err3 := json.Unmarshal(encJson, &newChain) + s.T().Log(err3) + s.T().Log(newChain) + fmt.Printf("TEEEEEEEEEST %+v\n", newChain.Validators[0]) + s.chains = append(s.chains, &newChain) + s.T().Logf("%+v", s.chains) + s.T().Log(s.chains[0].Validators[0]) + } -func (s *IntegrationTestSuite) configureDockerResources() { +func (s *IntegrationTestSuite) configureDockerResources(chainIDOne, chainIDTwo string) { var err error s.dkrPool, err = dockertest.NewPool("") s.Require().NoError(err) - s.dkrNet, err = s.dkrPool.CreateNetwork(fmt.Sprintf("%s-%s-testnet", s.chains[0].Id, s.chains[1].Id)) + s.dkrNet, err = s.dkrPool.CreateNetwork(fmt.Sprintf("%s-%s-testnet", chainIDOne, chainIDTwo)) s.Require().NoError(err) s.valResources = make(map[string][]*dockertest.Resource) diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index f00327dc16e..bfd88ef5f45 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -22,13 +22,13 @@ func (s *IntegrationTestSuite) TestQueryBalances() { expectedBalancesB = []uint64{chain.OsmoBalanceB, chain.StakeBalanceB - chain.StakeAmountB, chain.IbcSendAmount} ) - chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chains[0].Id][0].GetHostPort("1317/tcp")) + chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chains[0].ChainMeta.Id][0].GetHostPort("1317/tcp")) balancesA, err := queryBalances(chainAAPIEndpoint, s.chains[0].Validators[0].GetKeyInfo().GetAddress().String()) s.Require().NoError(err) s.Require().NotNil(balancesA) s.Require().Equal(2, len(balancesA)) - chainBAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chains[1].Id][0].GetHostPort("1317/tcp")) + chainBAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chains[1].ChainMeta.Id][0].GetHostPort("1317/tcp")) balancesB, err := queryBalances(chainBAPIEndpoint, s.chains[1].Validators[0].GetKeyInfo().GetAddress().String()) s.Require().NoError(err) s.Require().NotNil(balancesB) @@ -102,9 +102,9 @@ func (s *IntegrationTestSuite) TestIBCTokenTransfer() { s.Run("send_uosmo_to_chainB", func() { recipient := s.chains[1].Validators[0].GetKeyInfo().GetAddress().String() token := sdk.NewInt64Coin(chain.OsmoDenom, chain.IbcSendAmount) // 3,300uosmo - s.sendIBC(s.chains[0].Id, s.chains[1].Id, recipient, token) + s.sendIBC(s.chains[0].ChainMeta.Id, s.chains[1].ChainMeta.Id, recipient, token) - chainBAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chains[1].Id][0].GetHostPort("1317/tcp")) + chainBAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chains[1].ChainMeta.Id][0].GetHostPort("1317/tcp")) // require the recipient account receives the IBC tokens (IBC packets ACKd) var ( diff --git a/tests/e2e/e2e_util_test.go b/tests/e2e/e2e_util_test.go index fb6d7de3727..83976442b76 100644 --- a/tests/e2e/e2e_util_test.go +++ b/tests/e2e/e2e_util_test.go @@ -11,7 +11,7 @@ import ( ) func (s *IntegrationTestSuite) connectIBCChains() { - s.T().Logf("connecting %s and %s chains via IBC", s.chains[0].Id, s.chains[1].Id) + s.T().Logf("connecting %s and %s chains via IBC", s.chains[0].ChainMeta.Id, s.chains[1].ChainMeta.Id) ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() @@ -26,8 +26,8 @@ func (s *IntegrationTestSuite) connectIBCChains() { "hermes", "create", "channel", - s.chains[0].Id, - s.chains[1].Id, + s.chains[0].ChainMeta.Id, + s.chains[1].ChainMeta.Id, "--port-a=transfer", "--port-b=transfer", }, @@ -56,7 +56,7 @@ func (s *IntegrationTestSuite) connectIBCChains() { "failed to connect chains via IBC: %s", errBuf.String(), ) - s.T().Logf("connected %s and %s chains via IBC", s.chains[0].Id, s.chains[1].Id) + s.T().Logf("connected %s and %s chains via IBC", s.chains[0].ChainMeta.Id, s.chains[1].ChainMeta.Id) } func (s *IntegrationTestSuite) sendIBC(srcChainID, dstChainID, recipient string, token sdk.Coin) { From bd2617f3ada7c5021c14052c805cec2b7b42e3d4 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 27 Apr 2022 13:03:47 -0400 Subject: [PATCH 02/19] refactor to only marshal basic types --- tests/e2e/chain/chain.go | 53 ++++++++------- tests/e2e/chain/config.go | 50 +++++++------- tests/e2e/chain/export.go | 25 +++++++ tests/e2e/chain/main.go | 2 +- tests/e2e/chain/validator.go | 122 ++++++++++++++++++----------------- tests/e2e/chain_init/main.go | 22 +++---- tests/e2e/e2e_setup_test.go | 12 ++-- tests/e2e/e2e_test.go | 6 +- 8 files changed, 162 insertions(+), 130 deletions(-) create mode 100644 tests/e2e/chain/export.go diff --git a/tests/e2e/chain/chain.go b/tests/e2e/chain/chain.go index a29cb78732b..64d459ea558 100644 --- a/tests/e2e/chain/chain.go +++ b/tests/e2e/chain/chain.go @@ -9,35 +9,26 @@ const ( keyringAppName = "testnet" ) -type ChainMeta struct { - DataDir string - Id string +type internalChain struct { + chainMeta ChainMeta + validators []*internalValidator } -type Chain struct { - ChainMeta ChainMeta - Validators []*Validator -} - -func new(id, dataDir string) (*Chain, error) { +func new(id, dataDir string) (*internalChain, error) { // return &ChainMeta{ // Id: id, // DataDir: dataDir, // }, nil - chain := &ChainMeta{ + chainMeta := ChainMeta{ Id: id, DataDir: dataDir, } - return &Chain{ - ChainMeta: *chain, + return &internalChain{ + chainMeta: chainMeta, }, nil } -func (c *ChainMeta) configDir() string { - return fmt.Sprintf("%s/%s", c.DataDir, c.Id) -} - -func (c *Chain) createAndInitValidators(count int) error { +func (c *internalChain) createAndInitValidators(count int) error { for i := 0; i < count; i++ { node := c.createValidator(i) @@ -46,7 +37,7 @@ func (c *Chain) createAndInitValidators(count int) error { return err } - c.Validators = append(c.Validators, node) + c.validators = append(c.validators, node) // create keys if err := node.createKey("val"); err != nil { @@ -63,7 +54,7 @@ func (c *Chain) createAndInitValidators(count int) error { return nil } -func (c *Chain) createAndInitValidatorsWithMnemonics(count int, mnemonics []string) error { +func (c *internalChain) createAndInitValidatorsWithMnemonics(count int, mnemonics []string) error { for i := 0; i < count; i++ { // create node node := c.createValidator(i) @@ -73,7 +64,7 @@ func (c *Chain) createAndInitValidatorsWithMnemonics(count int, mnemonics []stri return err } - c.Validators = append(c.Validators, node) + c.validators = append(c.validators, node) // create keys if err := node.createKeyFromMnemonic("val", mnemonics[i]); err != nil { @@ -90,10 +81,22 @@ func (c *Chain) createAndInitValidatorsWithMnemonics(count int, mnemonics []stri return nil } -func (c *Chain) createValidator(index int) *Validator { - return &Validator{ - ChainMeta: c.ChainMeta, - Index: index, - Moniker: fmt.Sprintf("%s-osmosis-%d", c.ChainMeta.Id, index), +func (c *internalChain) createValidator(index int) *internalValidator { + return &internalValidator{ + chain: c, + index: index, + moniker: fmt.Sprintf("%s-osmosis-%d", c.chainMeta.Id, index), + } +} + +func (c *internalChain) export() *Chain { + exportValidators := make([]*Validator, 0, len(c.validators)) + for _, v := range c.validators { + exportValidators = append(exportValidators, v.export()) + } + + return &Chain{ + ChainMeta: c.chainMeta, + Validators: exportValidators, } } diff --git a/tests/e2e/chain/config.go b/tests/e2e/chain/config.go index a6934aeef24..28bc3ba3016 100644 --- a/tests/e2e/chain/config.go +++ b/tests/e2e/chain/config.go @@ -120,12 +120,12 @@ func addAccount(path, moniker, amountStr string, accAddr sdk.AccAddress) error { return genutil.ExportGenesisFile(genDoc, genFile) } -func initGenesis(c *Chain) error { +func initGenesis(c *internalChain) error { serverCtx := server.NewDefaultContext() config := serverCtx.Config - config.SetRoot(c.Validators[0].ConfigDir()) - config.Moniker = c.Validators[0].GetMoniker() + config.SetRoot(c.validators[0].configDir()) + config.Moniker = c.validators[0].getMoniker() genFilePath := config.GenesisFile() appGenState, genDoc, err := genutiltypes.GenesisStateFromGenFile(genFilePath) @@ -164,10 +164,10 @@ func initGenesis(c *Chain) error { } // generate genesis txs - genTxs := make([]json.RawMessage, len(c.Validators)) - for i, val := range c.Validators { + genTxs := make([]json.RawMessage, len(c.validators)) + for i, val := range c.validators { stakeAmountCoin := StakeAmountCoinA - if c.ChainMeta.Id != ChainAID { + if c.chainMeta.Id != ChainAID { stakeAmountCoin = StakeAmountCoinB } createValmsg, err := val.buildCreateValidatorMsg(stakeAmountCoin) @@ -209,38 +209,38 @@ func initGenesis(c *Chain) error { } // write the updated genesis file to each validator - for _, val := range c.Validators { - if err := util.WriteFile(filepath.Join(val.ConfigDir(), "config", "genesis.json"), bz); err != nil { + for _, val := range c.validators { + if err := util.WriteFile(filepath.Join(val.configDir(), "config", "genesis.json"), bz); err != nil { return err } } return nil } -func initNodes(c *Chain) error { +func initNodes(c *internalChain) error { if err := c.createAndInitValidators(2); err != nil { return err } // initialize a genesis file for the first validator - val0ConfigDir := c.Validators[0].ConfigDir() - for _, val := range c.Validators { - if c.ChainMeta.Id == ChainAID { - if err := addAccount(val0ConfigDir, "", InitBalanceStrA, val.GetKeyInfo().GetAddress()); err != nil { + val0ConfigDir := c.validators[0].configDir() + for _, val := range c.validators { + if c.chainMeta.Id == ChainAID { + if err := addAccount(val0ConfigDir, "", InitBalanceStrA, val.getKeyInfo().GetAddress()); err != nil { return err } - } else if c.ChainMeta.Id == ChainBID { - if err := addAccount(val0ConfigDir, "", InitBalanceStrB, val.GetKeyInfo().GetAddress()); err != nil { + } else if c.chainMeta.Id == ChainBID { + if err := addAccount(val0ConfigDir, "", InitBalanceStrB, val.getKeyInfo().GetAddress()); err != nil { return err } } } // copy the genesis file to the remaining validators - for _, val := range c.Validators[1:] { + for _, val := range c.validators[1:] { _, err := util.CopyFile( filepath.Join(val0ConfigDir, "config", "genesis.json"), - filepath.Join(val.ConfigDir(), "config", "genesis.json"), + filepath.Join(val.configDir(), "config", "genesis.json"), ) if err != nil { return err @@ -249,9 +249,9 @@ func initNodes(c *Chain) error { return nil } -func initValidatorConfigs(c *Chain) error { - for i, val := range c.Validators { - tmCfgPath := filepath.Join(val.ConfigDir(), "config", "config.toml") +func initValidatorConfigs(c *internalChain) error { + for i, val := range c.validators { + tmCfgPath := filepath.Join(val.configDir(), "config", "config.toml") vpr := viper.New() vpr.SetConfigFile(tmCfgPath) @@ -266,20 +266,20 @@ func initValidatorConfigs(c *Chain) error { valConfig.P2P.ListenAddress = "tcp://0.0.0.0:26656" valConfig.P2P.AddrBookStrict = false - valConfig.P2P.ExternalAddress = fmt.Sprintf("%s:%d", val.InstanceName(), 26656) + valConfig.P2P.ExternalAddress = fmt.Sprintf("%s:%d", val.instanceName(), 26656) valConfig.RPC.ListenAddress = "tcp://0.0.0.0:26657" valConfig.StateSync.Enable = false valConfig.LogLevel = "info" var peers []string - for j := 0; j < len(c.Validators); j++ { + for j := 0; j < len(c.validators); j++ { if i == j { continue } - peer := c.Validators[j] - peerID := fmt.Sprintf("%s@%s%d:26656", peer.getNodeKey().ID(), peer.GetMoniker(), j) + peer := c.validators[j] + peerID := fmt.Sprintf("%s@%s%d:26656", peer.getNodeKey().ID(), peer.getMoniker(), j) peers = append(peers, peerID) } @@ -288,7 +288,7 @@ func initValidatorConfigs(c *Chain) error { tmconfig.WriteConfigFile(tmCfgPath, valConfig) // set application configuration - appCfgPath := filepath.Join(val.ConfigDir(), "config", "app.toml") + appCfgPath := filepath.Join(val.configDir(), "config", "app.toml") appConfig := srvconfig.DefaultConfig() appConfig.API.Enable = true diff --git a/tests/e2e/chain/export.go b/tests/e2e/chain/export.go new file mode 100644 index 00000000000..d2b7922dbaa --- /dev/null +++ b/tests/e2e/chain/export.go @@ -0,0 +1,25 @@ +package chain + +import "fmt" + +type ChainMeta struct { + DataDir string `json:"dataDir"` + Id string `json:"id"` +} + +type Validator struct { + Name string `json:"name"` + ConfigDir string `json:"configDir"` + Index int `json:"index"` + Mnemonic string `json:"mnemonic"` + PublicAddress string `json:"publicAddress"` +} + +type Chain struct { + ChainMeta ChainMeta `json:"chainMeta"` + Validators []*Validator `json:"validators"` +} + +func (c *ChainMeta) configDir() string { + return fmt.Sprintf("%s/%s", c.DataDir, c.Id) +} diff --git a/tests/e2e/chain/main.go b/tests/e2e/chain/main.go index 20453d7186d..56cfc89b329 100644 --- a/tests/e2e/chain/main.go +++ b/tests/e2e/chain/main.go @@ -14,5 +14,5 @@ func Init(id, dataDir string) (*Chain, error) { if err := initValidatorConfigs(chain); err != nil { return nil, err } - return chain, nil + return chain.export(), nil } diff --git a/tests/e2e/chain/validator.go b/tests/e2e/chain/validator.go index fe2ccd356e0..5f57a71a2bc 100644 --- a/tests/e2e/chain/validator.go +++ b/tests/e2e/chain/validator.go @@ -30,44 +30,40 @@ import ( "github.com/osmosis-labs/osmosis/v7/tests/e2e/util" ) -type Validator struct { - ChainMeta ChainMeta - Index int - Moniker string - Mnemonic string - KeyInfo keyring.Info - PrivateKey cryptotypes.PrivKey - ConsensusKey privval.FilePVKey - ConsensusPrivKey cryptotypes.PrivKey - NodeKey p2p.NodeKey +type internalValidator struct { + chain *internalChain + index int + moniker string + mnemonic string + keyInfo keyring.Info + privateKey cryptotypes.PrivKey + consensusKey privval.FilePVKey + consensusPrivKey cryptotypes.PrivKey + nodeKey p2p.NodeKey } -func (v *Validator) InstanceName() string { - return fmt.Sprintf("%s%d", v.Moniker, v.Index) +func (v *internalValidator) instanceName() string { + return fmt.Sprintf("%s%d", v.moniker, v.index) } -func (v *Validator) ConfigDir() string { - return fmt.Sprintf("%s/%s", v.ChainMeta.configDir(), v.InstanceName()) +func (v *internalValidator) configDir() string { + return fmt.Sprintf("%s/%s", v.chain.chainMeta.configDir(), v.instanceName()) } -func (v *Validator) GetKeyInfo() keyring.Info { - return v.KeyInfo +func (v *internalValidator) getKeyInfo() keyring.Info { + return v.keyInfo } -func (v *Validator) GetMoniker() string { - return v.Moniker +func (v *internalValidator) getMoniker() string { + return v.moniker } -func (v *Validator) GetMnemonic() string { - return v.Mnemonic +func (v *internalValidator) getMnemonic() string { + return v.mnemonic } -func (v *Validator) GetIndex() int { - return v.Index -} - -func (v *Validator) buildCreateValidatorMsg(amount sdk.Coin) (sdk.Msg, error) { - description := stakingtypes.NewDescription(v.Moniker, "", "", "", "") +func (v *internalValidator) buildCreateValidatorMsg(amount sdk.Coin) (sdk.Msg, error) { + description := stakingtypes.NewDescription(v.moniker, "", "", "", "") commissionRates := stakingtypes.CommissionRates{ Rate: sdk.MustNewDecFromStr("0.1"), MaxRate: sdk.MustNewDecFromStr("0.2"), @@ -77,13 +73,13 @@ func (v *Validator) buildCreateValidatorMsg(amount sdk.Coin) (sdk.Msg, error) { // get the initial validator min self delegation minSelfDelegation, _ := sdk.NewIntFromString("1") - valPubKey, err := cryptocodec.FromTmPubKeyInterface(v.ConsensusKey.PubKey) + valPubKey, err := cryptocodec.FromTmPubKeyInterface(v.consensusKey.PubKey) if err != nil { return nil, err } return stakingtypes.NewMsgCreateValidator( - sdk.ValAddress(v.KeyInfo.GetAddress()), + sdk.ValAddress(v.keyInfo.GetAddress()), valPubKey, amount, description, @@ -92,33 +88,33 @@ func (v *Validator) buildCreateValidatorMsg(amount sdk.Coin) (sdk.Msg, error) { ) } -func (v *Validator) createConfig() error { - p := path.Join(v.ConfigDir(), "config") +func (v *internalValidator) createConfig() error { + p := path.Join(v.configDir(), "config") return os.MkdirAll(p, 0o755) } -func (v *Validator) createNodeKey() error { +func (v *internalValidator) createNodeKey() error { serverCtx := server.NewDefaultContext() config := serverCtx.Config - config.SetRoot(v.ConfigDir()) - config.Moniker = v.Moniker + config.SetRoot(v.configDir()) + config.Moniker = v.moniker nodeKey, err := p2p.LoadOrGenNodeKey(config.NodeKeyFile()) if err != nil { return err } - v.NodeKey = *nodeKey + v.nodeKey = *nodeKey return nil } -func (v *Validator) createConsensusKey() error { +func (v *internalValidator) createConsensusKey() error { serverCtx := server.NewDefaultContext() config := serverCtx.Config - config.SetRoot(v.ConfigDir()) - config.Moniker = v.Moniker + config.SetRoot(v.configDir()) + config.Moniker = v.moniker pvKeyFile := config.PrivValidatorKeyFile() if err := tmos.EnsureDir(filepath.Dir(pvKeyFile), 0o777); err != nil { @@ -131,13 +127,13 @@ func (v *Validator) createConsensusKey() error { } filePV := privval.LoadOrGenFilePV(pvKeyFile, pvStateFile) - v.ConsensusKey = filePV.Key + v.consensusKey = filePV.Key return nil } -func (v *Validator) createKeyFromMnemonic(name, mnemonic string) error { - kb, err := keyring.New(keyringAppName, keyring.BackendTest, v.ConfigDir(), nil) +func (v *internalValidator) createKeyFromMnemonic(name, mnemonic string) error { + kb, err := keyring.New(keyringAppName, keyring.BackendTest, v.configDir(), nil) if err != nil { return err } @@ -163,14 +159,14 @@ func (v *Validator) createKeyFromMnemonic(name, mnemonic string) error { return err } - v.KeyInfo = info - v.Mnemonic = mnemonic - v.PrivateKey = privKey + v.keyInfo = info + v.mnemonic = mnemonic + v.privateKey = privKey return nil } -func (v *Validator) createKey(name string) error { +func (v *internalValidator) createKey(name string) error { mnemonic, err := createMnemonic() if err != nil { return err @@ -179,14 +175,24 @@ func (v *Validator) createKey(name string) error { return v.createKeyFromMnemonic(name, mnemonic) } -func (v *Validator) getNodeKey() *p2p.NodeKey { - return &v.NodeKey +func (v *internalValidator) export() *Validator { + return &Validator{ + Name: v.instanceName(), + ConfigDir: v.configDir(), + Index: v.index, + Mnemonic: v.mnemonic, + PublicAddress: v.keyInfo.GetAddress().String(), + } +} + +func (v *internalValidator) getNodeKey() *p2p.NodeKey { + return &v.nodeKey } -func (v *Validator) getGenesisDoc() (*tmtypes.GenesisDoc, error) { +func (v *internalValidator) getGenesisDoc() (*tmtypes.GenesisDoc, error) { serverCtx := server.NewDefaultContext() config := serverCtx.Config - config.SetRoot(v.ConfigDir()) + config.SetRoot(v.configDir()) genFile := config.GenesisFile() doc := &tmtypes.GenesisDoc{} @@ -207,7 +213,7 @@ func (v *Validator) getGenesisDoc() (*tmtypes.GenesisDoc, error) { return doc, nil } -func (v *Validator) init() error { +func (v *internalValidator) init() error { if err := v.createConfig(); err != nil { return err } @@ -215,8 +221,8 @@ func (v *Validator) init() error { serverCtx := server.NewDefaultContext() config := serverCtx.Config - config.SetRoot(v.ConfigDir()) - config.Moniker = v.Moniker + config.SetRoot(v.configDir()) + config.Moniker = v.moniker genDoc, err := v.getGenesisDoc() if err != nil { @@ -228,7 +234,7 @@ func (v *Validator) init() error { return fmt.Errorf("failed to JSON encode app genesis state: %w", err) } - genDoc.ChainID = v.ChainMeta.Id + genDoc.ChainID = v.chain.chainMeta.Id genDoc.Validators = nil genDoc.AppState = appState @@ -254,19 +260,19 @@ func createMnemonic() (string, error) { return mnemonic, nil } -func (v *Validator) signMsg(msgs ...sdk.Msg) (*sdktx.Tx, error) { +func (v *internalValidator) signMsg(msgs ...sdk.Msg) (*sdktx.Tx, error) { txBuilder := util.EncodingConfig.TxConfig.NewTxBuilder() if err := txBuilder.SetMsgs(msgs...); err != nil { return nil, err } - txBuilder.SetMemo(fmt.Sprintf("%s@%s:26656", v.NodeKey.ID(), v.InstanceName())) + txBuilder.SetMemo(fmt.Sprintf("%s@%s:26656", v.nodeKey.ID(), v.instanceName())) txBuilder.SetFeeAmount(sdk.NewCoins()) txBuilder.SetGasLimit(200000) signerData := authsigning.SignerData{ - ChainID: v.ChainMeta.Id, + ChainID: v.chain.chainMeta.Id, AccountNumber: 0, Sequence: 0, } @@ -280,7 +286,7 @@ func (v *Validator) signMsg(msgs ...sdk.Msg) (*sdktx.Tx, error) { // also doesn't affect its generated sign bytes, so for code's simplicity // sake, we put it here. sig := txsigning.SignatureV2{ - PubKey: v.KeyInfo.GetPubKey(), + PubKey: v.keyInfo.GetPubKey(), Data: &txsigning.SingleSignatureData{ SignMode: txsigning.SignMode_SIGN_MODE_DIRECT, Signature: nil, @@ -301,13 +307,13 @@ func (v *Validator) signMsg(msgs ...sdk.Msg) (*sdktx.Tx, error) { return nil, err } - sigBytes, err := v.PrivateKey.Sign(bytesToSign) + sigBytes, err := v.privateKey.Sign(bytesToSign) if err != nil { return nil, err } sig = txsigning.SignatureV2{ - PubKey: v.KeyInfo.GetPubKey(), + PubKey: v.keyInfo.GetPubKey(), Data: &txsigning.SingleSignatureData{ SignMode: txsigning.SignMode_SIGN_MODE_DIRECT, Signature: sigBytes, diff --git a/tests/e2e/chain_init/main.go b/tests/e2e/chain_init/main.go index 52cca5eb040..91b9f8fabe5 100644 --- a/tests/e2e/chain_init/main.go +++ b/tests/e2e/chain_init/main.go @@ -12,7 +12,6 @@ import ( func main() { var dataDir string var chainId string - var m chain.Chain flag.StringVar(&dataDir, "data-dir", "", "chain data directory") flag.StringVar(&chainId, "chain-id", "", "chain ID") flag.Parse() @@ -25,7 +24,7 @@ func main() { panic(err) } - chain, err := chain.Init(chainId, dataDir) + createdChain, err := chain.Init(chainId, dataDir) if err != nil { panic(err) } @@ -52,11 +51,8 @@ func main() { // } // fmt.Println(buf.Bytes()) - fmt.Printf("test %+v", chain.Validators[0].KeyInfo) - b, err := json.Marshal(chain) - fmt.Println(b) - fmt.Println(m) - + fmt.Printf("test %+v", createdChain.Validators[0].PublicAddress) + b, err := json.Marshal(createdChain) fileName := fmt.Sprintf("%v/%v-encode", dataDir, chainId) err2 := os.WriteFile(fileName, b, 0777) if err2 != nil { @@ -64,10 +60,12 @@ func main() { } encJson, _ := os.ReadFile(fileName) - err3 := json.Unmarshal(encJson, &m) - fmt.Println(err3) - fmt.Println(m) - fmt.Printf("TEEEEEEEEEST %+v\n", m.Validators[0]) - fmt.Printf("TEEEEEEEEEST %+v\n", m.Validators[1]) + var newChain chain.Chain + err3 := json.Unmarshal(encJson, &newChain) + if err3 != nil { + fmt.Println(err3) + } + fmt.Printf("TEEEEEEEEEST %+v\n", newChain.Validators[0]) + fmt.Printf("TEEEEEEEEEST %+v\n", newChain.Validators[1]) } diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 9543814e0e7..836eeae5dd7 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -57,7 +57,7 @@ func (s *IntegrationTestSuite) SetupSuite() { s.configureChain(chain.ChainAID) s.configureChain(chain.ChainBID) - s.T().Logf("TESTTESTIJETSETSETSET %v", s.chains[1].Validators[0].GetKeyInfo()) + s.T().Logf("TESTTESTIJETSETSETSET %v", s.chains[1].Validators[0].PublicAddress) s.runValidators(s.chains[0], 0) s.runValidators(s.chains[1], 10) @@ -101,17 +101,17 @@ func (s *IntegrationTestSuite) runValidators(c *chain.Chain, portOffset int) { s.valResources[c.ChainMeta.Id] = make([]*dockertest.Resource, len(c.Validators)) for i, val := range c.Validators { runOpts := &dockertest.RunOptions{ - Name: val.InstanceName(), + Name: val.Name, NetworkID: s.dkrNet.Network.ID, Mounts: []string{ - fmt.Sprintf("%s/:/osmosis/.osmosisd", val.ConfigDir()), + fmt.Sprintf("%s/:/osmosis/.osmosisd", val.ConfigDir), }, Repository: "osmosis", Tag: "debug", } // expose the first validator for debugging and communication - if val.GetIndex() == 0 { + if val.Index == 0 { runOpts.PortBindings = map[docker.Port][]docker.PortBinding{ "1317/tcp": {{HostIP: "", HostPort: fmt.Sprintf("%d", 1317+portOffset)}}, "6060/tcp": {{HostIP: "", HostPort: fmt.Sprintf("%d", 6060+portOffset)}}, @@ -199,8 +199,8 @@ func (s *IntegrationTestSuite) runIBCRelayer() { Env: []string{ fmt.Sprintf("OSMO_A_E2E_CHAIN_ID=%s", s.chains[0].ChainMeta.Id), fmt.Sprintf("OSMO_B_E2E_CHAIN_ID=%s", s.chains[1].ChainMeta.Id), - fmt.Sprintf("OSMO_A_E2E_VAL_MNEMONIC=%s", osmoAVal.GetMnemonic()), - fmt.Sprintf("OSMO_B_E2E_VAL_MNEMONIC=%s", osmoBVal.GetMnemonic()), + fmt.Sprintf("OSMO_A_E2E_VAL_MNEMONIC=%s", osmoAVal.Mnemonic), + fmt.Sprintf("OSMO_B_E2E_VAL_MNEMONIC=%s", osmoBVal.Mnemonic), fmt.Sprintf("OSMO_A_E2E_VAL_HOST=%s", s.valResources[s.chains[0].ChainMeta.Id][0].Container.Name[1:]), fmt.Sprintf("OSMO_B_E2E_VAL_HOST=%s", s.valResources[s.chains[1].ChainMeta.Id][0].Container.Name[1:]), }, diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index bfd88ef5f45..01b98400fce 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -23,13 +23,13 @@ func (s *IntegrationTestSuite) TestQueryBalances() { ) chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chains[0].ChainMeta.Id][0].GetHostPort("1317/tcp")) - balancesA, err := queryBalances(chainAAPIEndpoint, s.chains[0].Validators[0].GetKeyInfo().GetAddress().String()) + balancesA, err := queryBalances(chainAAPIEndpoint, s.chains[0].Validators[0].PublicAddress) s.Require().NoError(err) s.Require().NotNil(balancesA) s.Require().Equal(2, len(balancesA)) chainBAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chains[1].ChainMeta.Id][0].GetHostPort("1317/tcp")) - balancesB, err := queryBalances(chainBAPIEndpoint, s.chains[1].Validators[0].GetKeyInfo().GetAddress().String()) + balancesB, err := queryBalances(chainBAPIEndpoint, s.chains[1].Validators[0].PublicAddress) s.Require().NoError(err) s.Require().NotNil(balancesB) s.Require().Equal(3, len(balancesB)) @@ -100,7 +100,7 @@ func (s *IntegrationTestSuite) TestIBCTokenTransfer() { var ibcStakeDenom string s.Run("send_uosmo_to_chainB", func() { - recipient := s.chains[1].Validators[0].GetKeyInfo().GetAddress().String() + recipient := s.chains[1].Validators[0].PublicAddress token := sdk.NewInt64Coin(chain.OsmoDenom, chain.IbcSendAmount) // 3,300uosmo s.sendIBC(s.chains[0].ChainMeta.Id, s.chains[1].ChainMeta.Id, recipient, token) From aafe7e37f02aff90c6d06cce718a80cce3b2cdbd Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Wed, 27 Apr 2022 19:42:57 +0000 Subject: [PATCH 03/19] external docker init with sleep --- tests/e2e/chain_init/main.go | 33 --------------------------------- tests/e2e/e2e_setup_test.go | 17 +++++++---------- 2 files changed, 7 insertions(+), 43 deletions(-) diff --git a/tests/e2e/chain_init/main.go b/tests/e2e/chain_init/main.go index 91b9f8fabe5..2262208cc11 100644 --- a/tests/e2e/chain_init/main.go +++ b/tests/e2e/chain_init/main.go @@ -29,43 +29,10 @@ func main() { panic(err) } - // enc := gob.NewEncoder(f) - // if err := enc.Encode(chain); err != nil { - // log.Fatal(err) - // } - - // var b bytes.Buffer - // e := gob.NewEncoder(&b) - // if err := e.Encode(chain); err != nil { - // panic(err) - // } - // fmt.Println("Encoded Struct ", b) - - // fmt.Println(chain) - - // var buf bytes.Buffer - // enc := gob.NewEncoder(&buf) - - // if err := enc.Encode(chain); err != nil { - // log.Fatal(err) - // } - - // fmt.Println(buf.Bytes()) - fmt.Printf("test %+v", createdChain.Validators[0].PublicAddress) b, err := json.Marshal(createdChain) fileName := fmt.Sprintf("%v/%v-encode", dataDir, chainId) err2 := os.WriteFile(fileName, b, 0777) if err2 != nil { panic(err) } - encJson, _ := os.ReadFile(fileName) - - var newChain chain.Chain - err3 := json.Unmarshal(encJson, &newChain) - if err3 != nil { - fmt.Println(err3) - } - fmt.Printf("TEEEEEEEEEST %+v\n", newChain.Validators[0]) - fmt.Printf("TEEEEEEEEEST %+v\n", newChain.Validators[1]) - } diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 836eeae5dd7..4878c91d060 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -56,8 +56,9 @@ func (s *IntegrationTestSuite) SetupSuite() { s.configureDockerResources(chain.ChainAID, chain.ChainBID) s.configureChain(chain.ChainAID) + s.Require().NoError(s.dkrPool.Purge(s.initResource)) s.configureChain(chain.ChainBID) - s.T().Logf("TESTTESTIJETSETSETSET %v", s.chains[1].Validators[0].PublicAddress) + s.Require().NoError(s.dkrPool.Purge(s.initResource)) s.runValidators(s.chains[0], 0) s.runValidators(s.chains[1], 10) @@ -259,8 +260,7 @@ func (s *IntegrationTestSuite) configureChain(chainId string) { tmpDir, err := ioutil.TempDir("", "osmosis-e2e-testnet-") s.T().Log(tmpDir) s.Require().NoError(err) - //newChain, err := chain.Init(chainId, tmpDir) - // dataDir := "/temp" + s.initResource, err = s.dkrPool.RunWithOptions( &dockertest.RunOptions{ Name: fmt.Sprintf("%s", chainId), @@ -282,17 +282,14 @@ func (s *IntegrationTestSuite) configureChain(chainId string) { var newChain chain.Chain fileName := fmt.Sprintf("%v/%v-encode", tmpDir, chainId) - time.Sleep(8 * time.Second) s.T().Log(fileName) + time.Sleep(8 * time.Second) encJson, _ := os.ReadFile(fileName) - s.T().Log(encJson) err3 := json.Unmarshal(encJson, &newChain) - s.T().Log(err3) - s.T().Log(newChain) - fmt.Printf("TEEEEEEEEEST %+v\n", newChain.Validators[0]) + if err3 != nil { + panic(err3) + } s.chains = append(s.chains, &newChain) - s.T().Logf("%+v", s.chains) - s.T().Log(s.chains[0].Validators[0]) } From 837c8bd8f2c083e72e6a06a746b87b9fc2de89e7 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Wed, 27 Apr 2022 16:00:45 -0500 Subject: [PATCH 04/19] add make docker-build-e2e-chain-init --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e60197fcfb3..a75e14ab5a3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -87,6 +87,7 @@ jobs: - name: Build Docker Image run: | make docker-build-debug + make docker-build-e2e-chain-init if: env.GIT_DIFF - name: Test E2E run: | From 0e7411a052593f150b46d7aaee39673859c10cf0 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Wed, 27 Apr 2022 21:40:01 +0000 Subject: [PATCH 05/19] change sleep for retry function --- tests/e2e/e2e_setup_test.go | 14 +++++++++++++- tests/e2e/e2e_util_test.go | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 4878c91d060..6a3adbe87b7 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -281,9 +281,21 @@ func (s *IntegrationTestSuite) configureChain(chainId string) { s.Require().NoError(err) var newChain chain.Chain + var dummyChain chain.Chain fileName := fmt.Sprintf("%v/%v-encode", tmpDir, chainId) s.T().Log(fileName) - time.Sleep(8 * time.Second) + + err2 := Do(func(attempt int) (bool, error) { + encJson, _ := os.ReadFile(fileName) + err2 := json.Unmarshal(encJson, &dummyChain) + if err2 != nil { + time.Sleep(1 * time.Second) // wait 1 second + } + return attempt < 5, err2 + }) + if err2 != nil { + panic(err2) + } encJson, _ := os.ReadFile(fileName) err3 := json.Unmarshal(encJson, &newChain) if err3 != nil { diff --git a/tests/e2e/e2e_util_test.go b/tests/e2e/e2e_util_test.go index 83976442b76..902aac313a9 100644 --- a/tests/e2e/e2e_util_test.go +++ b/tests/e2e/e2e_util_test.go @@ -3,6 +3,7 @@ package e2e import ( "bytes" "context" + "errors" "fmt" "time" @@ -106,3 +107,36 @@ func (s *IntegrationTestSuite) sendIBC(srcChainID, dstChainID, recipient string, s.T().Log("successfully sent IBC tokens") } + +// MaxRetries is the maximum number of retries before bailing. +var MaxRetries = 10 + +var errMaxRetriesReached = errors.New("exceeded retry limit") + +// Func represents functions that can be retried. +type Func func(attempt int) (retry bool, err error) + +// Do keeps trying the function until the second argument +// returns false, or no error is returned. +func Do(fn Func) error { + var err error + var cont bool + attempt := 1 + for { + cont, err = fn(attempt) + if !cont || err == nil { + break + } + attempt++ + if attempt > MaxRetries { + return errMaxRetriesReached + } + } + return err +} + +// IsMaxRetries checks whether the error is due to hitting the +// maximum number of retries or not. +func IsMaxRetries(err error) bool { + return err == errMaxRetriesReached +} From 427efd367fbbd6e8f75c945a543a5a7c3a58b32a Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Wed, 27 Apr 2022 23:00:44 +0000 Subject: [PATCH 06/19] basic for loop in place of package --- tests/e2e/e2e_setup_test.go | 23 ++++++++++------------- tests/e2e/e2e_util_test.go | 34 ---------------------------------- 2 files changed, 10 insertions(+), 47 deletions(-) diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 6a3adbe87b7..76c6bce61f7 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -281,25 +281,22 @@ func (s *IntegrationTestSuite) configureChain(chainId string) { s.Require().NoError(err) var newChain chain.Chain - var dummyChain chain.Chain + fileName := fmt.Sprintf("%v/%v-encode", tmpDir, chainId) s.T().Log(fileName) - err2 := Do(func(attempt int) (bool, error) { + attempts := 0 + for i := 0; i < 10; i++ { + attempts += i encJson, _ := os.ReadFile(fileName) - err2 := json.Unmarshal(encJson, &dummyChain) + err2 := json.Unmarshal(encJson, &newChain) if err2 != nil { - time.Sleep(1 * time.Second) // wait 1 second + time.Sleep(1 * time.Second) + } else if err2 != nil && attempts == 10 { + panic(err2) + } else { + break } - return attempt < 5, err2 - }) - if err2 != nil { - panic(err2) - } - encJson, _ := os.ReadFile(fileName) - err3 := json.Unmarshal(encJson, &newChain) - if err3 != nil { - panic(err3) } s.chains = append(s.chains, &newChain) diff --git a/tests/e2e/e2e_util_test.go b/tests/e2e/e2e_util_test.go index 902aac313a9..83976442b76 100644 --- a/tests/e2e/e2e_util_test.go +++ b/tests/e2e/e2e_util_test.go @@ -3,7 +3,6 @@ package e2e import ( "bytes" "context" - "errors" "fmt" "time" @@ -107,36 +106,3 @@ func (s *IntegrationTestSuite) sendIBC(srcChainID, dstChainID, recipient string, s.T().Log("successfully sent IBC tokens") } - -// MaxRetries is the maximum number of retries before bailing. -var MaxRetries = 10 - -var errMaxRetriesReached = errors.New("exceeded retry limit") - -// Func represents functions that can be retried. -type Func func(attempt int) (retry bool, err error) - -// Do keeps trying the function until the second argument -// returns false, or no error is returned. -func Do(fn Func) error { - var err error - var cont bool - attempt := 1 - for { - cont, err = fn(attempt) - if !cont || err == nil { - break - } - attempt++ - if attempt > MaxRetries { - return errMaxRetriesReached - } - } - return err -} - -// IsMaxRetries checks whether the error is due to hitting the -// maximum number of retries or not. -func IsMaxRetries(err error) bool { - return err == errMaxRetriesReached -} From c566de6f5fdd6f1e9485e6f547115cf1c85c3076 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Wed, 27 Apr 2022 23:36:39 +0000 Subject: [PATCH 07/19] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3955c188e4b..8b1ad09c9ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Minor improvements & Bug Fixes +* [#1363](https://github.com/osmosis-labs/osmosis/pull/1363) Switch e2e test setup to create genesis and configs via Dockertest * [#1308](https://github.com/osmosis-labs/osmosis/pull/1308) Make panics inside of epochs no longer chain halt by default. * [#1286](https://github.com/osmosis-labs/osmosis/pull/1286) Fix release build scripts. * [#1203](https://github.com/osmosis-labs/osmosis/pull/1203) cleanup Makefile and ci workflows From 63968d3efcfeadac592d3ebe3fc71be637d3cc5f Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 28 Apr 2022 09:49:32 -0500 Subject: [PATCH 08/19] Update tests/e2e/e2e_setup_test.go Co-authored-by: Roman --- tests/e2e/e2e_setup_test.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 76c6bce61f7..2ac03daf2f3 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -289,13 +289,17 @@ func (s *IntegrationTestSuite) configureChain(chainId string) { for i := 0; i < 10; i++ { attempts += i encJson, _ := os.ReadFile(fileName) - err2 := json.Unmarshal(encJson, &newChain) - if err2 != nil { - time.Sleep(1 * time.Second) - } else if err2 != nil && attempts == 10 { - panic(err2) - } else { - break + err = json.Unmarshal(encJson, &newChain) + if err == nil { + break + } + + if i == 10 { + s.Require().NoError(err) + } + + if i > 0 { + time.Sleep(1 * time.Second) } } s.chains = append(s.chains, &newChain) From 2e716fe8a0533e6ca107c38e131e12934cede954 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 28 Apr 2022 09:51:16 -0500 Subject: [PATCH 09/19] Update tests/e2e/e2e_setup_test.go Co-authored-by: Roman --- tests/e2e/e2e_setup_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 2ac03daf2f3..11ad130353a 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -287,7 +287,6 @@ func (s *IntegrationTestSuite) configureChain(chainId string) { attempts := 0 for i := 0; i < 10; i++ { - attempts += i encJson, _ := os.ReadFile(fileName) err = json.Unmarshal(encJson, &newChain) if err == nil { From 38937912439dd9790a003fe5f1969b8f51063b93 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 28 Apr 2022 09:52:00 -0500 Subject: [PATCH 10/19] Update tests/e2e/e2e_setup_test.go Co-authored-by: Roman --- tests/e2e/e2e_setup_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 11ad130353a..804df06c178 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -285,7 +285,6 @@ func (s *IntegrationTestSuite) configureChain(chainId string) { fileName := fmt.Sprintf("%v/%v-encode", tmpDir, chainId) s.T().Log(fileName) - attempts := 0 for i := 0; i < 10; i++ { encJson, _ := os.ReadFile(fileName) err = json.Unmarshal(encJson, &newChain) From 3c9f74e77653d373863cfad4767cdce828f99a8b Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 28 Apr 2022 10:54:19 -0500 Subject: [PATCH 11/19] Update tests/e2e/chain_init/main.go Co-authored-by: Roman --- tests/e2e/chain_init/main.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/e2e/chain_init/main.go b/tests/e2e/chain_init/main.go index 2262208cc11..d11042d6771 100644 --- a/tests/e2e/chain_init/main.go +++ b/tests/e2e/chain_init/main.go @@ -31,8 +31,7 @@ func main() { b, err := json.Marshal(createdChain) fileName := fmt.Sprintf("%v/%v-encode", dataDir, chainId) - err2 := os.WriteFile(fileName, b, 0777) - if err2 != nil { + if err = os.WriteFile(fileName, b, 0777); err != nil { panic(err) } } From 84b2734dc17806fb393cdf26d4f0af6be166a885 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 28 Apr 2022 16:23:59 +0000 Subject: [PATCH 12/19] roman suggestions --- tests/e2e/chain/chain.go | 4 ---- tests/e2e/e2e_setup_test.go | 18 ++++++++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/tests/e2e/chain/chain.go b/tests/e2e/chain/chain.go index 64d459ea558..a20d4fc5679 100644 --- a/tests/e2e/chain/chain.go +++ b/tests/e2e/chain/chain.go @@ -15,10 +15,6 @@ type internalChain struct { } func new(id, dataDir string) (*internalChain, error) { - // return &ChainMeta{ - // Id: id, - // DataDir: dataDir, - // }, nil chainMeta := ChainMeta{ Id: id, DataDir: dataDir, diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 804df06c178..5ff3eda3204 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -24,6 +24,8 @@ import ( "github.com/osmosis-labs/osmosis/v7/tests/e2e/util" ) +const maxRetries = 10 // max retries for json unmarshalling + type IntegrationTestSuite struct { suite.Suite @@ -258,7 +260,7 @@ func (s *IntegrationTestSuite) runIBCRelayer() { func (s *IntegrationTestSuite) configureChain(chainId string) { s.T().Logf("starting e2e infrastructure for chain-id: %s", chainId) tmpDir, err := ioutil.TempDir("", "osmosis-e2e-testnet-") - s.T().Log(tmpDir) + s.T().Logf("temp directory for chain-id %v: %v", chainId, tmpDir) s.Require().NoError(err) s.initResource, err = s.dkrPool.RunWithOptions( @@ -283,21 +285,21 @@ func (s *IntegrationTestSuite) configureChain(chainId string) { var newChain chain.Chain fileName := fmt.Sprintf("%v/%v-encode", tmpDir, chainId) - s.T().Log(fileName) + s.T().Logf("serialized init file for chain-id %v: %v", chainId, fileName) - for i := 0; i < 10; i++ { + for i := 0; i < maxRetries; i++ { encJson, _ := os.ReadFile(fileName) err = json.Unmarshal(encJson, &newChain) if err == nil { - break + break } - + if i == 10 { - s.Require().NoError(err) + s.Require().NoError(err) } - + if i > 0 { - time.Sleep(1 * time.Second) + time.Sleep(1 * time.Second) } } s.chains = append(s.chains, &newChain) From 790b97e5c1fb131e9edd0326797dd0d4424d36f5 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 28 Apr 2022 16:37:45 +0000 Subject: [PATCH 13/19] add for loop purpose comment --- tests/e2e/e2e_setup_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 5ff3eda3204..927890e6a49 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -287,6 +287,8 @@ func (s *IntegrationTestSuite) configureChain(chainId string) { fileName := fmt.Sprintf("%v/%v-encode", tmpDir, chainId) s.T().Logf("serialized init file for chain-id %v: %v", chainId, fileName) + // loop through the reading and unmarshaling of the init file a total of maxRetries or until error is nil + // without this, test attempts to unmarshal file before docker container is finished writing for i := 0; i < maxRetries; i++ { encJson, _ := os.ReadFile(fileName) err = json.Unmarshal(encJson, &newChain) From 457b5a2a2fabaf0cbf175baae06a905b0098ef5e Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 28 Apr 2022 14:17:00 -0500 Subject: [PATCH 14/19] Update tests/e2e/chain/chain.go Co-authored-by: Dev Ojha --- tests/e2e/chain/chain.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/e2e/chain/chain.go b/tests/e2e/chain/chain.go index a20d4fc5679..a746bcc7440 100644 --- a/tests/e2e/chain/chain.go +++ b/tests/e2e/chain/chain.go @@ -9,6 +9,8 @@ const ( keyringAppName = "testnet" ) +// internalChain contains the same info as chain, but with the validator structs instead using the internal validator +// representation, with more derived data type internalChain struct { chainMeta ChainMeta validators []*internalValidator From b32bea6fa5f406d4cc869f6e8099038ca37f8ffc Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 28 Apr 2022 14:18:55 -0500 Subject: [PATCH 15/19] Update tests/e2e/e2e_setup_test.go Co-authored-by: Aleksandr Bezobchuk --- tests/e2e/e2e_setup_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 927890e6a49..28f746b20b2 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -260,6 +260,7 @@ func (s *IntegrationTestSuite) runIBCRelayer() { func (s *IntegrationTestSuite) configureChain(chainId string) { s.T().Logf("starting e2e infrastructure for chain-id: %s", chainId) tmpDir, err := ioutil.TempDir("", "osmosis-e2e-testnet-") + s.T().Logf("temp directory for chain-id %v: %v", chainId, tmpDir) s.Require().NoError(err) From 36e4933752e1339d7d1931ee3ac17b18bffd69f1 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 28 Apr 2022 19:22:11 +0000 Subject: [PATCH 16/19] group vars --- tests/e2e/chain_init/main.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/e2e/chain_init/main.go b/tests/e2e/chain_init/main.go index d11042d6771..509d40fec08 100644 --- a/tests/e2e/chain_init/main.go +++ b/tests/e2e/chain_init/main.go @@ -10,8 +10,11 @@ import ( ) func main() { - var dataDir string - var chainId string + var ( + dataDir string + chainId string + ) + flag.StringVar(&dataDir, "data-dir", "", "chain data directory") flag.StringVar(&chainId, "chain-id", "", "chain ID") flag.Parse() From e78f5cdbe892fd363c06509274a47204dc9b24f3 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 28 Apr 2022 14:33:44 -0500 Subject: [PATCH 17/19] Update tests/e2e/e2e_setup_test.go Co-authored-by: Dev Ojha --- tests/e2e/e2e_setup_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 28f746b20b2..b566cec8929 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -297,7 +297,7 @@ func (s *IntegrationTestSuite) configureChain(chainId string) { break } - if i == 10 { + if i == maxRetries - 1 { s.Require().NoError(err) } From 9a276d3065583b91464c1d02c5eb600285dfc32c Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 28 Apr 2022 19:39:58 +0000 Subject: [PATCH 18/19] linter fix --- tests/e2e/e2e_setup_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index b566cec8929..7e2ac86197e 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -297,7 +297,7 @@ func (s *IntegrationTestSuite) configureChain(chainId string) { break } - if i == maxRetries - 1 { + if i == maxRetries-1 { s.Require().NoError(err) } From 7d0ca70d64d8868f67a5921938ca48de6c7c4eb7 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 28 Apr 2022 19:52:49 +0000 Subject: [PATCH 19/19] fixed ineff assign err --- tests/e2e/chain_init/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/chain_init/main.go b/tests/e2e/chain_init/main.go index 509d40fec08..12275a56baa 100644 --- a/tests/e2e/chain_init/main.go +++ b/tests/e2e/chain_init/main.go @@ -32,7 +32,7 @@ func main() { panic(err) } - b, err := json.Marshal(createdChain) + b, _ := json.Marshal(createdChain) fileName := fmt.Sprintf("%v/%v-encode", dataDir, chainId) if err = os.WriteFile(fileName, b, 0777); err != nil { panic(err)