diff --git a/go.mod b/go.mod index 305a0104ef1..0ffe90d1d19 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/cosmos/interchain-security v1.0.1-0.20230522154154-1bb8d39e691a cosmossdk.io/math v1.0.1 github.com/cosmos/go-bip39 v1.0.0 - github.com/cosmos/interchain-security v1.1.1-multiden + github.com/cosmos/interchain-security v1.1.0-multiden github.com/golang/protobuf v1.5.3 github.com/golangci/golangci-lint v1.52.2 github.com/gorilla/mux v1.8.0 diff --git a/tests/e2e/e2e_bypassminfee_test.go b/tests/e2e/e2e_bypassminfee_test.go index cb28b9e5476..0b6dada008f 100644 --- a/tests/e2e/e2e_bypassminfee_test.go +++ b/tests/e2e/e2e_bypassminfee_test.go @@ -1,98 +1,184 @@ package e2e -// // import ( -// "cosmossdk.io/math" -// sdk "github.com/cosmos/cosmos-sdk/types" -// distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" -//) -// +// "time" + +// "cosmossdk.io/math" +// sdk "github.com/cosmos/cosmos-sdk/types" +// distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" +// ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" +// ibcchanneltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types" +// ) + // func (s *IntegrationTestSuite) testBypassMinFeeWithdrawReward(endpoint string) { -// // submit gov prop to change bypass-msg param to MsgWithdrawDelegatorReward -// submitterAddr := s.chainA.validators[0].keyInfo.GetAddress() -// submitter := submitterAddr.String() -// proposalCounter++ -// s.govProposeNewBypassMsgs([]string{sdk.MsgTypeURL(&distributiontypes.MsgWithdrawDelegatorReward{})}, proposalCounter, submitter, standardFees.String()) -// -// paidFeeAmt := math.LegacyMustNewDecFromStr(minGasPrice).Mul(math.LegacyNewDec(gas)).String() -// payee := s.chainA.validators[0].keyInfo.GetAddress() -// -// testCases := []struct { -// name string -// fee string -// changeMaxBypassGasUsage bool -// expErr bool -// }{ -// { -// "bypass-msg with fee in the denom of global fee, pass", -// paidFeeAmt + uatomDenom, -// false, -// false, -// }, -// { -// "bypass-msg with zero coin in the denom of global fee, pass", -// "0" + uatomDenom, -// false, -// false, -// }, -// { -// "bypass-msg with zero coin not in the denom of global fee, pass", -// "0" + photonDenom, -// false, -// false, -// }, -// { -// "bypass-msg with non-zero coin not in the denom of global fee, fail", -// paidFeeAmt + photonDenom, -// false, -// true, -// }, -// { -// "bypass-msg with zero coin in the denom of global fee and maxTotalBypassMinFeeMsgGasUsage set to 1, fail", -// "0" + uatomDenom, -// true, -// true, -// }, -// { -// "bypass-msg with non zero coin in the denom of global fee and maxTotalBypassMinFeeMsgGasUsage set to 1, pass", -// paidFeeAmt + uatomDenom, -// false, -// false, -// }, -// } -// -// for _, tc := range testCases { -// -// if tc.changeMaxBypassGasUsage { -// proposalCounter++ -// // change MaxTotalBypassMinFeeMsgGasUsage through governance proposal from 1_000_0000 to 1 -// s.govProposeNewMaxTotalBypassMinFeeMsgGasUsage(1, proposalCounter, submitter) -// } -// -// // get delegator rewards -// rewards, err := queryDelegatorTotalRewards(endpoint, payee.String()) -// s.Require().NoError(err) -// -// // get delegator stake balance -// oldBalance, err := getSpecificBalance(endpoint, payee.String(), stakeDenom) -// s.Require().NoError(err) -// -// // withdraw rewards -// s.Run(tc.name, func() { -// s.execWithdrawAllRewards(s.chainA, 0, payee.String(), tc.fee, tc.expErr) -// }) -// -// if !tc.expErr { -// // get updated balance -// incrBalance, err := getSpecificBalance(endpoint, payee.String(), stakeDenom) -// s.Require().NoError(err) -// -// // compute sum of old balance and stake token rewards -// oldBalancePlusReward := rewards.GetTotal().Add(sdk.NewDecCoinFromCoin(oldBalance)) -// s.Require().Equal(oldBalancePlusReward[0].Denom, stakeDenom) -// -// // check updated balance got increased by at least oldBalancePlusReward -// s.Require().True(sdk.NewDecCoinFromCoin(incrBalance).IsGTE(oldBalancePlusReward[0])) -// } -// } -//} +// // submit gov prop to change bypass-msg param to MsgWithdrawDelegatorReward +// submitterAddr := s.chainA.validators[0].keyInfo.GetAddress() +// submitter := submitterAddr.String() +// proposalCounter++ +// s.govProposeNewBypassMsgs([]string{sdk.MsgTypeURL(&distributiontypes.MsgWithdrawDelegatorReward{})}, proposalCounter, submitter, standardFees.String()) + +// paidFeeAmt := math.LegacyMustNewDecFromStr(minGasPrice).Mul(math.LegacyNewDec(gas)).String() +// payee := s.chainA.validators[0].keyInfo.GetAddress() + +// testCases := []struct { +// name string +// fee string +// changeMaxBypassGasUsage bool +// expErr bool +// }{ +// { +// "bypass-msg with fee in the denom of global fee, pass", +// paidFeeAmt + uatomDenom, +// false, +// false, +// }, +// { +// "bypass-msg with zero coin in the denom of global fee, pass", +// "0" + uatomDenom, +// false, +// false, +// }, +// { +// "bypass-msg with zero coin not in the denom of global fee, pass", +// "0" + photonDenom, +// false, +// false, +// }, +// { +// "bypass-msg with non-zero coin not in the denom of global fee, fail", +// paidFeeAmt + photonDenom, +// false, +// true, +// }, +// { +// "bypass-msg with zero coin in the denom of global fee and maxTotalBypassMinFeeMsgGasUsage set to 1, fail", +// "0" + uatomDenom, +// true, +// true, +// }, +// { +// "bypass-msg with non zero coin in the denom of global fee and maxTotalBypassMinFeeMsgGasUsage set to 1, pass", +// paidFeeAmt + uatomDenom, +// false, +// false, +// }, +// } + +// for _, tc := range testCases { + +// if tc.changeMaxBypassGasUsage { +// proposalCounter++ +// // change MaxTotalBypassMinFeeMsgGasUsage through governance proposal from 1_000_0000 to 1 +// s.govProposeNewMaxTotalBypassMinFeeMsgGasUsage(1, proposalCounter, submitter) +// } + +// // get delegator rewards +// rewards, err := queryDelegatorTotalRewards(endpoint, payee.String()) +// s.Require().NoError(err) + +// // get delegator stake balance +// oldBalance, err := getSpecificBalance(endpoint, payee.String(), stakeDenom) +// s.Require().NoError(err) + +// // withdraw rewards +// s.Run(tc.name, func() { +// s.execWithdrawAllRewards(s.chainA, 0, payee.String(), tc.fee, tc.expErr) +// }) + +// if !tc.expErr { +// // get updated balance +// incrBalance, err := getSpecificBalance(endpoint, payee.String(), stakeDenom) +// s.Require().NoError(err) + +// // compute sum of old balance and stake token rewards +// oldBalancePlusReward := rewards.GetTotal().Add(sdk.NewDecCoinFromCoin(oldBalance)) +// s.Require().Equal(oldBalancePlusReward[0].Denom, stakeDenom) + +// // check updated balance got increased by at least oldBalancePlusReward +// s.Require().True(sdk.NewDecCoinFromCoin(incrBalance).IsGTE(oldBalancePlusReward[0])) +// } +// } +// } + +// func (s *IntegrationTestSuite) testIBCBypassMsg() { +// // submit gov proposal to change bypass-msg param to +// // ["/ibc.core.channel.v1.MsgRecvPacket", +// // "/ibc.core.channel.v1.MsgAcknowledgement", +// // "/ibc.core.client.v1.MsgUpdateClient"] +// submitterAddr := s.chainA.validators[0].keyInfo.GetAddress() +// submitter := submitterAddr.String() +// proposalCounter++ +// s.govProposeNewBypassMsgs([]string{ +// sdk.MsgTypeURL(&ibcchanneltypes.MsgRecvPacket{}), +// sdk.MsgTypeURL(&ibcchanneltypes.MsgAcknowledgement{}), +// sdk.MsgTypeURL(&ibcclienttypes.MsgUpdateClient{}), +// }, proposalCounter, submitter, standardFees.String()) + +// // use hermes1 to test default ibc bypass-msg +// // +// // test 1: transaction only contains bypass-msgs, pass +// s.testTxContainsOnlyIBCBypassMsg() +// // test 2: test transactions contains both bypass and non-bypass msgs (sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeout{}) +// s.testTxContainsMixBypassNonBypassMsg() +// // test 3: test bypass-msgs exceed the MaxBypassGasUsage +// s.testBypassMsgsExceedMaxBypassGasLimit() + +// // set the default bypass-msg back +// proposalCounter++ +// s.govProposeNewBypassMsgs([]string{ +// sdk.MsgTypeURL(&ibcchanneltypes.MsgRecvPacket{}), +// sdk.MsgTypeURL(&ibcchanneltypes.MsgAcknowledgement{}), +// sdk.MsgTypeURL(&ibcclienttypes.MsgUpdateClient{}), +// sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeout{}), +// sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeoutOnClose{}), +// }, proposalCounter, submitter, standardFees.String()) +// } + +// func (s *IntegrationTestSuite) testTxContainsOnlyIBCBypassMsg() { +// s.T().Logf("testing transaction contains only ibc bypass messages") +// ok := s.hermesTransfer(hermesConfigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1000, 1) +// s.Require().True(ok) + +// scrRelayerBalanceBefore, dstRelayerBalanceBefore := s.queryRelayerWalletsBalances() + +// pass := s.hermesClearPacket(hermesConfigNoGasPrices, s.chainA.id, transferChannel) +// s.Require().True(pass) +// pendingPacketsExist := s.hermesPendingPackets(hermesConfigNoGasPrices, s.chainA.id, transferChannel) +// s.Require().False(pendingPacketsExist) + +// // confirm relayer wallets do not pay fees +// scrRelayerBalanceAfter, dstRelayerBalanceAfter := s.queryRelayerWalletsBalances() +// s.Require().Equal(scrRelayerBalanceBefore.String(), scrRelayerBalanceAfter.String()) +// s.Require().Equal(dstRelayerBalanceBefore.String(), dstRelayerBalanceAfter.String()) +// } + +// func (s *IntegrationTestSuite) testTxContainsMixBypassNonBypassMsg() { +// s.T().Logf("testing transaction contains both bypass and non-bypass messages") +// // hermesTransfer with --timeout-height-offset=1 +// ok := s.hermesTransfer(hermesConfigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1, 1) +// s.Require().True(ok) +// // make sure that the transaction is timeout +// time.Sleep(3 * time.Second) +// pendingPacketsExist := s.hermesPendingPackets(hermesConfigNoGasPrices, s.chainA.id, transferChannel) +// s.Require().True(pendingPacketsExist) + +// pass := s.hermesClearPacket(hermesConfigNoGasPrices, s.chainA.id, transferChannel) +// s.Require().False(pass) +// // clear packets with paying fee, to not influence the next transaction +// pass = s.hermesClearPacket(hermesConfigWithGasPrices, s.chainA.id, transferChannel) +// s.Require().True(pass) +// } + +// func (s *IntegrationTestSuite) testBypassMsgsExceedMaxBypassGasLimit() { +// s.T().Logf("testing bypass messages exceed MaxBypassGasUsage") +// ok := s.hermesTransfer(hermesConfigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1000, 12) +// s.Require().True(ok) +// pass := s.hermesClearPacket(hermesConfigNoGasPrices, s.chainA.id, transferChannel) +// s.Require().False(pass) + +// pendingPacketsExist := s.hermesPendingPackets(hermesConfigNoGasPrices, s.chainA.id, transferChannel) +// s.Require().True(pendingPacketsExist) + +// pass = s.hermesClearPacket(hermesConfigWithGasPrices, s.chainA.id, transferChannel) +// s.Require().True(pass) +// } diff --git a/tests/e2e/e2e_exec_test.go b/tests/e2e/e2e_exec_test.go index 8cb869d0ced..ad16ad437ba 100644 --- a/tests/e2e/e2e_exec_test.go +++ b/tests/e2e/e2e_exec_test.go @@ -1,665 +1,693 @@ package e2e -// // import ( -// "bytes" -// "context" -// "encoding/json" -// "fmt" -// "strconv" -// "strings" -// "time" -// -// "github.com/cosmos/cosmos-sdk/client/flags" -// sdk "github.com/cosmos/cosmos-sdk/types" -// vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" -// banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" -// distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" -// "github.com/cosmos/cosmos-sdk/x/feegrant" -// govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" -// slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" -// stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" -// "github.com/ory/dockertest/v3/docker" -//) -// +// "bytes" +// "context" +// "encoding/json" +// "fmt" +// "strconv" +// "strings" +// "time" + +// "github.com/cosmos/cosmos-sdk/client/flags" +// sdk "github.com/cosmos/cosmos-sdk/types" +// vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" +// banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" +// distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" +// "github.com/cosmos/cosmos-sdk/x/feegrant" +// govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" +// slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" +// stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" +// "github.com/ory/dockertest/v3/docker" +// ) + // const ( -// flagFrom = "from" -// flagHome = "home" -// flagFees = "fees" -// flagGas = "gas" -// flagOutput = "output" -// flagChainID = "chain-id" -// flagSpendLimit = "spend-limit" -// flagGasAdjustment = "gas-adjustment" -// flagFeeAccount = "fee-account" -// flagBroadcastMode = "broadcast-mode" -// flagKeyringBackend = "keyring-backend" -// flagAllowedMessages = "allowed-messages" -//) -// +// flagFrom = "from" +// flagHome = "home" +// flagFees = "fees" +// flagGas = "gas" +// flagOutput = "output" +// flagChainID = "chain-id" +// flagSpendLimit = "spend-limit" +// flagGasAdjustment = "gas-adjustment" +// flagFeeAccount = "fee-account" +// flagBroadcastMode = "broadcast-mode" +// flagKeyringBackend = "keyring-backend" +// flagAllowedMessages = "allowed-messages" +// ) + // type flagOption func(map[string]interface{}) -// -//// withKeyValue add a new flag to command + +// // withKeyValue add a new flag to command // func withKeyValue(key string, value interface{}) flagOption { -// return func(o map[string]interface{}) { -// o[key] = value -// } -//} -// +// return func(o map[string]interface{}) { +// o[key] = value +// } +// } + // func applyOptions(chainID string, options []flagOption) map[string]interface{} { -// opts := map[string]interface{}{ -// flagKeyringBackend: "test", -// flagOutput: "json", -// flagGas: "auto", -// flagFrom: "alice", -// flagBroadcastMode: "sync", -// flagGasAdjustment: "1.5", -// flagChainID: chainID, -// flagHome: gaiaHomePath, -// flagFees: standardFees.String(), -// } -// for _, apply := range options { -// apply(opts) -// } -// return opts -//} -// +// opts := map[string]interface{}{ +// flagKeyringBackend: "test", +// flagOutput: "json", +// flagGas: "auto", +// flagFrom: "alice", +// flagBroadcastMode: "sync", +// flagGasAdjustment: "1.5", +// flagChainID: chainID, +// flagHome: gaiaHomePath, +// flagFees: standardFees.String(), +// } +// for _, apply := range options { +// apply(opts) +// } +// return opts +// } + // func (s *IntegrationTestSuite) execEncode( -// c *chain, -// txPath string, -// opt ...flagOption, +// c *chain, +// txPath string, +// opt ...flagOption, // ) string { -// opts := applyOptions(c.id, opt) -// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) -// defer cancel() -// -// s.T().Logf("%s - Executing gaiad encoding with %v", c.id, txPath) -// gaiaCommand := []string{ -// gaiadBinary, -// txCommand, -// "encode", -// txPath, -// } -// for flag, value := range opts { -// gaiaCommand = append(gaiaCommand, fmt.Sprintf("--%s=%v", flag, value)) -// } -// -// var encoded string -// s.executeGaiaTxCommand(ctx, c, gaiaCommand, 0, func(stdOut []byte, stdErr []byte) bool { -// if stdErr != nil { -// return false -// } -// encoded = strings.TrimSuffix(string(stdOut), "\n") -// return true -// }) -// s.T().Logf("successfully encode with %v", txPath) -// return encoded -//} -// +// opts := applyOptions(c.id, opt) +// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) +// defer cancel() + +// s.T().Logf("%s - Executing gaiad encoding with %v", c.id, txPath) +// gaiaCommand := []string{ +// gaiadBinary, +// txCommand, +// "encode", +// txPath, +// } +// for flag, value := range opts { +// gaiaCommand = append(gaiaCommand, fmt.Sprintf("--%s=%v", flag, value)) +// } + +// var encoded string +// s.executeGaiaTxCommand(ctx, c, gaiaCommand, 0, func(stdOut []byte, stdErr []byte) bool { +// if stdErr != nil { +// return false +// } +// encoded = strings.TrimSuffix(string(stdOut), "\n") +// return true +// }) +// s.T().Logf("successfully encode with %v", txPath) +// return encoded +// } + // func (s *IntegrationTestSuite) execDecode( -// c *chain, -// txPath string, -// opt ...flagOption, +// c *chain, +// txPath string, +// opt ...flagOption, // ) string { -// opts := applyOptions(c.id, opt) -// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) -// defer cancel() -// -// s.T().Logf("%s - Executing gaiad decoding with %v", c.id, txPath) -// gaiaCommand := []string{ -// gaiadBinary, -// txCommand, -// "decode", -// txPath, -// } -// for flag, value := range opts { -// gaiaCommand = append(gaiaCommand, fmt.Sprintf("--%s=%v", flag, value)) -// } -// -// var decoded string -// s.executeGaiaTxCommand(ctx, c, gaiaCommand, 0, func(stdOut []byte, stdErr []byte) bool { -// if stdErr != nil { -// return false -// } -// decoded = strings.TrimSuffix(string(stdOut), "\n") -// return true -// }) -// s.T().Logf("successfully decode %v", txPath) -// return decoded -//} -// +// opts := applyOptions(c.id, opt) +// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) +// defer cancel() + +// s.T().Logf("%s - Executing gaiad decoding with %v", c.id, txPath) +// gaiaCommand := []string{ +// gaiadBinary, +// txCommand, +// "decode", +// txPath, +// } +// for flag, value := range opts { +// gaiaCommand = append(gaiaCommand, fmt.Sprintf("--%s=%v", flag, value)) +// } + +// var decoded string +// s.executeGaiaTxCommand(ctx, c, gaiaCommand, 0, func(stdOut []byte, stdErr []byte) bool { +// if stdErr != nil { +// return false +// } +// decoded = strings.TrimSuffix(string(stdOut), "\n") +// return true +// }) +// s.T().Logf("successfully decode %v", txPath) +// return decoded +// } + // func (s *IntegrationTestSuite) execVestingTx( -// c *chain, -// method string, -// args []string, -// opt ...flagOption, +// c *chain, +// method string, +// args []string, +// opt ...flagOption, // ) { -// opts := applyOptions(c.id, opt) -// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) -// defer cancel() -// -// s.T().Logf("%s - Executing gaiad %s with %v", c.id, method, args) -// gaiaCommand := []string{ -// gaiadBinary, -// txCommand, -// vestingtypes.ModuleName, -// method, -// "-y", -// } -// gaiaCommand = append(gaiaCommand, args...) -// -// for flag, value := range opts { -// gaiaCommand = append(gaiaCommand, fmt.Sprintf("--%s=%v", flag, value)) -// } -// -// s.executeGaiaTxCommand(ctx, c, gaiaCommand, 0, s.defaultExecValidation(c, 0)) -// s.T().Logf("successfully %s with %v", method, args) -//} -// +// opts := applyOptions(c.id, opt) +// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) +// defer cancel() + +// s.T().Logf("%s - Executing gaiad %s with %v", c.id, method, args) +// gaiaCommand := []string{ +// gaiadBinary, +// txCommand, +// vestingtypes.ModuleName, +// method, +// "-y", +// } +// gaiaCommand = append(gaiaCommand, args...) + +// for flag, value := range opts { +// gaiaCommand = append(gaiaCommand, fmt.Sprintf("--%s=%v", flag, value)) +// } + +// s.executeGaiaTxCommand(ctx, c, gaiaCommand, 0, s.defaultExecValidation(c, 0)) +// s.T().Logf("successfully %s with %v", method, args) +// } + // func (s *IntegrationTestSuite) execCreatePeriodicVestingAccount( -// c *chain, -// address, -// jsonPath string, -// opt ...flagOption, +// c *chain, +// address, +// jsonPath string, +// opt ...flagOption, // ) { -// s.T().Logf("Executing gaiad create periodic vesting account %s", c.id) -// s.execVestingTx(c, "create-periodic-vesting-account", []string{address, jsonPath}, opt...) -// s.T().Logf("successfully created periodic vesting account %s with %s", address, jsonPath) -//} -// +// s.T().Logf("Executing gaiad create periodic vesting account %s", c.id) +// s.execVestingTx(c, "create-periodic-vesting-account", []string{address, jsonPath}, opt...) +// s.T().Logf("successfully created periodic vesting account %s with %s", address, jsonPath) +// } + // func (s *IntegrationTestSuite) execUnjail( -// c *chain, -// opt ...flagOption, +// c *chain, +// opt ...flagOption, // ) { -// opts := applyOptions(c.id, opt) -// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) -// defer cancel() -// -// s.T().Logf("Executing gaiad slashing unjail %s with options: %v", c.id, opt) -// gaiaCommand := []string{ -// gaiadBinary, -// txCommand, -// slashingtypes.ModuleName, -// "unjail", -// "-y", -// } -// -// for flag, value := range opts { -// gaiaCommand = append(gaiaCommand, fmt.Sprintf("--%s=%v", flag, value)) -// } -// -// s.executeGaiaTxCommand(ctx, c, gaiaCommand, 0, s.defaultExecValidation(c, 0)) -// s.T().Logf("successfully unjail with options %v", opt) -//} -// +// opts := applyOptions(c.id, opt) +// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) +// defer cancel() + +// s.T().Logf("Executing gaiad slashing unjail %s with options: %v", c.id, opt) +// gaiaCommand := []string{ +// gaiadBinary, +// txCommand, +// slashingtypes.ModuleName, +// "unjail", +// "-y", +// } + +// for flag, value := range opts { +// gaiaCommand = append(gaiaCommand, fmt.Sprintf("--%s=%v", flag, value)) +// } + +// s.executeGaiaTxCommand(ctx, c, gaiaCommand, 0, s.defaultExecValidation(c, 0)) +// s.T().Logf("successfully unjail with options %v", opt) +// } + // func (s *IntegrationTestSuite) execFeeGrant(c *chain, valIdx int, granter, grantee, spendLimit string, opt ...flagOption) { -// opt = append(opt, withKeyValue(flagFrom, granter)) -// opt = append(opt, withKeyValue(flagSpendLimit, spendLimit)) -// opts := applyOptions(c.id, opt) -// -// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) -// defer cancel() -// -// s.T().Logf("granting %s fee from %s on chain %s", grantee, granter, c.id) -// -// gaiaCommand := []string{ -// gaiadBinary, -// txCommand, -// feegrant.ModuleName, -// "grant", -// granter, -// grantee, -// "-y", -// } -// for flag, value := range opts { -// gaiaCommand = append(gaiaCommand, fmt.Sprintf("--%s=%v", flag, value)) -// } -// -// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx)) -//} -// +// opt = append(opt, withKeyValue(flagFrom, granter)) +// opt = append(opt, withKeyValue(flagSpendLimit, spendLimit)) +// opts := applyOptions(c.id, opt) + +// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) +// defer cancel() + +// s.T().Logf("granting %s fee from %s on chain %s", grantee, granter, c.id) + +// gaiaCommand := []string{ +// gaiadBinary, +// txCommand, +// feegrant.ModuleName, +// "grant", +// granter, +// grantee, +// "-y", +// } +// for flag, value := range opts { +// gaiaCommand = append(gaiaCommand, fmt.Sprintf("--%s=%v", flag, value)) +// } + +// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx)) +// } + // func (s *IntegrationTestSuite) execFeeGrantRevoke(c *chain, valIdx int, granter, grantee string, opt ...flagOption) { -// opt = append(opt, withKeyValue(flagFrom, granter)) -// opts := applyOptions(c.id, opt) -// -// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) -// defer cancel() -// -// s.T().Logf("revoking %s fee grant from %s on chain %s", grantee, granter, c.id) -// -// gaiaCommand := []string{ -// gaiadBinary, -// txCommand, -// feegrant.ModuleName, -// "revoke", -// granter, -// grantee, -// "-y", -// } -// for flag, value := range opts { -// gaiaCommand = append(gaiaCommand, fmt.Sprintf("--%s=%v", flag, value)) -// } -// -// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx)) -//} -// +// opt = append(opt, withKeyValue(flagFrom, granter)) +// opts := applyOptions(c.id, opt) + +// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) +// defer cancel() + +// s.T().Logf("revoking %s fee grant from %s on chain %s", grantee, granter, c.id) + +// gaiaCommand := []string{ +// gaiadBinary, +// txCommand, +// feegrant.ModuleName, +// "revoke", +// granter, +// grantee, +// "-y", +// } +// for flag, value := range opts { +// gaiaCommand = append(gaiaCommand, fmt.Sprintf("--%s=%v", flag, value)) +// } + +// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx)) +// } + // func (s *IntegrationTestSuite) execBankSend( -// c *chain, -// valIdx int, -// from, -// to, -// amt, -// fees string, -// expectErr bool, -// opt ...flagOption, +// c *chain, +// valIdx int, +// from, +// to, +// amt, +// fees string, +// expectErr bool, +// opt ...flagOption, // ) { -// // TODO remove the hardcode opt after refactor, all methods should accept custom flags -// opt = append(opt, withKeyValue(flagFees, fees)) -// opt = append(opt, withKeyValue(flagFrom, from)) -// opts := applyOptions(c.id, opt) -// -// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) -// defer cancel() -// -// s.T().Logf("sending %s tokens from %s to %s on chain %s", amt, from, to, c.id) -// -// gaiaCommand := []string{ -// gaiadBinary, -// txCommand, -// banktypes.ModuleName, -// "send", -// from, -// to, -// amt, -// "-y", -// } -// for flag, value := range opts { -// gaiaCommand = append(gaiaCommand, fmt.Sprintf("--%s=%v", flag, value)) -// } -// -// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.expectErrExecValidation(c, valIdx, expectErr)) -//} -// +// // TODO remove the hardcode opt after refactor, all methods should accept custom flags +// opt = append(opt, withKeyValue(flagFees, fees)) +// opt = append(opt, withKeyValue(flagFrom, from)) +// opts := applyOptions(c.id, opt) + +// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) +// defer cancel() + +// s.T().Logf("sending %s tokens from %s to %s on chain %s", amt, from, to, c.id) + +// gaiaCommand := []string{ +// gaiadBinary, +// txCommand, +// banktypes.ModuleName, +// "send", +// from, +// to, +// amt, +// "-y", +// } +// for flag, value := range opts { +// gaiaCommand = append(gaiaCommand, fmt.Sprintf("--%s=%v", flag, value)) +// } + +// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.expectErrExecValidation(c, valIdx, expectErr)) +// } + // type txBankSend struct { -// from string -// to string -// amt string -// fees string -// log string -// expectErr bool -//} -// +// from string +// to string +// amt string +// fees string +// log string +// expectErr bool +// } + // func (s *IntegrationTestSuite) execBankSendBatch( -// c *chain, -// valIdx int, //nolint:unparam -// txs ...txBankSend, +// c *chain, +// valIdx int, //nolint:unparam +// txs ...txBankSend, // ) int { -// sucessBankSendCount := 0 -// -// for i := range txs { -// s.T().Logf(txs[i].log) -// -// s.execBankSend(c, valIdx, txs[i].from, txs[i].to, txs[i].amt, txs[i].fees, txs[i].expectErr) -// if !txs[i].expectErr { -// if !txs[i].expectErr { -// sucessBankSendCount++ -// } -// } -// } -// -// return sucessBankSendCount -//} -// +// sucessBankSendCount := 0 + +// for i := range txs { +// s.T().Logf(txs[i].log) + +// s.execBankSend(c, valIdx, txs[i].from, txs[i].to, txs[i].amt, txs[i].fees, txs[i].expectErr) +// if !txs[i].expectErr { +// if !txs[i].expectErr { +// sucessBankSendCount++ +// } +// } +// } + +// return sucessBankSendCount +// } + // func (s *IntegrationTestSuite) execWithdrawAllRewards(c *chain, valIdx int, payee, fees string, expectErr bool) { -// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) -// defer cancel() -// -// gaiaCommand := []string{ -// gaiadBinary, -// txCommand, -// distributiontypes.ModuleName, -// "withdraw-all-rewards", -// fmt.Sprintf("--%s=%s", flags.FlagFrom, payee), -// fmt.Sprintf("--%s=%s", flags.FlagGasPrices, fees), -// fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id), -// "--keyring-backend=test", -// "--output=json", -// "-y", -// } -// -// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.expectErrExecValidation(c, valIdx, expectErr)) -//} -// +// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) +// defer cancel() + +// gaiaCommand := []string{ +// gaiadBinary, +// txCommand, +// distributiontypes.ModuleName, +// "withdraw-all-rewards", +// fmt.Sprintf("--%s=%s", flags.FlagFrom, payee), +// fmt.Sprintf("--%s=%s", flags.FlagGasPrices, fees), +// fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id), +// "--keyring-backend=test", +// "--output=json", +// "-y", +// } + +// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.expectErrExecValidation(c, valIdx, expectErr)) +// } + // func (s *IntegrationTestSuite) execDistributionFundCommunityPool(c *chain, valIdx int, from, amt, fees string) { -// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) -// defer cancel() -// -// s.T().Logf("Executing gaiad tx distribution fund-community-pool on chain %s", c.id) -// -// gaiaCommand := []string{ -// gaiadBinary, -// txCommand, -// distributiontypes.ModuleName, -// "fund-community-pool", -// amt, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id), -// fmt.Sprintf("--%s=%s", flags.FlagFees, fees), -// "--keyring-backend=test", -// "--output=json", -// "-y", -// } -// -// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx)) -// s.T().Logf("Successfully funded community pool") -//} -// +// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) +// defer cancel() + +// s.T().Logf("Executing gaiad tx distribution fund-community-pool on chain %s", c.id) + +// gaiaCommand := []string{ +// gaiadBinary, +// txCommand, +// distributiontypes.ModuleName, +// "fund-community-pool", +// amt, +// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), +// fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id), +// fmt.Sprintf("--%s=%s", flags.FlagFees, fees), +// "--keyring-backend=test", +// "--output=json", +// "-y", +// } + +// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx)) +// s.T().Logf("Successfully funded community pool") +// } + // func (s *IntegrationTestSuite) runGovExec(c *chain, valIdx int, submitterAddr, govCommand string, proposalFlags []string, fees string) { -// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) -// defer cancel() -// -// gaiaCommand := []string{ -// gaiadBinary, -// txCommand, -// govtypes.ModuleName, -// govCommand, -// } -// -// generalFlags := []string{ -// fmt.Sprintf("--%s=%s", flags.FlagFrom, submitterAddr), -// fmt.Sprintf("--%s=%s", flags.FlagGas, "300000"), // default 200000 isn't enough -// fmt.Sprintf("--%s=%s", flags.FlagGasPrices, fees), -// fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id), -// "--keyring-backend=test", -// "--output=json", -// "-y", -// } -// -// gaiaCommand = concatFlags(gaiaCommand, proposalFlags, generalFlags) -// -// s.T().Logf("Executing gaiad tx gov %s on chain %s", govCommand, c.id) -// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx)) -// s.T().Logf("Successfully executed %s", govCommand) -//} -// +// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) +// defer cancel() + +// gaiaCommand := []string{ +// gaiadBinary, +// txCommand, +// govtypes.ModuleName, +// govCommand, +// } + +// generalFlags := []string{ +// fmt.Sprintf("--%s=%s", flags.FlagFrom, submitterAddr), +// fmt.Sprintf("--%s=%s", flags.FlagGas, "300000"), // default 200000 isn't enough +// fmt.Sprintf("--%s=%s", flags.FlagGasPrices, fees), +// fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id), +// "--keyring-backend=test", +// "--output=json", +// "-y", +// } + +// gaiaCommand = concatFlags(gaiaCommand, proposalFlags, generalFlags) + +// s.T().Logf("Executing gaiad tx gov %s on chain %s", govCommand, c.id) +// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx)) +// s.T().Logf("Successfully executed %s", govCommand) +// } + // func (s *IntegrationTestSuite) executeGKeysAddCommand(c *chain, valIdx int, name string, home string) string { -// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) -// defer cancel() -// -// gaiaCommand := []string{ -// gaiadBinary, -// keysCommand, -// "add", -// name, -// fmt.Sprintf("--%s=%s", flags.FlagHome, home), -// "--keyring-backend=test", -// "--output=json", -// } -// -// var addrRecord AddressResponse -// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, func(stdOut []byte, stdErr []byte) bool { -// // Gaiad keys add by default returns payload to stdErr -// if err := json.Unmarshal(stdErr, &addrRecord); err != nil { -// return false -// } -// return strings.Contains(addrRecord.Address, "cosmos") -// }) -// return addrRecord.Address -//} -// +// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) +// defer cancel() + +// gaiaCommand := []string{ +// gaiadBinary, +// keysCommand, +// "add", +// name, +// fmt.Sprintf("--%s=%s", flags.FlagHome, home), +// "--keyring-backend=test", +// "--output=json", +// } + +// var addrRecord AddressResponse +// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, func(stdOut []byte, stdErr []byte) bool { +// // Gaiad keys add by default returns payload to stdErr +// if err := json.Unmarshal(stdErr, &addrRecord); err != nil { +// return false +// } +// return strings.Contains(addrRecord.Address, "cosmos") +// }) +// return addrRecord.Address +// } + // func (s *IntegrationTestSuite) executeKeysList(c *chain, valIdx int, home string) { -// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) -// defer cancel() -// -// gaiaCommand := []string{ -// gaiadBinary, -// keysCommand, -// "list", -// "--keyring-backend=test", -// fmt.Sprintf("--%s=%s", flags.FlagHome, home), -// "--output=json", -// } -// -// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, func([]byte, []byte) bool { -// return true -// }) -//} -// +// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) +// defer cancel() + +// gaiaCommand := []string{ +// gaiadBinary, +// keysCommand, +// "list", +// "--keyring-backend=test", +// fmt.Sprintf("--%s=%s", flags.FlagHome, home), +// "--output=json", +// } + +// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, func([]byte, []byte) bool { +// return true +// }) +// } + // func (s *IntegrationTestSuite) executeDelegate(c *chain, valIdx int, amount, valOperAddress, delegatorAddr, home, delegateFees string) { //nolint:unparam -// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) -// defer cancel() -// -// s.T().Logf("Executing gaiad tx staking delegate %s", c.id) -// -// gaiaCommand := []string{ -// gaiadBinary, -// txCommand, -// stakingtypes.ModuleName, -// "delegate", -// valOperAddress, -// amount, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, delegatorAddr), -// fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id), -// fmt.Sprintf("--%s=%s", flags.FlagGasPrices, delegateFees), -// "--keyring-backend=test", -// fmt.Sprintf("--%s=%s", flags.FlagHome, home), -// "--output=json", -// "-y", -// } -// -// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx)) -// s.T().Logf("%s successfully delegated %s to %s", delegatorAddr, amount, valOperAddress) -//} -// +// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) +// defer cancel() + +// s.T().Logf("Executing gaiad tx staking delegate %s", c.id) + +// gaiaCommand := []string{ +// gaiadBinary, +// txCommand, +// stakingtypes.ModuleName, +// "delegate", +// valOperAddress, +// amount, +// fmt.Sprintf("--%s=%s", flags.FlagFrom, delegatorAddr), +// fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id), +// fmt.Sprintf("--%s=%s", flags.FlagGasPrices, delegateFees), +// "--keyring-backend=test", +// fmt.Sprintf("--%s=%s", flags.FlagHome, home), +// "--output=json", +// "-y", +// } + +// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx)) +// s.T().Logf("%s successfully delegated %s to %s", delegatorAddr, amount, valOperAddress) +// } + // func (s *IntegrationTestSuite) executeRedelegate(c *chain, valIdx int, amount, originalValOperAddress, -// newValOperAddress, delegatorAddr, home, delegateFees string, +// newValOperAddress, delegatorAddr, home, delegateFees string, // ) { -// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) -// defer cancel() -// -// s.T().Logf("Executing gaiad tx staking redelegate %s", c.id) -// -// gaiaCommand := []string{ -// gaiadBinary, -// txCommand, -// stakingtypes.ModuleName, -// "redelegate", -// originalValOperAddress, -// newValOperAddress, -// amount, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, delegatorAddr), -// fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id), -// fmt.Sprintf("--%s=%s", flags.FlagGas, "300000"), // default 200000 isn't enough -// fmt.Sprintf("--%s=%s", flags.FlagGasPrices, delegateFees), -// "--keyring-backend=test", -// fmt.Sprintf("--%s=%s", flags.FlagHome, home), -// "--output=json", -// "-y", -// } -// -// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx)) -// s.T().Logf("%s successfully redelegated %s from %s to %s", delegatorAddr, amount, originalValOperAddress, newValOperAddress) -//} -// +// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) +// defer cancel() + +// s.T().Logf("Executing gaiad tx staking redelegate %s", c.id) + +// gaiaCommand := []string{ +// gaiadBinary, +// txCommand, +// stakingtypes.ModuleName, +// "redelegate", +// originalValOperAddress, +// newValOperAddress, +// amount, +// fmt.Sprintf("--%s=%s", flags.FlagFrom, delegatorAddr), +// fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id), +// fmt.Sprintf("--%s=%s", flags.FlagGas, "300000"), // default 200000 isn't enough +// fmt.Sprintf("--%s=%s", flags.FlagGasPrices, delegateFees), +// "--keyring-backend=test", +// fmt.Sprintf("--%s=%s", flags.FlagHome, home), +// "--output=json", +// "-y", +// } + +// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx)) +// s.T().Logf("%s successfully redelegated %s from %s to %s", delegatorAddr, amount, originalValOperAddress, newValOperAddress) +// } + // func (s *IntegrationTestSuite) getLatestBlockHeight(c *chain, valIdx int) int { -// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) -// defer cancel() -// -// type syncInfo struct { -// SyncInfo struct { -// LatestHeight string `json:"latest_block_height"` -// } `json:"SyncInfo"` -// } -// -// var currentHeight int -// gaiaCommand := []string{gaiadBinary, "status"} -// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, func(stdOut []byte, stdErr []byte) bool { -// var ( -// err error -// block syncInfo -// ) -// s.Require().NoError(json.Unmarshal(stdErr, &block)) -// currentHeight, err = strconv.Atoi(block.SyncInfo.LatestHeight) -// s.Require().NoError(err) -// return currentHeight > 0 -// }) -// return currentHeight -//} -// +// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) +// defer cancel() + +// type syncInfo struct { +// SyncInfo struct { +// LatestHeight string `json:"latest_block_height"` +// } `json:"SyncInfo"` +// } + +// var currentHeight int +// gaiaCommand := []string{gaiadBinary, "status"} +// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, func(stdOut []byte, stdErr []byte) bool { +// var ( +// err error +// block syncInfo +// ) +// s.Require().NoError(json.Unmarshal(stdErr, &block)) +// currentHeight, err = strconv.Atoi(block.SyncInfo.LatestHeight) +// s.Require().NoError(err) +// return currentHeight > 0 +// }) +// return currentHeight +// } + // func (s *IntegrationTestSuite) verifyBalanceChange(endpoint string, expectedAmount sdk.Coin, recipientAddress string) { -// s.Require().Eventually( -// func() bool { -// afterAtomBalance, err := getSpecificBalance(endpoint, recipientAddress, uatomDenom) -// s.Require().NoError(err) -// -// return afterAtomBalance.IsEqual(expectedAmount) -// }, -// 20*time.Second, -// 5*time.Second, -// ) -//} -// +// s.Require().Eventually( +// func() bool { +// afterAtomBalance, err := getSpecificBalance(endpoint, recipientAddress, uatomDenom) +// s.Require().NoError(err) + +// return afterAtomBalance.IsEqual(expectedAmount) +// }, +// 20*time.Second, +// 5*time.Second, +// ) +// } + // func (s *IntegrationTestSuite) execSetWithdrawAddress( -// c *chain, -// valIdx int, -// fees, -// delegatorAddress, -// newWithdrawalAddress, -// homePath string, +// c *chain, +// valIdx int, +// fees, +// delegatorAddress, +// newWithdrawalAddress, +// homePath string, // ) { -// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) -// defer cancel() -// -// s.T().Logf("Setting distribution withdrawal address on chain %s for %s to %s", c.id, delegatorAddress, newWithdrawalAddress) -// gaiaCommand := []string{ -// gaiadBinary, -// txCommand, -// distributiontypes.ModuleName, -// "set-withdraw-addr", -// newWithdrawalAddress, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, delegatorAddress), -// fmt.Sprintf("--%s=%s", flags.FlagFees, fees), -// fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id), -// fmt.Sprintf("--%s=%s", flags.FlagHome, homePath), -// "--keyring-backend=test", -// "--output=json", -// "-y", -// } -// -// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx)) -// s.T().Logf("Successfully set new distribution withdrawal address for %s to %s", delegatorAddress, newWithdrawalAddress) -//} -// +// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) +// defer cancel() + +// s.T().Logf("Setting distribution withdrawal address on chain %s for %s to %s", c.id, delegatorAddress, newWithdrawalAddress) +// gaiaCommand := []string{ +// gaiadBinary, +// txCommand, +// distributiontypes.ModuleName, +// "set-withdraw-addr", +// newWithdrawalAddress, +// fmt.Sprintf("--%s=%s", flags.FlagFrom, delegatorAddress), +// fmt.Sprintf("--%s=%s", flags.FlagFees, fees), +// fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id), +// fmt.Sprintf("--%s=%s", flags.FlagHome, homePath), +// "--keyring-backend=test", +// "--output=json", +// "-y", +// } + +// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx)) +// s.T().Logf("Successfully set new distribution withdrawal address for %s to %s", delegatorAddress, newWithdrawalAddress) +// } + // func (s *IntegrationTestSuite) execWithdrawReward( -// c *chain, -// valIdx int, -// delegatorAddress, -// validatorAddress, -// homePath string, +// c *chain, +// valIdx int, +// delegatorAddress, +// validatorAddress, +// homePath string, // ) { -// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) -// defer cancel() -// -// s.T().Logf("Withdrawing distribution rewards on chain %s for delegator %s from %s validator", c.id, delegatorAddress, validatorAddress) -// gaiaCommand := []string{ -// gaiadBinary, -// txCommand, -// distributiontypes.ModuleName, -// "withdraw-rewards", -// validatorAddress, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, delegatorAddress), -// fmt.Sprintf("--%s=%s", flags.FlagGasPrices, "300uatom"), -// fmt.Sprintf("--%s=%s", flags.FlagGas, "auto"), -// fmt.Sprintf("--%s=%s", flags.FlagGasAdjustment, "1.5"), -// fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id), -// fmt.Sprintf("--%s=%s", flags.FlagHome, homePath), -// "--keyring-backend=test", -// "--output=json", -// "-y", -// } -// -// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx)) -// s.T().Logf("Successfully withdrew distribution rewards for delegator %s from validator %s", delegatorAddress, validatorAddress) -//} -// +// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) +// defer cancel() + +// s.T().Logf("Withdrawing distribution rewards on chain %s for delegator %s from %s validator", c.id, delegatorAddress, validatorAddress) +// gaiaCommand := []string{ +// gaiadBinary, +// txCommand, +// distributiontypes.ModuleName, +// "withdraw-rewards", +// validatorAddress, +// fmt.Sprintf("--%s=%s", flags.FlagFrom, delegatorAddress), +// fmt.Sprintf("--%s=%s", flags.FlagGasPrices, "300uatom"), +// fmt.Sprintf("--%s=%s", flags.FlagGas, "auto"), +// fmt.Sprintf("--%s=%s", flags.FlagGasAdjustment, "1.5"), +// fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id), +// fmt.Sprintf("--%s=%s", flags.FlagHome, homePath), +// "--keyring-backend=test", +// "--output=json", +// "-y", +// } + +// s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, s.defaultExecValidation(c, valIdx)) +// s.T().Logf("Successfully withdrew distribution rewards for delegator %s from validator %s", delegatorAddress, validatorAddress) +// } + // func (s *IntegrationTestSuite) executeGaiaTxCommand(ctx context.Context, c *chain, gaiaCommand []string, valIdx int, validation func([]byte, []byte) bool) { -// if validation == nil { -// validation = s.defaultExecValidation(s.chainA, 0) -// } -// var ( -// outBuf bytes.Buffer -// errBuf bytes.Buffer -// ) -// exec, err := s.dkrPool.Client.CreateExec(docker.CreateExecOptions{ -// Context: ctx, -// AttachStdout: true, -// AttachStderr: true, -// Container: s.valResources[c.id][valIdx].Container.ID, -// User: "nonroot", -// Cmd: gaiaCommand, -// }) -// s.Require().NoError(err) -// -// err = s.dkrPool.Client.StartExec(exec.ID, docker.StartExecOptions{ -// Context: ctx, -// Detach: false, -// OutputStream: &outBuf, -// ErrorStream: &errBuf, -// }) -// s.Require().NoError(err) -// -// stdOut := outBuf.Bytes() -// stdErr := errBuf.Bytes() -// -// if !validation(stdOut, stdErr) { -// s.Require().FailNowf("Exec validation failed", "stdout: %s, stderr: %s", -// string(stdOut), string(stdErr)) -// } -//} -// +// if validation == nil { +// validation = s.defaultExecValidation(s.chainA, 0) +// } +// var ( +// outBuf bytes.Buffer +// errBuf bytes.Buffer +// ) +// exec, err := s.dkrPool.Client.CreateExec(docker.CreateExecOptions{ +// Context: ctx, +// AttachStdout: true, +// AttachStderr: true, +// Container: s.valResources[c.id][valIdx].Container.ID, +// User: "nonroot", +// Cmd: gaiaCommand, +// }) +// s.Require().NoError(err) + +// err = s.dkrPool.Client.StartExec(exec.ID, docker.StartExecOptions{ +// Context: ctx, +// Detach: false, +// OutputStream: &outBuf, +// ErrorStream: &errBuf, +// }) +// s.Require().NoError(err) + +// stdOut := outBuf.Bytes() +// stdErr := errBuf.Bytes() + +// if !validation(stdOut, stdErr) { +// s.Require().FailNowf("Exec validation failed", "stdout: %s, stderr: %s", +// string(stdOut), string(stdErr)) +// } +// } + +// func (s *IntegrationTestSuite) executeHermesCommand(ctx context.Context, hermesCmd []string) (string, string) { +// var ( +// outBuf bytes.Buffer +// errBuf bytes.Buffer +// ) +// exec, err := s.dkrPool.Client.CreateExec(docker.CreateExecOptions{ +// Context: ctx, +// AttachStdout: true, +// AttachStderr: true, +// Container: s.hermesResource1.Container.ID, +// User: "root", +// Cmd: hermesCmd, +// }) +// s.Require().NoError(err) + +// err = s.dkrPool.Client.StartExec(exec.ID, docker.StartExecOptions{ +// Context: ctx, +// Detach: false, +// OutputStream: &outBuf, +// ErrorStream: &errBuf, +// }) +// s.Require().NoError(err) + +// stdOut := outBuf.Bytes() +// stdErr := errBuf.Bytes() + +// return string(stdOut), string(stdErr) +// } + // func (s *IntegrationTestSuite) expectErrExecValidation(chain *chain, valIdx int, expectErr bool) func([]byte, []byte) bool { -// return func(stdOut []byte, stdErr []byte) bool { -// var txResp sdk.TxResponse -// gotErr := cdc.UnmarshalJSON(stdOut, &txResp) != nil -// if gotErr { -// s.Require().True(expectErr) -// } -// -// endpoint := fmt.Sprintf("http://%s", s.valResources[chain.id][valIdx].GetHostPort("1317/tcp")) -// // wait for the tx to be committed on chain -// s.Require().Eventuallyf( -// func() bool { -// gotErr := queryGaiaTx(endpoint, txResp.TxHash) != nil -// return gotErr == expectErr -// }, -// time.Minute, -// 5*time.Second, -// "stdOut: %s, stdErr: %s", -// string(stdOut), string(stdErr), -// ) -// return true -// } -//} -// +// return func(stdOut []byte, stdErr []byte) bool { +// var txResp sdk.TxResponse +// gotErr := cdc.UnmarshalJSON(stdOut, &txResp) != nil +// if gotErr { +// s.Require().True(expectErr) +// } + +// endpoint := fmt.Sprintf("http://%s", s.valResources[chain.id][valIdx].GetHostPort("1317/tcp")) +// // wait for the tx to be committed on chain +// s.Require().Eventuallyf( +// func() bool { +// gotErr := queryGaiaTx(endpoint, txResp.TxHash) != nil +// return gotErr == expectErr +// }, +// time.Minute, +// 5*time.Second, +// "stdOut: %s, stdErr: %s", +// string(stdOut), string(stdErr), +// ) +// return true +// } +// } + // func (s *IntegrationTestSuite) defaultExecValidation(chain *chain, valIdx int) func([]byte, []byte) bool { -// return func(stdOut []byte, stdErr []byte) bool { -// var txResp sdk.TxResponse -// if err := cdc.UnmarshalJSON(stdOut, &txResp); err != nil { -// return false -// } -// if strings.Contains(txResp.String(), "code: 0") || txResp.Code == 0 { -// endpoint := fmt.Sprintf("http://%s", s.valResources[chain.id][valIdx].GetHostPort("1317/tcp")) -// s.Require().Eventually( -// func() bool { -// return queryGaiaTx(endpoint, txResp.TxHash) == nil -// }, -// time.Minute, -// 5*time.Second, -// "stdOut: %s, stdErr: %s", -// string(stdOut), string(stdErr), -// ) -// return true -// } -// return false -// } -//} +// return func(stdOut []byte, stdErr []byte) bool { +// var txResp sdk.TxResponse +// if err := cdc.UnmarshalJSON(stdOut, &txResp); err != nil { +// return false +// } +// if strings.Contains(txResp.String(), "code: 0") || txResp.Code == 0 { +// endpoint := fmt.Sprintf("http://%s", s.valResources[chain.id][valIdx].GetHostPort("1317/tcp")) +// s.Require().Eventually( +// func() bool { +// return queryGaiaTx(endpoint, txResp.TxHash) == nil +// }, +// time.Minute, +// 5*time.Second, +// "stdOut: %s, stdErr: %s", +// string(stdOut), string(stdErr), +// ) +// return true +// } +// return false +// } +// } diff --git a/tests/e2e/e2e_ibc_test.go b/tests/e2e/e2e_ibc_test.go index 612bc46d708..ec4a429f53c 100644 --- a/tests/e2e/e2e_ibc_test.go +++ b/tests/e2e/e2e_ibc_test.go @@ -1,482 +1,467 @@ package e2e -// // import ( -// "bytes" -// "context" -// "encoding/json" -// "fmt" -// "io" -// "net/http" -// "os" -// "path" -// "path/filepath" -// "strconv" -// "strings" -// "time" -// -// "github.com/cosmos/cosmos-sdk/client/flags" -// sdk "github.com/cosmos/cosmos-sdk/types" -// "github.com/ory/dockertest/v3" -// "github.com/ory/dockertest/v3/docker" -//) -// +// "bytes" +// "context" +// "encoding/json" +// "fmt" +// "strconv" +// "strings" +// "time" + +// "github.com/cosmos/cosmos-sdk/client/flags" +// sdk "github.com/cosmos/cosmos-sdk/types" +// "github.com/ory/dockertest/v3/docker" +// ) + // type ForwardMetadata struct { -// Receiver string `json:"receiver"` -// Port string `json:"port"` -// Channel string `json:"channel"` -// // Timeout time.Duration `json:"timeout"` -// // Retries *uint8 `json:"retries,omitempty"` -// // Next *string `json:"next,omitempty"` -// // RefundSequence *uint64 `json:"refund_sequence,omitempty"` -//} -// +// Receiver string `json:"receiver"` +// Port string `json:"port"` +// Channel string `json:"channel"` +// // Timeout time.Duration `json:"timeout"` +// // Retries *uint8 `json:"retries,omitempty"` +// // Next *string `json:"next,omitempty"` +// // RefundSequence *uint64 `json:"refund_sequence,omitempty"` +// } + // type PacketMetadata struct { -// Forward *ForwardMetadata `json:"forward"` -//} -// -// func (s *IntegrationTestSuite) runIBCRelayer() { -// s.T().Log("starting Hermes relayer container...") -// -// tmpDir, err := os.MkdirTemp("", "gaia-e2e-testnet-hermes-") -// s.Require().NoError(err) -// s.tmpDirs = append(s.tmpDirs, tmpDir) -// -// gaiaAVal := s.chainA.validators[0] -// gaiaBVal := s.chainB.validators[0] -// -// gaiaARly := s.chainA.genesisAccounts[relayerAccountIndex] -// gaiaBRly := s.chainB.genesisAccounts[relayerAccountIndex] -// -// hermesCfgPath := path.Join(tmpDir, "hermes") -// -// s.Require().NoError(os.MkdirAll(hermesCfgPath, 0o755)) -// _, err = copyFile( -// filepath.Join("./scripts/", "hermes_bootstrap.sh"), -// filepath.Join(hermesCfgPath, "hermes_bootstrap.sh"), -// ) -// s.Require().NoError(err) -// -// s.hermesResource, err = s.dkrPool.RunWithOptions( -// &dockertest.RunOptions{ -// Name: fmt.Sprintf("%s-%s-relayer", s.chainA.id, s.chainB.id), -// Repository: "ghcr.io/cosmos/hermes-e2e", -// Tag: "1.0.0", -// NetworkID: s.dkrNet.Network.ID, -// Mounts: []string{ -// fmt.Sprintf("%s/:/root/hermes", hermesCfgPath), -// }, -// PortBindings: map[docker.Port][]docker.PortBinding{ -// "3031/tcp": {{HostIP: "", HostPort: "3031"}}, -// }, -// Env: []string{ -// fmt.Sprintf("GAIA_A_E2E_CHAIN_ID=%s", s.chainA.id), -// fmt.Sprintf("GAIA_B_E2E_CHAIN_ID=%s", s.chainB.id), -// fmt.Sprintf("GAIA_A_E2E_VAL_MNEMONIC=%s", gaiaAVal.mnemonic), -// fmt.Sprintf("GAIA_B_E2E_VAL_MNEMONIC=%s", gaiaBVal.mnemonic), -// fmt.Sprintf("GAIA_A_E2E_RLY_MNEMONIC=%s", gaiaARly.mnemonic), -// fmt.Sprintf("GAIA_B_E2E_RLY_MNEMONIC=%s", gaiaBRly.mnemonic), -// fmt.Sprintf("GAIA_A_E2E_VAL_HOST=%s", s.valResources[s.chainA.id][0].Container.Name[1:]), -// fmt.Sprintf("GAIA_B_E2E_VAL_HOST=%s", s.valResources[s.chainB.id][0].Container.Name[1:]), -// }, -// Entrypoint: []string{ -// "sh", -// "-c", -// "chmod +x /root/hermes/hermes_bootstrap.sh && /root/hermes/hermes_bootstrap.sh", -// }, -// }, -// noRestart, -// ) -// s.Require().NoError(err) -// -// endpoint := fmt.Sprintf("http://%s/state", s.hermesResource.GetHostPort("3031/tcp")) -// s.Require().Eventually( -// func() bool { -// resp, err := http.Get(endpoint) //nolint:gosec // this is a test -// if err != nil { -// return false -// } -// -// defer resp.Body.Close() -// -// bz, err := io.ReadAll(resp.Body) -// if err != nil { -// return false -// } -// -// var respBody map[string]interface{} -// if err := json.Unmarshal(bz, &respBody); err != nil { -// return false -// } -// -// status := respBody["status"].(string) -// result := respBody["result"].(map[string]interface{}) -// -// return status == "success" && len(result["chains"].([]interface{})) == 2 -// }, -// 5*time.Minute, -// time.Second, -// "hermes relayer not healthy", -// ) -// -// s.T().Logf("started Hermes relayer container: %s", s.hermesResource.Container.ID) -// -// // XXX: Give time to both networks to start, otherwise we might see gRPC -// // transport errors. -// time.Sleep(10 * time.Second) -// -// // create the client, connection and channel between the two Gaia chains -// s.createConnection() -// time.Sleep(10 * time.Second) -// s.createChannel() -//} -// +// Forward *ForwardMetadata `json:"forward"` +// } + // func (s *IntegrationTestSuite) sendIBC(c *chain, valIdx int, sender, recipient, token, fees, note string) { -// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) -// defer cancel() -// -// ibcCmd := []string{ -// gaiadBinary, -// txCommand, -// "ibc-transfer", -// "transfer", -// "transfer", -// "channel-0", -// recipient, -// token, -// fmt.Sprintf("--from=%s", sender), -// fmt.Sprintf("--%s=%s", flags.FlagFees, fees), -// fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id), -// // fmt.Sprintf("--%s=%s", flags.FlagNote, note), -// fmt.Sprintf("--memo=%s", note), -// "--keyring-backend=test", -// "--broadcast-mode=sync", -// "--output=json", -// "-y", -// } -// s.T().Logf("sending %s from %s (%s) to %s (%s) with memo %s", token, s.chainA.id, sender, s.chainB.id, recipient, note) -// s.executeGaiaTxCommand(ctx, c, ibcCmd, valIdx, s.defaultExecValidation(c, valIdx)) -// s.T().Log("successfully sent IBC tokens") -//} -// +// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) +// defer cancel() + +// ibcCmd := []string{ +// gaiadBinary, +// txCommand, +// "ibc-transfer", +// "transfer", +// "transfer", +// "channel-0", +// recipient, +// token, +// fmt.Sprintf("--from=%s", sender), +// fmt.Sprintf("--%s=%s", flags.FlagFees, fees), +// fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id), +// // fmt.Sprintf("--%s=%s", flags.FlagNote, note), +// fmt.Sprintf("--memo=%s", note), +// "--keyring-backend=test", +// "--broadcast-mode=sync", +// "--output=json", +// "-y", +// } +// s.T().Logf("sending %s from %s (%s) to %s (%s) with memo %s", token, s.chainA.id, sender, s.chainB.id, recipient, note) +// s.executeGaiaTxCommand(ctx, c, ibcCmd, valIdx, s.defaultExecValidation(c, valIdx)) +// s.T().Log("successfully sent IBC tokens") +// } + +// func (s *IntegrationTestSuite) hermesTransfer(configPath, srcChainID, dstChainID, srcChannelID, denom string, sendAmt, timeOutOffset, numMsg int) (success bool) { +// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) +// defer cancel() + +// hermesCmd := []string{ +// hermesBinary, +// fmt.Sprintf("--config=%s", configPath), +// "tx", +// "ft-transfer", +// fmt.Sprintf("--dst-chain=%s", dstChainID), +// fmt.Sprintf("--src-chain=%s", srcChainID), +// fmt.Sprintf("--src-channel=%s", srcChannelID), +// fmt.Sprintf("--src-port=%s", "transfer"), +// fmt.Sprintf("--amount=%v", sendAmt), +// fmt.Sprintf("--denom=%s", denom), +// fmt.Sprintf("--timeout-height-offset=%v", timeOutOffset), +// fmt.Sprintf("--number-msgs=%v", numMsg), +// } + +// stdout, stderr := s.executeHermesCommand(ctx, hermesCmd) +// if strings.Contains(stdout, "ERROR") || strings.Contains(stderr, "ERROR") { +// return false +// } + +// return true +// } + +// func (s *IntegrationTestSuite) hermesClearPacket(configPath, chainID, channelID string) bool { //nolint:unparam +// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) +// defer cancel() + +// hermesCmd := []string{ +// hermesBinary, +// fmt.Sprintf("--config=%s", configPath), +// "clear", +// "packets", +// fmt.Sprintf("--chain=%s", chainID), +// fmt.Sprintf("--channel=%s", channelID), +// fmt.Sprintf("--port=%s", "transfer"), +// } + +// stdout, stderr := s.executeHermesCommand(ctx, hermesCmd) +// if strings.Contains(stdout, "ERROR") || strings.Contains(stderr, "ERROR") { +// return false +// } + +// return true +// } + +// func (s *IntegrationTestSuite) hermesPendingPackets(configPath, chainID, channelID string) (pendingPackets bool) { +// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) +// defer cancel() +// hermesCmd := []string{ +// hermesBinary, +// fmt.Sprintf("--config=%s", configPath), +// "query", +// "packet", +// "pending", +// fmt.Sprintf("--chain=%s", chainID), +// fmt.Sprintf("--channel=%s", channelID), +// fmt.Sprintf("--port=%s", "transfer"), +// } + +// stdout, _ := s.executeHermesCommand(ctx, hermesCmd) +// stdout = strings.ReplaceAll(stdout, " ", "") +// stdout = strings.ReplaceAll(stdout, "\n", "") + +// // Check if "unreceived_packets" exists in "src" +// return !strings.Contains(stdout, "src:pendingPackets{unreceived_packets:[]") +// } + +// func (s *IntegrationTestSuite) queryRelayerWalletsBalances() (sdk.Coin, sdk.Coin) { +// chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) +// scrRelayerBalance, err := getSpecificBalance( +// chainAAPIEndpoint, +// s.chainA.genesisAccounts[relayerAccountIndexHermes1].keyInfo.GetAddress().String(), +// uatomDenom) +// s.Require().NoError(err) + +// chainBAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainB.id][0].GetHostPort("1317/tcp")) +// dstRelayerBalance, err := getSpecificBalance( +// chainBAPIEndpoint, +// s.chainB.genesisAccounts[relayerAccountIndexHermes1].keyInfo.GetAddress().String(), +// uatomDenom) +// s.Require().NoError(err) + +// return scrRelayerBalance, dstRelayerBalance +// } + // func (s *IntegrationTestSuite) createConnection() { -// s.T().Logf("connecting %s and %s chains via IBC", s.chainA.id, s.chainB.id) -// -// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) -// defer cancel() -// -// exec, err := s.dkrPool.Client.CreateExec(docker.CreateExecOptions{ -// Context: ctx, -// AttachStdout: true, -// AttachStderr: true, -// Container: s.hermesResource.Container.ID, -// User: "root", -// Cmd: []string{ -// "hermes", -// "create", -// "connection", -// "--a-chain", -// s.chainA.id, -// "--b-chain", -// s.chainB.id, -// }, -// }) -// s.Require().NoError(err) -// -// var ( -// outBuf bytes.Buffer -// errBuf bytes.Buffer -// ) -// -// err = s.dkrPool.Client.StartExec(exec.ID, docker.StartExecOptions{ -// Context: ctx, -// Detach: false, -// OutputStream: &outBuf, -// ErrorStream: &errBuf, -// }) -// s.Require().NoErrorf( -// err, -// "failed connect chains; stdout: %s, stderr: %s", outBuf.String(), errBuf.String(), -// ) -// -// s.T().Logf("connected %s and %s chains via IBC", s.chainA.id, s.chainB.id) -//} -// +// s.T().Logf("connecting %s and %s chains via IBC", s.chainA.id, s.chainB.id) + +// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) +// defer cancel() + +// exec, err := s.dkrPool.Client.CreateExec(docker.CreateExecOptions{ +// Context: ctx, +// AttachStdout: true, +// AttachStderr: true, +// Container: s.hermesResource0.Container.ID, +// User: "root", +// Cmd: []string{ +// "hermes", +// "create", +// "connection", +// "--a-chain", +// s.chainA.id, +// "--b-chain", +// s.chainB.id, +// }, +// }) +// s.Require().NoError(err) + +// var ( +// outBuf bytes.Buffer +// errBuf bytes.Buffer +// ) + +// err = s.dkrPool.Client.StartExec(exec.ID, docker.StartExecOptions{ +// Context: ctx, +// Detach: false, +// OutputStream: &outBuf, +// ErrorStream: &errBuf, +// }) +// s.Require().NoErrorf( +// err, +// "failed connect chains; stdout: %s, stderr: %s", outBuf.String(), errBuf.String(), +// ) + +// s.T().Logf("connected %s and %s chains via IBC", s.chainA.id, s.chainB.id) +// } + // func (s *IntegrationTestSuite) createChannel() { -// s.T().Logf("connecting %s and %s chains via IBC", s.chainA.id, s.chainB.id) -// -// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) -// defer cancel() -// -// exec, err := s.dkrPool.Client.CreateExec(docker.CreateExecOptions{ -// Context: ctx, -// AttachStdout: true, -// AttachStderr: true, -// Container: s.hermesResource.Container.ID, -// User: "root", -// Cmd: []string{ -// "hermes", -// txCommand, -// "chan-open-init", -// "--dst-chain", -// s.chainA.id, -// "--src-chain", -// s.chainB.id, -// "--dst-connection", -// "connection-0", -// "--src-port=transfer", -// "--dst-port=transfer", -// }, -// }) -// s.Require().NoError(err) -// -// var ( -// outBuf bytes.Buffer -// errBuf bytes.Buffer -// ) -// -// err = s.dkrPool.Client.StartExec(exec.ID, docker.StartExecOptions{ -// Context: ctx, -// Detach: false, -// OutputStream: &outBuf, -// ErrorStream: &errBuf, -// }) -// s.Require().NoErrorf( -// err, -// "failed connect chains; stdout: %s, stderr: %s", outBuf.String(), errBuf.String(), -// ) -// -// s.T().Logf("connected %s and %s chains via IBC", s.chainA.id, s.chainB.id) -//} -// +// s.T().Logf("connecting %s and %s chains via IBC", s.chainA.id, s.chainB.id) + +// ctx, cancel := context.WithTimeout(context.Background(), time.Minute) +// defer cancel() + +// exec, err := s.dkrPool.Client.CreateExec(docker.CreateExecOptions{ +// Context: ctx, +// AttachStdout: true, +// AttachStderr: true, +// Container: s.hermesResource0.Container.ID, +// User: "root", +// Cmd: []string{ +// "hermes", +// txCommand, +// "chan-open-init", +// "--dst-chain", +// s.chainA.id, +// "--src-chain", +// s.chainB.id, +// "--dst-connection", +// "connection-0", +// "--src-port=transfer", +// "--dst-port=transfer", +// }, +// }) +// s.Require().NoError(err) + +// var ( +// outBuf bytes.Buffer +// errBuf bytes.Buffer +// ) + +// err = s.dkrPool.Client.StartExec(exec.ID, docker.StartExecOptions{ +// Context: ctx, +// Detach: false, +// OutputStream: &outBuf, +// ErrorStream: &errBuf, +// }) +// s.Require().NoErrorf( +// err, +// "failed connect chains; stdout: %s, stderr: %s", outBuf.String(), errBuf.String(), +// ) + +// s.T().Logf("connected %s and %s chains via IBC", s.chainA.id, s.chainB.id) +// } + // func (s *IntegrationTestSuite) testIBCTokenTransfer() { -// time.Sleep(30 * time.Second) -// s.Run("send_uatom_to_chainB", func() { -// // require the recipient account receives the IBC tokens (IBC packets ACKd) -// var ( -// balances sdk.Coins -// err error -// beforeBalance int64 -// ibcStakeDenom string -// ) -// -// address := s.chainA.validators[0].keyInfo.GetAddress() -// sender := address.String() -// -// address = s.chainB.validators[0].keyInfo.GetAddress() -// recipient := address.String() -// -// chainBAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainB.id][0].GetHostPort("1317/tcp")) -// -// s.Require().Eventually( -// func() bool { -// balances, err = queryGaiaAllBalances(chainBAPIEndpoint, recipient) -// s.Require().NoError(err) -// return balances.Len() != 0 -// }, -// time.Minute, -// 5*time.Second, -// ) -// for _, c := range balances { -// if strings.Contains(c.Denom, "ibc/") { -// beforeBalance = c.Amount.Int64() -// break -// } -// } -// -// tokenAmt := 3300000000 -// s.sendIBC(s.chainA, 0, sender, recipient, strconv.Itoa(tokenAmt)+uatomDenom, standardFees.String(), "") -// -// s.Require().Eventually( -// func() bool { -// balances, err = queryGaiaAllBalances(chainBAPIEndpoint, recipient) -// s.Require().NoError(err) -// return balances.Len() != 0 -// }, -// time.Minute, -// 5*time.Second, -// ) -// for _, c := range balances { -// if strings.Contains(c.Denom, "ibc/") { -// ibcStakeDenom = c.Denom -// s.Require().Equal((int64(tokenAmt) + beforeBalance), c.Amount.Int64()) -// break -// } -// } -// -// s.Require().NotEmpty(ibcStakeDenom) -// }) -//} -// -///* +// s.Run("send_uatom_to_chainB", func() { +// // require the recipient account receives the IBC tokens (IBC packets ACKd) +// var ( +// balances sdk.Coins +// err error +// beforeBalance int64 +// ibcStakeDenom string +// ) + +// address := s.chainA.validators[0].keyInfo.GetAddress() +// sender := address.String() + +// address = s.chainB.validators[0].keyInfo.GetAddress() +// recipient := address.String() + +// chainBAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainB.id][0].GetHostPort("1317/tcp")) + +// s.Require().Eventually( +// func() bool { +// balances, err = queryGaiaAllBalances(chainBAPIEndpoint, recipient) +// s.Require().NoError(err) +// return balances.Len() != 0 +// }, +// time.Minute, +// 5*time.Second, +// ) +// for _, c := range balances { +// if strings.Contains(c.Denom, "ibc/") { +// beforeBalance = c.Amount.Int64() +// break +// } +// } + +// tokenAmt := 3300000000 +// s.sendIBC(s.chainA, 0, sender, recipient, strconv.Itoa(tokenAmt)+uatomDenom, standardFees.String(), "") + +// s.Require().Eventually( +// func() bool { +// balances, err = queryGaiaAllBalances(chainBAPIEndpoint, recipient) +// s.Require().NoError(err) +// return balances.Len() != 0 +// }, +// time.Minute, +// 5*time.Second, +// ) +// for _, c := range balances { +// if strings.Contains(c.Denom, "ibc/") { +// ibcStakeDenom = c.Denom +// s.Require().Equal((int64(tokenAmt) + beforeBalance), c.Amount.Int64()) +// break +// } +// } + +// s.Require().NotEmpty(ibcStakeDenom) +// }) +// } + +// /* // TestMultihopIBCTokenTransfer tests that sending an IBC transfer using the IBC Packet Forward Middleware accepts a port, channel and account address -// -//Steps: + +// Steps: // 1. Check balance of Account 1 on Chain 1 // 2. Check balance of Account 2 on Chain 1 // 3. Account 1 on Chain 1 sends x tokens to Account 2 on Chain 1 via Account 1 on Chain 2 // 4. Check Balance of Account 1 on Chain 1, confirm it is original minus x tokens // 5. Check Balance of Account 2 on Chain 1, confirm it is original plus x tokens -// + // */ -//// TODO: Add back only if packet forward middleware has a working version compatible with IBC v3.0.x +// // TODO: Add back only if packet forward middleware has a working version compatible with IBC v3.0.x // func (s *IntegrationTestSuite) testMultihopIBCTokenTransfer() { -// time.Sleep(30 * time.Second) -// -// s.Run("send_successful_multihop_uatom_to_chainA_from_chainA", func() { -// // require the recipient account receives the IBC tokens (IBC packets ACKd) -// var ( -// err error -// ) -// -// address := s.chainA.validators[0].keyInfo.GetAddress() -// sender := address.String() -// -// address = s.chainB.validators[0].keyInfo.GetAddress() -// middlehop := address.String() -// -// address = s.chainA.validators[1].keyInfo.GetAddress() -// recipient := address.String() -// -// forwardPort := "transfer" -// forwardChannel := "channel-0" -// -// tokenAmt := 3300000000 -// -// chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) -// -// var ( -// beforeSenderUAtomBalance sdk.Coin -// beforeRecipientUAtomBalance sdk.Coin -// ) -// -// s.Require().Eventually( -// func() bool { -// beforeSenderUAtomBalance, err = getSpecificBalance(chainAAPIEndpoint, sender, uatomDenom) -// s.Require().NoError(err) -// fmt.Println("beforeSenderUAtomBalance", beforeSenderUAtomBalance) -// -// beforeRecipientUAtomBalance, err = getSpecificBalance(chainAAPIEndpoint, recipient, uatomDenom) -// s.Require().NoError(err) -// fmt.Print("beforeRecipientUAtomBalance", beforeRecipientUAtomBalance) -// -// return beforeSenderUAtomBalance.IsValid() && beforeRecipientUAtomBalance.IsValid() -// }, -// 1*time.Minute, -// 5*time.Second, -// ) -// -// firstHopMetadata := &PacketMetadata{ -// Forward: &ForwardMetadata{ -// Receiver: recipient, -// Channel: forwardChannel, -// Port: forwardPort, -// }, -// } -// -// memo, err := json.Marshal(firstHopMetadata) -// s.Require().NoError(err) -// -// s.sendIBC(s.chainA, 0, sender, middlehop, strconv.Itoa(tokenAmt)+uatomDenom, standardFees.String(), string(memo)) -// -// s.Require().Eventually( -// func() bool { -// afterSenderUAtomBalance, err := getSpecificBalance(chainAAPIEndpoint, sender, uatomDenom) -// s.Require().NoError(err) -// -// afterRecipientUAtomBalance, err := getSpecificBalance(chainAAPIEndpoint, recipient, uatomDenom) -// s.Require().NoError(err) -// -// decremented := beforeSenderUAtomBalance.Sub(tokenAmount).Sub(standardFees).IsEqual(afterSenderUAtomBalance) -// incremented := beforeRecipientUAtomBalance.Add(tokenAmount).IsEqual(afterRecipientUAtomBalance) -// -// return decremented && incremented -// }, -// 1*time.Minute, -// 5*time.Second, -// ) -// }) -//} -// -///* +// time.Sleep(30 * time.Second) + +// s.Run("send_successful_multihop_uatom_to_chainA_from_chainA", func() { +// // require the recipient account receives the IBC tokens (IBC packets ACKd) +// var ( +// err error +// ) + +// address := s.chainA.validators[0].keyInfo.GetAddress() +// sender := address.String() + +// address = s.chainB.validators[0].keyInfo.GetAddress() +// middlehop := address.String() + +// address = s.chainA.validators[1].keyInfo.GetAddress() +// recipient := address.String() + +// forwardPort := "transfer" +// forwardChannel := "channel-0" + +// tokenAmt := 3300000000 + +// chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) + +// var ( +// beforeSenderUAtomBalance sdk.Coin +// beforeRecipientUAtomBalance sdk.Coin +// ) + +// s.Require().Eventually( +// func() bool { +// beforeSenderUAtomBalance, err = getSpecificBalance(chainAAPIEndpoint, sender, uatomDenom) +// s.Require().NoError(err) +// fmt.Println("beforeSenderUAtomBalance", beforeSenderUAtomBalance) + +// beforeRecipientUAtomBalance, err = getSpecificBalance(chainAAPIEndpoint, recipient, uatomDenom) +// s.Require().NoError(err) +// fmt.Print("beforeRecipientUAtomBalance", beforeRecipientUAtomBalance) + +// return beforeSenderUAtomBalance.IsValid() && beforeRecipientUAtomBalance.IsValid() +// }, +// 1*time.Minute, +// 5*time.Second, +// ) + +// firstHopMetadata := &PacketMetadata{ +// Forward: &ForwardMetadata{ +// Receiver: recipient, +// Channel: forwardChannel, +// Port: forwardPort, +// }, +// } + +// memo, err := json.Marshal(firstHopMetadata) +// s.Require().NoError(err) + +// s.sendIBC(s.chainA, 0, sender, middlehop, strconv.Itoa(tokenAmt)+uatomDenom, standardFees.String(), string(memo)) + +// s.Require().Eventually( +// func() bool { +// afterSenderUAtomBalance, err := getSpecificBalance(chainAAPIEndpoint, sender, uatomDenom) +// s.Require().NoError(err) + +// afterRecipientUAtomBalance, err := getSpecificBalance(chainAAPIEndpoint, recipient, uatomDenom) +// s.Require().NoError(err) + +// decremented := beforeSenderUAtomBalance.Sub(tokenAmount).Sub(standardFees).IsEqual(afterSenderUAtomBalance) +// incremented := beforeRecipientUAtomBalance.Add(tokenAmount).IsEqual(afterRecipientUAtomBalance) + +// return decremented && incremented +// }, +// 1*time.Minute, +// 5*time.Second, +// ) +// }) +// } + +// /* // TestFailedMultihopIBCTokenTransfer tests that sending a failing IBC transfer using the IBC Packet Forward // Middleware will send the tokens back to the original account after failing. // */ // func (s *IntegrationTestSuite) testFailedMultihopIBCTokenTransfer() { -// time.Sleep(30 * time.Second) -// -// s.Run("send_failed_multihop_uatom_to_chainA_from_chainA", func() { -// address := s.chainA.validators[0].keyInfo.GetAddress() -// sender := address.String() -// -// address = s.chainB.validators[0].keyInfo.GetAddress() -// middlehop := address.String() -// -// address = s.chainA.validators[1].keyInfo.GetAddress() -// recipient := strings.Replace(address.String(), "cosmos", "foobar", 1) // this should be an invalid recipient to force the tx to fail -// -// forwardPort := "transfer" -// forwardChannel := "channel-0" -// -// tokenAmt := 3300000000 -// -// chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) -// -// var ( -// beforeSenderUAtomBalance sdk.Coin -// err error -// ) -// -// s.Require().Eventually( -// func() bool { -// beforeSenderUAtomBalance, err = getSpecificBalance(chainAAPIEndpoint, sender, uatomDenom) -// s.Require().NoError(err) -// -// return beforeSenderUAtomBalance.IsValid() -// }, -// 1*time.Minute, -// 5*time.Second, -// ) -// -// firstHopMetadata := &PacketMetadata{ -// Forward: &ForwardMetadata{ -// Receiver: recipient, -// Channel: forwardChannel, -// Port: forwardPort, -// }, -// } -// -// memo, err := json.Marshal(firstHopMetadata) -// s.Require().NoError(err) -// -// s.sendIBC(s.chainA, 0, sender, middlehop, strconv.Itoa(tokenAmt)+uatomDenom, standardFees.String(), string(memo)) -// -// // Sender account should be initially decremented the full amount -// s.Require().Eventually( -// func() bool { -// afterSenderUAtomBalance, err := getSpecificBalance(chainAAPIEndpoint, sender, uatomDenom) -// s.Require().NoError(err) -// -// returned := beforeSenderUAtomBalance.Sub(tokenAmount).Sub(standardFees).IsEqual(afterSenderUAtomBalance) -// -// return returned -// }, -// 1*time.Minute, -// 1*time.Second, -// ) -// -// // since the forward receiving account is invalid, it should be refunded to the original sender (minus the original fee) -// s.Require().Eventually( -// func() bool { -// afterSenderUAtomBalance, err := getSpecificBalance(chainAAPIEndpoint, sender, uatomDenom) -// s.Require().NoError(err) -// -// returned := beforeSenderUAtomBalance.Sub(standardFees).IsEqual(afterSenderUAtomBalance) -// -// return returned -// }, -// 5*time.Minute, -// 5*time.Second, -// ) -// }) -//} +// time.Sleep(30 * time.Second) + +// s.Run("send_failed_multihop_uatom_to_chainA_from_chainA", func() { +// address := s.chainA.validators[0].keyInfo.GetAddress() +// sender := address.String() + +// address = s.chainB.validators[0].keyInfo.GetAddress() +// middlehop := address.String() + +// address = s.chainA.validators[1].keyInfo.GetAddress() +// recipient := strings.Replace(address.String(), "cosmos", "foobar", 1) // this should be an invalid recipient to force the tx to fail + +// forwardPort := "transfer" +// forwardChannel := "channel-0" + +// tokenAmt := 3300000000 + +// chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) + +// var ( +// beforeSenderUAtomBalance sdk.Coin +// err error +// ) + +// s.Require().Eventually( +// func() bool { +// beforeSenderUAtomBalance, err = getSpecificBalance(chainAAPIEndpoint, sender, uatomDenom) +// s.Require().NoError(err) + +// return beforeSenderUAtomBalance.IsValid() +// }, +// 1*time.Minute, +// 5*time.Second, +// ) + +// firstHopMetadata := &PacketMetadata{ +// Forward: &ForwardMetadata{ +// Receiver: recipient, +// Channel: forwardChannel, +// Port: forwardPort, +// }, +// } + +// memo, err := json.Marshal(firstHopMetadata) +// s.Require().NoError(err) + +// s.sendIBC(s.chainA, 0, sender, middlehop, strconv.Itoa(tokenAmt)+uatomDenom, standardFees.String(), string(memo)) + +// // Sender account should be initially decremented the full amount +// s.Require().Eventually( +// func() bool { +// afterSenderUAtomBalance, err := getSpecificBalance(chainAAPIEndpoint, sender, uatomDenom) +// s.Require().NoError(err) + +// returned := beforeSenderUAtomBalance.Sub(tokenAmount).Sub(standardFees).IsEqual(afterSenderUAtomBalance) + +// return returned +// }, +// 1*time.Minute, +// 1*time.Second, +// ) + +// // since the forward receiving account is invalid, it should be refunded to the original sender (minus the original fee) +// s.Require().Eventually( +// func() bool { +// afterSenderUAtomBalance, err := getSpecificBalance(chainAAPIEndpoint, sender, uatomDenom) +// s.Require().NoError(err) + +// returned := beforeSenderUAtomBalance.Sub(standardFees).IsEqual(afterSenderUAtomBalance) + +// return returned +// }, +// 5*time.Minute, +// 5*time.Second, +// ) +// }) +// } diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 40f7fd85084..5685fcbeeb2 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -1,757 +1,935 @@ package e2e -// // import ( -// "context" -// "encoding/json" -// "fmt" -// "os" -// "os/exec" -// "path/filepath" -// "strconv" -// "strings" -// "testing" -// "time" -// -// //ccvprovider "github.com/cosmos/interchain-security/x/ccv/provider/types" -// -// tmconfig "github.com/cometbft/cometbft/config" -// tmjson "github.com/cometbft/cometbft/libs/json" -// "github.com/cometbft/cometbft/libs/rand" -// rpchttp "github.com/cometbft/cometbft/rpc/client/http" -// codectypes "github.com/cosmos/cosmos-sdk/codec/types" -// "github.com/cosmos/cosmos-sdk/crypto/hd" -// "github.com/cosmos/cosmos-sdk/crypto/keyring" -// "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" -// "github.com/cosmos/cosmos-sdk/server" -// srvconfig "github.com/cosmos/cosmos-sdk/server/config" -// sdk "github.com/cosmos/cosmos-sdk/types" -// authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" -// authvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" -// banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" -// distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" -// evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" -// genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" -// stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" -// ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" -// "github.com/ory/dockertest/v3" -// "github.com/ory/dockertest/v3/docker" -// "github.com/spf13/viper" -// "github.com/stretchr/testify/suite" -//) -// +// "context" +// "encoding/json" +// "fmt" +// "io" +// "net/http" +// "os" +// "os/exec" +// "path" +// "path/filepath" +// "strconv" +// "strings" +// "testing" +// "time" + +// ccvprovider "github.com/cosmos/interchain-security/x/ccv/provider/types" + +// codectypes "github.com/cosmos/cosmos-sdk/codec/types" +// "github.com/cosmos/cosmos-sdk/crypto/hd" +// "github.com/cosmos/cosmos-sdk/crypto/keyring" +// "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" +// "github.com/cosmos/cosmos-sdk/server" +// srvconfig "github.com/cosmos/cosmos-sdk/server/config" +// sdk "github.com/cosmos/cosmos-sdk/types" +// authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" +// authvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" +// banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" +// distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" +// evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" +// genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" +// stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" +// ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" +// "github.com/ory/dockertest/v3" +// "github.com/ory/dockertest/v3/docker" +// "github.com/spf13/viper" +// "github.com/stretchr/testify/suite" +// tmconfig "github.com/tendermint/tendermint/config" +// tmjson "github.com/tendermint/tendermint/libs/json" +// "github.com/tendermint/tendermint/libs/rand" +// rpchttp "github.com/tendermint/tendermint/rpc/client/http" +// ) + // const ( -// gaiadBinary = "gaiad" -// txCommand = "tx" -// queryCommand = "query" -// keysCommand = "keys" -// gaiaHomePath = "/home/nonroot/.gaia" -// photonDenom = "photon" -// uatomDenom = "uatom" -// stakeDenom = "stake" -// initBalanceStr = "110000000000stake,100000000000000000photon,100000000000000000uatom" -// minGasPrice = "0.00001" -// // the test globalfee in genesis is the same as minGasPrice -// // global fee lower/higher than min_gas_price -// initialGlobalFeeAmt = "0.00001" -// lowGlobalFeesAmt = "0.000001" -// highGlobalFeeAmt = "0.0001" -// maxTotalBypassMinFeeMsgGasUsage = "1" -// gas = 200000 -// govProposalBlockBuffer = 35 -// relayerAccountIndex = 0 -// numberOfEvidences = 10 -// slashingShares int64 = 10000 -// -// proposalGlobalFeeFilename = "proposal_globalfee.json" -// proposalBypassMsgFilename = "proposal_bypass_msg.json" -// proposalMaxTotalBypassFilename = "proposal_max_total_bypass.json" -// proposalCommunitySpendFilename = "proposal_community_spend.json" -// proposalAddConsumerChainFilename = "proposal_add_consumer.json" -// proposalRemoveConsumerChainFilename = "proposal_remove_consumer.json" -//) -// +// gaiadBinary = "gaiad" +// txCommand = "tx" +// queryCommand = "query" +// keysCommand = "keys" +// gaiaHomePath = "/home/nonroot/.gaia" +// photonDenom = "photon" +// uatomDenom = "uatom" +// stakeDenom = "stake" +// initBalanceStr = "110000000000stake,100000000000000000photon,100000000000000000uatom" +// minGasPrice = "0.00001" +// // the test globalfee in genesis is the same as minGasPrice +// // global fee lower/higher than min_gas_price +// initialGlobalFeeAmt = "0.00001" +// lowGlobalFeesAmt = "0.000001" +// highGlobalFeeAmt = "0.0001" +// maxTotalBypassMinFeeMsgGasUsage = "1" +// gas = 200000 +// govProposalBlockBuffer = 35 +// relayerAccountIndexHermes0 = 0 +// relayerAccountIndexHermes1 = 1 +// numberOfEvidences = 10 +// slashingShares int64 = 10000 + +// proposalGlobalFeeFilename = "proposal_globalfee.json" +// proposalBypassMsgFilename = "proposal_bypass_msg.json" +// proposalMaxTotalBypassFilename = "proposal_max_total_bypass.json" +// proposalCommunitySpendFilename = "proposal_community_spend.json" +// proposalAddConsumerChainFilename = "proposal_add_consumer.json" +// proposalRemoveConsumerChainFilename = "proposal_remove_consumer.json" + +// hermesBinary = "hermes" +// hermesConfigWithGasPrices = "/root/.hermes/config.toml" +// hermesConfigNoGasPrices = "/root/.hermes/config-zero.toml" +// transferChannel = "channel-0" +// ) + // var ( -// gaiaConfigPath = filepath.Join(gaiaHomePath, "config") -// stakingAmount = sdk.NewInt(100000000000) -// stakingAmountCoin = sdk.NewCoin(uatomDenom, stakingAmount) -// tokenAmount = sdk.NewCoin(uatomDenom, sdk.NewInt(3300000000)) // 3,300uatom -// standardFees = sdk.NewCoin(uatomDenom, sdk.NewInt(330000)) // 0.33uatom -// depositAmount = sdk.NewCoin(uatomDenom, sdk.NewInt(330000000)) // 3,300uatom -// distModuleAddress = authtypes.NewModuleAddress(distrtypes.ModuleName).String() -// proposalCounter = 0 -//) -// +// gaiaConfigPath = filepath.Join(gaiaHomePath, "config") +// stakingAmount = sdk.NewInt(100000000000) +// stakingAmountCoin = sdk.NewCoin(uatomDenom, stakingAmount) +// tokenAmount = sdk.NewCoin(uatomDenom, sdk.NewInt(3300000000)) // 3,300uatom +// standardFees = sdk.NewCoin(uatomDenom, sdk.NewInt(330000)) // 0.33uatom +// depositAmount = sdk.NewCoin(uatomDenom, sdk.NewInt(330000000)) // 3,300uatom +// distModuleAddress = authtypes.NewModuleAddress(distrtypes.ModuleName).String() +// proposalCounter = 0 +// HermesResource0Purged = false +// ) + // type IntegrationTestSuite struct { -// suite.Suite -// -// tmpDirs []string -// chainA *chain -// chainB *chain -// dkrPool *dockertest.Pool -// dkrNet *dockertest.Network -// hermesResource *dockertest.Resource -// valResources map[string][]*dockertest.Resource -//} -// +// suite.Suite + +// tmpDirs []string +// chainA *chain +// chainB *chain +// dkrPool *dockertest.Pool +// dkrNet *dockertest.Network +// hermesResource0 *dockertest.Resource +// hermesResource1 *dockertest.Resource + +// valResources map[string][]*dockertest.Resource +// } + // type AddressResponse struct { -// Name string `json:"name"` -// Type string `json:"type"` -// Address string `json:"address"` -// Mnemonic string `json:"mnemonic"` -//} -// +// Name string `json:"name"` +// Type string `json:"type"` +// Address string `json:"address"` +// Mnemonic string `json:"mnemonic"` +// } + // func TestIntegrationTestSuite(t *testing.T) { -// suite.Run(t, new(IntegrationTestSuite)) -//} -// +// suite.Run(t, new(IntegrationTestSuite)) +// } + // func (s *IntegrationTestSuite) SetupSuite() { -// s.T().Log("setting up e2e integration test suite...") -// -// var err error -// s.chainA, err = newChain() -// s.Require().NoError(err) -// -// s.chainB, err = newChain() -// s.Require().NoError(err) -// -// s.dkrPool, err = dockertest.NewPool("") -// s.Require().NoError(err) -// -// s.dkrNet, err = s.dkrPool.CreateNetwork(fmt.Sprintf("%s-%s-testnet", s.chainA.id, s.chainB.id)) -// s.Require().NoError(err) -// -// s.valResources = make(map[string][]*dockertest.Resource) -// -// vestingMnemonic, err := createMnemonic() -// s.Require().NoError(err) -// -// jailedValMnemonic, err := createMnemonic() -// s.Require().NoError(err) -// -// // The boostrapping phase is as follows: -// // -// // 1. Initialize Gaia validator nodes. -// // 2. Create and initialize Gaia validator genesis files (both chains) -// // 3. Start both networks. -// // 4. Create and run IBC relayer (Hermes) containers. -// -// s.T().Logf("starting e2e infrastructure for chain A; chain-id: %s; datadir: %s", s.chainA.id, s.chainA.dataDir) -// s.initNodes(s.chainA) -// s.initGenesis(s.chainA, vestingMnemonic, jailedValMnemonic) -// s.initValidatorConfigs(s.chainA) -// s.runValidators(s.chainA, 0) -// -// s.T().Logf("starting e2e infrastructure for chain B; chain-id: %s; datadir: %s", s.chainB.id, s.chainB.dataDir) -// s.initNodes(s.chainB) -// s.initGenesis(s.chainB, vestingMnemonic, jailedValMnemonic) -// s.initValidatorConfigs(s.chainB) -// s.runValidators(s.chainB, 10) -// -// time.Sleep(10 * time.Second) -// s.runIBCRelayer() -//} -// +// s.T().Log("setting up e2e integration test suite...") + +// var err error +// s.chainA, err = newChain() +// s.Require().NoError(err) + +// s.chainB, err = newChain() +// s.Require().NoError(err) + +// s.dkrPool, err = dockertest.NewPool("") +// s.Require().NoError(err) + +// s.dkrNet, err = s.dkrPool.CreateNetwork(fmt.Sprintf("%s-%s-testnet", s.chainA.id, s.chainB.id)) +// s.Require().NoError(err) + +// s.valResources = make(map[string][]*dockertest.Resource) + +// vestingMnemonic, err := createMnemonic() +// s.Require().NoError(err) + +// jailedValMnemonic, err := createMnemonic() +// s.Require().NoError(err) + +// // The boostrapping phase is as follows: +// // +// // 1. Initialize Gaia validator nodes. +// // 2. Create and initialize Gaia validator genesis files (both chains) +// // 3. Start both networks. +// // 4. Create and run IBC relayer (Hermes) containers. + +// s.T().Logf("starting e2e infrastructure for chain A; chain-id: %s; datadir: %s", s.chainA.id, s.chainA.dataDir) +// s.initNodes(s.chainA) +// s.initGenesis(s.chainA, vestingMnemonic, jailedValMnemonic) +// s.initValidatorConfigs(s.chainA) +// s.runValidators(s.chainA, 0) + +// s.T().Logf("starting e2e infrastructure for chain B; chain-id: %s; datadir: %s", s.chainB.id, s.chainB.dataDir) +// s.initNodes(s.chainB) +// s.initGenesis(s.chainB, vestingMnemonic, jailedValMnemonic) +// s.initValidatorConfigs(s.chainB) +// s.runValidators(s.chainB, 10) + +// time.Sleep(10 * time.Second) +// s.runIBCRelayer0() +// s.runIBCRelayer1() +// } + // func (s *IntegrationTestSuite) TearDownSuite() { -// if str := os.Getenv("GAIA_E2E_SKIP_CLEANUP"); len(str) > 0 { -// skipCleanup, err := strconv.ParseBool(str) -// s.Require().NoError(err) -// -// if skipCleanup { -// return -// } -// } -// -// s.T().Log("tearing down e2e integration test suite...") -// -// if runIBCTest { -// s.Require().NoError(s.dkrPool.Purge(s.hermesResource)) -// } -// -// for _, vr := range s.valResources { -// for _, r := range vr { -// s.Require().NoError(s.dkrPool.Purge(r)) -// } -// } -// -// s.Require().NoError(s.dkrPool.RemoveNetwork(s.dkrNet)) -// -// os.RemoveAll(s.chainA.dataDir) -// os.RemoveAll(s.chainB.dataDir) -// -// for _, td := range s.tmpDirs { -// os.RemoveAll(td) -// } -//} -// +// if str := os.Getenv("GAIA_E2E_SKIP_CLEANUP"); len(str) > 0 { +// skipCleanup, err := strconv.ParseBool(str) +// s.Require().NoError(err) + +// if skipCleanup { +// return +// } +// } + +// s.T().Log("tearing down e2e integration test suite...") + +// s.Require().NoError(s.dkrPool.Purge(s.hermesResource1)) +// // if runIBCTest, s.hermesResource0 already purged in TestIBC() +// // in GovSoftwareUpgrade test, s.TearDownSuite() then s.SetupSuite() +// // if IBCTest runs before GovSoftwareUpgrade, s.hermesResource0 is already purged. +// if !HermesResource0Purged { +// s.Require().NoError(s.dkrPool.Purge(s.hermesResource0)) +// } + +// for _, vr := range s.valResources { +// for _, r := range vr { +// s.Require().NoError(s.dkrPool.Purge(r)) +// } +// } + +// s.Require().NoError(s.dkrPool.RemoveNetwork(s.dkrNet)) + +// os.RemoveAll(s.chainA.dataDir) +// os.RemoveAll(s.chainB.dataDir) + +// for _, td := range s.tmpDirs { +// os.RemoveAll(td) +// } +// } + // func (s *IntegrationTestSuite) initNodes(c *chain) { -// s.Require().NoError(c.createAndInitValidators(2)) -// /* Adding 4 accounts to val0 local directory -// c.genesisAccounts[0]: Relayer Wallet -// c.genesisAccounts[1]: ICA Owner -// c.genesisAccounts[2]: Test Account 1 -// c.genesisAccounts[3]: Test Account 2 -// */ -// s.Require().NoError(c.addAccountFromMnemonic(4)) -// // Initialize a genesis file for the first validator -// val0ConfigDir := c.validators[0].configDir() -// var addrAll []sdk.AccAddress -// for _, val := range c.validators { -// address := val.keyInfo.GetAddress() -// addrAll = append(addrAll, address) -// } -// -// for _, addr := range c.genesisAccounts { -// acctAddr := addr.keyInfo.GetAddress() -// addrAll = append(addrAll, acctAddr) -// } -// -// s.Require().NoError( -// modifyGenesis(val0ConfigDir, "", initBalanceStr, addrAll, initialGlobalFeeAmt+uatomDenom, uatomDenom), -// ) -// // copy the genesis file to the remaining validators -// for _, val := range c.validators[1:] { -// _, err := copyFile( -// filepath.Join(val0ConfigDir, "config", "genesis.json"), -// filepath.Join(val.configDir(), "config", "genesis.json"), -// ) -// s.Require().NoError(err) -// } -//} -// -//// TODO find a better way to manipulate accounts to add genesis accounts -// func (s *IntegrationTestSuite) addGenesisVestingAndJailedAccounts( -// c *chain, -// valConfigDir, -// vestingMnemonic, -// jailedValMnemonic string, -// appGenState map[string]json.RawMessage, +// s.Require().NoError(c.createAndInitValidators(2)) +// /* Adding 4 accounts to val0 local directory +// c.genesisAccounts[0]: Relayer0 Wallet +// c.genesisAccounts[1]: ICA Owner +// c.genesisAccounts[2]: Test Account 1 +// c.genesisAccounts[3]: Test Account 2 +// c.genesisAccounts[4]: Relayer1 Wallet +// */ +// s.Require().NoError(c.addAccountFromMnemonic(5)) +// // Initialize a genesis file for the first validator +// val0ConfigDir := c.validators[0].configDir() +// var addrAll []sdk.AccAddress +// for _, val := range c.validators { +// address := val.keyInfo.GetAddress() +// addrAll = append(addrAll, address) +// } + +// for _, addr := range c.genesisAccounts { +// acctAddr := addr.keyInfo.GetAddress() +// addrAll = append(addrAll, acctAddr) +// } + +// s.Require().NoError( +// modifyGenesis(val0ConfigDir, "", initBalanceStr, addrAll, initialGlobalFeeAmt+uatomDenom, uatomDenom), +// ) +// // copy the genesis file to the remaining validators +// for _, val := range c.validators[1:] { +// _, err := copyFile( +// filepath.Join(val0ConfigDir, "config", "genesis.json"), +// filepath.Join(val.configDir(), "config", "genesis.json"), +// ) +// s.Require().NoError(err) +// } +// } + +// // TODO find a better way to manipulate accounts to add genesis accounts +// func (s *IntegrationTestSuite) addGenesisVestingAndJailedAccounts( +// c *chain, +// valConfigDir, +// vestingMnemonic, +// jailedValMnemonic string, +// appGenState map[string]json.RawMessage, // ) map[string]json.RawMessage { -// var ( -// authGenState = authtypes.GetGenesisStateFromAppState(cdc, appGenState) -// bankGenState = banktypes.GetGenesisStateFromAppState(cdc, appGenState) -// stakingGenState = stakingtypes.GetGenesisStateFromAppState(cdc, appGenState) -// ) -// -// // create genesis vesting accounts keys -// kb, err := keyring.New(keyringAppName, keyring.BackendTest, valConfigDir, nil) -// s.Require().NoError(err) -// -// keyringAlgos, _ := kb.SupportedAlgorithms() -// algo, err := keyring.NewSigningAlgoFromString(string(hd.Secp256k1Type), keyringAlgos) -// s.Require().NoError(err) -// -// // create jailed validator account keys -// jailedValKey, err := kb.NewAccount(jailedValidatorKey, jailedValMnemonic, "", sdk.FullFundraiserPath, algo) -// s.Require().NoError(err) -// -// // create genesis vesting accounts keys -// c.genesisVestingAccounts = make(map[string]sdk.AccAddress) -// for i, key := range genesisVestingKeys { -// // Use the first wallet from the same mnemonic by HD path -// acc, err := kb.NewAccount(key, vestingMnemonic, "", HDPath(i), algo) -// s.Require().NoError(err) -// c.genesisVestingAccounts[key] = acc.GetAddress() -// s.T().Logf("created %s genesis account %s\n", key, c.genesisVestingAccounts[key].String()) -// } -// var ( -// continuousVestingAcc = c.genesisVestingAccounts[continuousVestingKey] -// delayedVestingAcc = c.genesisVestingAccounts[delayedVestingKey] -// ) -// -// // add jailed validator to staking store -// pubKey := jailedValKey.GetPubKey() -// jailedValAcc := jailedValKey.GetAddress() -// jailedValAddr := sdk.ValAddress(jailedValAcc) -// val, err := stakingtypes.NewValidator( -// jailedValAddr, -// pubKey, -// stakingtypes.NewDescription("jailed", "", "", "", ""), -// ) -// s.Require().NoError(err) -// val.Jailed = true -// val.Tokens = sdk.NewInt(slashingShares) -// val.DelegatorShares = sdk.NewDec(slashingShares) -// stakingGenState.Validators = append(stakingGenState.Validators, val) -// -// // add jailed validator delegations -// stakingGenState.Delegations = append(stakingGenState.Delegations, stakingtypes.Delegation{ -// DelegatorAddress: jailedValAcc.String(), -// ValidatorAddress: jailedValAddr.String(), -// Shares: sdk.NewDec(slashingShares), -// }) -// -// appGenState[stakingtypes.ModuleName], err = cdc.MarshalJSON(stakingGenState) -// s.Require().NoError(err) -// -// // add jailed account to the genesis -// baseJailedAccount := authtypes.NewBaseAccount(jailedValAcc, pubKey, 0, 0) -// s.Require().NoError(baseJailedAccount.Validate()) -// -// // add continuous vesting account to the genesis -// baseVestingContinuousAccount := authtypes.NewBaseAccount( -// continuousVestingAcc, nil, 0, 0) -// vestingContinuousGenAccount := authvesting.NewContinuousVestingAccountRaw( -// authvesting.NewBaseVestingAccount( -// baseVestingContinuousAccount, -// sdk.NewCoins(vestingAmountVested), -// time.Now().Add(time.Duration(rand.Intn(80)+150)*time.Second).Unix(), -// ), -// time.Now().Add(time.Duration(rand.Intn(40)+90)*time.Second).Unix(), -// ) -// s.Require().NoError(vestingContinuousGenAccount.Validate()) -// -// // add delayed vesting account to the genesis -// baseVestingDelayedAccount := authtypes.NewBaseAccount( -// delayedVestingAcc, nil, 0, 0) -// vestingDelayedGenAccount := authvesting.NewDelayedVestingAccountRaw( -// authvesting.NewBaseVestingAccount( -// baseVestingDelayedAccount, -// sdk.NewCoins(vestingAmountVested), -// time.Now().Add(time.Duration(rand.Intn(40)+90)*time.Second).Unix(), -// ), -// ) -// s.Require().NoError(vestingDelayedGenAccount.Validate()) -// -// // unpack and append accounts -// accs, err := authtypes.UnpackAccounts(authGenState.Accounts) -// s.Require().NoError(err) -// accs = append(accs, vestingContinuousGenAccount, vestingDelayedGenAccount, baseJailedAccount) -// accs = authtypes.SanitizeGenesisAccounts(accs) -// genAccs, err := authtypes.PackAccounts(accs) -// s.Require().NoError(err) -// authGenState.Accounts = genAccs -// -// // update auth module state -// appGenState[authtypes.ModuleName], err = cdc.MarshalJSON(&authGenState) -// s.Require().NoError(err) -// -// // update balances -// vestingContinuousBalances := banktypes.Balance{ -// Address: continuousVestingAcc.String(), -// Coins: vestingBalance, -// } -// vestingDelayedBalances := banktypes.Balance{ -// Address: delayedVestingAcc.String(), -// Coins: vestingBalance, -// } -// jailedValidatorBalances := banktypes.Balance{ -// Address: jailedValAcc.String(), -// Coins: sdk.NewCoins(tokenAmount), -// } -// stakingModuleBalances := banktypes.Balance{ -// Address: authtypes.NewModuleAddress(stakingtypes.NotBondedPoolName).String(), -// Coins: sdk.NewCoins(sdk.NewCoin(uatomDenom, sdk.NewInt(slashingShares))), -// } -// bankGenState.Balances = append( -// bankGenState.Balances, -// vestingContinuousBalances, -// vestingDelayedBalances, -// jailedValidatorBalances, -// stakingModuleBalances, -// ) -// bankGenState.Balances = banktypes.SanitizeGenesisBalances(bankGenState.Balances) -// -// // update the denom metadata for the bank module -// bankGenState.DenomMetadata = append(bankGenState.DenomMetadata, banktypes.Metadata{ -// Description: "An example stable token", -// Display: uatomDenom, -// Base: uatomDenom, -// Symbol: uatomDenom, -// Name: uatomDenom, -// DenomUnits: []*banktypes.DenomUnit{ -// { -// Denom: uatomDenom, -// Exponent: 0, -// }, -// }, -// }) -// -// // update bank module state -// appGenState[banktypes.ModuleName], err = cdc.MarshalJSON(bankGenState) -// s.Require().NoError(err) -// -// return appGenState -//} -// -// func (s *IntegrationTestSuite) initGenesis(c *chain, vestingMnemonic, jailedValMnemonic string) { -// var ( -// serverCtx = server.NewDefaultContext() -// config = serverCtx.Config -// validator = c.validators[0] -// ) -// -// config.SetRoot(validator.configDir()) -// config.Moniker = validator.moniker -// -// genFilePath := config.GenesisFile() -// appGenState, genDoc, err := genutiltypes.GenesisStateFromGenFile(genFilePath) -// s.Require().NoError(err) -// -// appGenState = s.addGenesisVestingAndJailedAccounts( -// c, -// validator.configDir(), -// vestingMnemonic, -// jailedValMnemonic, -// appGenState, -// ) -// -// var evidenceGenState evidencetypes.GenesisState -// s.Require().NoError(cdc.UnmarshalJSON(appGenState[evidencetypes.ModuleName], &evidenceGenState)) -// -// evidenceGenState.Evidence = make([]*codectypes.Any, numberOfEvidences) -// for i := range evidenceGenState.Evidence { -// pk := ed25519.GenPrivKey() -// evidence := &evidencetypes.Equivocation{ -// Height: 1, -// Power: 100, -// Time: time.Now().UTC(), -// ConsensusAddress: sdk.ConsAddress(pk.PubKey().Address().Bytes()).String(), -// } -// evidenceGenState.Evidence[i], err = codectypes.NewAnyWithValue(evidence) -// s.Require().NoError(err) -// } -// -// appGenState[evidencetypes.ModuleName], err = cdc.MarshalJSON(&evidenceGenState) -// s.Require().NoError(err) -// -// var genUtilGenState genutiltypes.GenesisState -// s.Require().NoError(cdc.UnmarshalJSON(appGenState[genutiltypes.ModuleName], &genUtilGenState)) -// -// // generate genesis txs -// genTxs := make([]json.RawMessage, len(c.validators)) -// for i, val := range c.validators { -// createValmsg, err := val.buildCreateValidatorMsg(stakingAmountCoin) -// s.Require().NoError(err) -// signedTx, err := val.signMsg(createValmsg) -// -// s.Require().NoError(err) -// -// txRaw, err := cdc.MarshalJSON(signedTx) -// s.Require().NoError(err) -// -// genTxs[i] = txRaw -// } -// -// genUtilGenState.GenTxs = genTxs -// -// appGenState[genutiltypes.ModuleName], err = cdc.MarshalJSON(&genUtilGenState) -// s.Require().NoError(err) -// -// genDoc.AppState, err = json.MarshalIndent(appGenState, "", " ") -// s.Require().NoError(err) -// -// bz, err := tmjson.MarshalIndent(genDoc, "", " ") -// s.Require().NoError(err) -// -// vestingPeriod, err := generateVestingPeriod() -// s.Require().NoError(err) -// -// rawTx, _, err := buildRawTx() -// s.Require().NoError(err) -// -// // write the updated genesis file to each validator. -// for _, val := range c.validators { -// err = writeFile(filepath.Join(val.configDir(), "config", "genesis.json"), bz) -// s.Require().NoError(err) -// -// err = writeFile(filepath.Join(val.configDir(), vestingPeriodFile), vestingPeriod) -// s.Require().NoError(err) -// -// err = writeFile(filepath.Join(val.configDir(), rawTxFile), rawTx) -// s.Require().NoError(err) -// } -//} -// -//// initValidatorConfigs initializes the validator configs for the given chain. -// func (s *IntegrationTestSuite) initValidatorConfigs(c *chain) { -// for i, val := range c.validators { -// tmCfgPath := filepath.Join(val.configDir(), "config", "config.toml") -// -// vpr := viper.New() -// vpr.SetConfigFile(tmCfgPath) -// s.Require().NoError(vpr.ReadInConfig()) -// -// valConfig := tmconfig.DefaultConfig() -// -// s.Require().NoError(vpr.Unmarshal(valConfig)) -// -// valConfig.P2P.ListenAddress = "tcp://0.0.0.0:26656" -// valConfig.P2P.AddrBookStrict = false -// 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++ { -// if i == j { -// continue -// } -// -// peer := c.validators[j] -// peerID := fmt.Sprintf("%s@%s%d:26656", peer.nodeKey.ID(), peer.moniker, j) -// peers = append(peers, peerID) -// } -// -// valConfig.P2P.PersistentPeers = strings.Join(peers, ",") -// -// tmconfig.WriteConfigFile(tmCfgPath, valConfig) -// -// // set application configuration -// appCfgPath := filepath.Join(val.configDir(), "config", "app.toml") -// -// appConfig := srvconfig.DefaultConfig() -// appConfig.API.Enable = true -// appConfig.MinGasPrices = fmt.Sprintf("%s%s", minGasPrice, uatomDenom) -// -// srvconfig.SetConfigTemplate(srvconfig.DefaultConfigTemplate) -// srvconfig.WriteConfigFile(appCfgPath, appConfig) -// } -//} -// -//// runValidators runs the validators in the chain -// func (s *IntegrationTestSuite) runValidators(c *chain, portOffset int) { -// s.T().Logf("starting Gaia %s validator containers...", c.id) -// -// s.valResources[c.id] = make([]*dockertest.Resource, len(c.validators)) -// for i, val := range c.validators { -// runOpts := &dockertest.RunOptions{ -// Name: val.instanceName(), -// NetworkID: s.dkrNet.Network.ID, -// Mounts: []string{ -// fmt.Sprintf("%s/:%s", val.configDir(), gaiaHomePath), -// }, -// Repository: "cosmos/gaiad-e2e", -// } -// -// s.Require().NoError(exec.Command("chmod", "-R", "0777", val.configDir()).Run()) //nolint:gosec // this is a test -// -// // expose the first validator for debugging and communication -// 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)}}, -// "6061/tcp": {{HostIP: "", HostPort: fmt.Sprintf("%d", 6061+portOffset)}}, -// "6062/tcp": {{HostIP: "", HostPort: fmt.Sprintf("%d", 6062+portOffset)}}, -// "6063/tcp": {{HostIP: "", HostPort: fmt.Sprintf("%d", 6063+portOffset)}}, -// "6064/tcp": {{HostIP: "", HostPort: fmt.Sprintf("%d", 6064+portOffset)}}, -// "6065/tcp": {{HostIP: "", HostPort: fmt.Sprintf("%d", 6065+portOffset)}}, -// "9090/tcp": {{HostIP: "", HostPort: fmt.Sprintf("%d", 9090+portOffset)}}, -// "26656/tcp": {{HostIP: "", HostPort: fmt.Sprintf("%d", 26656+portOffset)}}, -// "26657/tcp": {{HostIP: "", HostPort: fmt.Sprintf("%d", 26657+portOffset)}}, -// } -// } -// -// resource, err := s.dkrPool.RunWithOptions(runOpts, noRestart) -// s.Require().NoError(err) -// -// s.valResources[c.id][i] = resource -// s.T().Logf("started Gaia %s validator container: %s", c.id, resource.Container.ID) -// } -// -// rpcClient, err := rpchttp.New("tcp://localhost:26657", "/websocket") -// s.Require().NoError(err) -// -// s.Require().Eventually( -// func() bool { -// ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) -// defer cancel() -// -// status, err := rpcClient.Status(ctx) -// if err != nil { -// return false -// } -// -// // let the node produce a few blocks -// if status.SyncInfo.CatchingUp || status.SyncInfo.LatestBlockHeight < 3 { -// return false -// } -// -// return true -// }, -// 5*time.Minute, -// time.Second, -// "Gaia node failed to produce blocks", -// ) -//} -// -// func noRestart(config *docker.HostConfig) { -// // in this case we don't want the nodes to restart on failure -// config.RestartPolicy = docker.RestartPolicy{ -// Name: "no", -// } -//} -// -// func (s *IntegrationTestSuite) writeGovParamChangeProposalGlobalFees(c *chain, coins sdk.DecCoins) { -// type ParamInfo struct { -// Subspace string `json:"subspace"` -// Key string `json:"key"` -// Value sdk.DecCoins `json:"value"` -// } -// -// type ParamChangeMessage struct { -// Title string `json:"title"` -// Description string `json:"description"` -// Changes []ParamInfo `json:"changes"` -// Deposit string `json:"deposit"` -// } -// -// paramChangeProposalBody, err := json.MarshalIndent(ParamChangeMessage{ -// Title: "global fee test", -// Description: "global fee change", -// Changes: []ParamInfo{ -// { -// Subspace: "globalfee", -// Key: "MinimumGasPricesParam", -// Value: coins, -// }, -// }, -// Deposit: "1000uatom", -// }, "", " ") -// s.Require().NoError(err) -// -// err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalGlobalFeeFilename), paramChangeProposalBody) -// s.Require().NoError(err) -//} -// -// func (s *IntegrationTestSuite) writeGovParamChangeProposalBypassMsgs(c *chain, msgs []string) { -// type ParamInfo struct { -// Subspace string `json:"subspace"` -// Key string `json:"key"` -// Value []string `json:"value"` -// } -// -// type ParamChangeMessage struct { -// Title string `json:"title"` -// Description string `json:"description"` -// Changes []ParamInfo `json:"changes"` -// Deposit string `json:"deposit"` -// } -// paramChangeProposalBody, err := json.MarshalIndent(ParamChangeMessage{ -// Title: "ChangeProposalBypassMsgs", -// Description: "global fee change", -// Changes: []ParamInfo{ -// { -// Subspace: "globalfee", -// Key: "BypassMinFeeMsgTypes", -// Value: msgs, -// }, -// }, -// Deposit: "1000uatom", -// }, "", " ") -// s.Require().NoError(err) -// -// err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalBypassMsgFilename), paramChangeProposalBody) -// s.Require().NoError(err) -//} -// -// func (s *IntegrationTestSuite) writeGovParamChangeProposalMaxTotalBypass(c *chain, gas uint64) { -// type ParamInfo struct { -// Subspace string `json:"subspace"` -// Key string `json:"key"` -// Value string `json:"value"` -// } -// -// type ParamChangeMessage struct { -// Title string `json:"title"` -// Description string `json:"description"` -// Changes []ParamInfo `json:"changes"` -// Deposit string `json:"deposit"` -// } -// paramChangeProposalBody, err := json.MarshalIndent(ParamChangeMessage{ -// Title: "ChangeProposalMaxTotalBypass", -// Description: "global fee change", -// Changes: []ParamInfo{ -// { -// Subspace: "globalfee", -// Key: "MaxTotalBypassMinFeeMsgGasUsage", -// Value: strconv.FormatInt(int64(gas), 10), -// }, -// }, -// Deposit: "1000uatom", -// }, "", " ") -// s.Require().NoError(err) -// -// err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalMaxTotalBypassFilename), paramChangeProposalBody) -// s.Require().NoError(err) -//} -// +// var ( +// authGenState = authtypes.GetGenesisStateFromAppState(cdc, appGenState) +// bankGenState = banktypes.GetGenesisStateFromAppState(cdc, appGenState) +// stakingGenState = stakingtypes.GetGenesisStateFromAppState(cdc, appGenState) +// ) + +// // create genesis vesting accounts keys +// kb, err := keyring.New(keyringAppName, keyring.BackendTest, valConfigDir, nil) +// s.Require().NoError(err) + +// keyringAlgos, _ := kb.SupportedAlgorithms() +// algo, err := keyring.NewSigningAlgoFromString(string(hd.Secp256k1Type), keyringAlgos) +// s.Require().NoError(err) + +// // create jailed validator account keys +// jailedValKey, err := kb.NewAccount(jailedValidatorKey, jailedValMnemonic, "", sdk.FullFundraiserPath, algo) +// s.Require().NoError(err) + +// // create genesis vesting accounts keys +// c.genesisVestingAccounts = make(map[string]sdk.AccAddress) +// for i, key := range genesisVestingKeys { +// // Use the first wallet from the same mnemonic by HD path +// acc, err := kb.NewAccount(key, vestingMnemonic, "", HDPath(i), algo) +// s.Require().NoError(err) +// c.genesisVestingAccounts[key] = acc.GetAddress() +// s.T().Logf("created %s genesis account %s\n", key, c.genesisVestingAccounts[key].String()) +// } +// var ( +// continuousVestingAcc = c.genesisVestingAccounts[continuousVestingKey] +// delayedVestingAcc = c.genesisVestingAccounts[delayedVestingKey] +// ) + +// // add jailed validator to staking store +// pubKey := jailedValKey.GetPubKey() +// jailedValAcc := jailedValKey.GetAddress() +// jailedValAddr := sdk.ValAddress(jailedValAcc) +// val, err := stakingtypes.NewValidator( +// jailedValAddr, +// pubKey, +// stakingtypes.NewDescription("jailed", "", "", "", ""), +// ) +// s.Require().NoError(err) +// val.Jailed = true +// val.Tokens = sdk.NewInt(slashingShares) +// val.DelegatorShares = sdk.NewDec(slashingShares) +// stakingGenState.Validators = append(stakingGenState.Validators, val) + +// // add jailed validator delegations +// stakingGenState.Delegations = append(stakingGenState.Delegations, stakingtypes.Delegation{ +// DelegatorAddress: jailedValAcc.String(), +// ValidatorAddress: jailedValAddr.String(), +// Shares: sdk.NewDec(slashingShares), +// }) + +// appGenState[stakingtypes.ModuleName], err = cdc.MarshalJSON(stakingGenState) +// s.Require().NoError(err) + +// // add jailed account to the genesis +// baseJailedAccount := authtypes.NewBaseAccount(jailedValAcc, pubKey, 0, 0) +// s.Require().NoError(baseJailedAccount.Validate()) + +// // add continuous vesting account to the genesis +// baseVestingContinuousAccount := authtypes.NewBaseAccount( +// continuousVestingAcc, nil, 0, 0) +// vestingContinuousGenAccount := authvesting.NewContinuousVestingAccountRaw( +// authvesting.NewBaseVestingAccount( +// baseVestingContinuousAccount, +// sdk.NewCoins(vestingAmountVested), +// time.Now().Add(time.Duration(rand.Intn(80)+150)*time.Second).Unix(), +// ), +// time.Now().Add(time.Duration(rand.Intn(40)+90)*time.Second).Unix(), +// ) +// s.Require().NoError(vestingContinuousGenAccount.Validate()) + +// // add delayed vesting account to the genesis +// baseVestingDelayedAccount := authtypes.NewBaseAccount( +// delayedVestingAcc, nil, 0, 0) +// vestingDelayedGenAccount := authvesting.NewDelayedVestingAccountRaw( +// authvesting.NewBaseVestingAccount( +// baseVestingDelayedAccount, +// sdk.NewCoins(vestingAmountVested), +// time.Now().Add(time.Duration(rand.Intn(40)+90)*time.Second).Unix(), +// ), +// ) +// s.Require().NoError(vestingDelayedGenAccount.Validate()) + +// // unpack and append accounts +// accs, err := authtypes.UnpackAccounts(authGenState.Accounts) +// s.Require().NoError(err) +// accs = append(accs, vestingContinuousGenAccount, vestingDelayedGenAccount, baseJailedAccount) +// accs = authtypes.SanitizeGenesisAccounts(accs) +// genAccs, err := authtypes.PackAccounts(accs) +// s.Require().NoError(err) +// authGenState.Accounts = genAccs + +// // update auth module state +// appGenState[authtypes.ModuleName], err = cdc.MarshalJSON(&authGenState) +// s.Require().NoError(err) + +// // update balances +// vestingContinuousBalances := banktypes.Balance{ +// Address: continuousVestingAcc.String(), +// Coins: vestingBalance, +// } +// vestingDelayedBalances := banktypes.Balance{ +// Address: delayedVestingAcc.String(), +// Coins: vestingBalance, +// } +// jailedValidatorBalances := banktypes.Balance{ +// Address: jailedValAcc.String(), +// Coins: sdk.NewCoins(tokenAmount), +// } +// stakingModuleBalances := banktypes.Balance{ +// Address: authtypes.NewModuleAddress(stakingtypes.NotBondedPoolName).String(), +// Coins: sdk.NewCoins(sdk.NewCoin(uatomDenom, sdk.NewInt(slashingShares))), +// } +// bankGenState.Balances = append( +// bankGenState.Balances, +// vestingContinuousBalances, +// vestingDelayedBalances, +// jailedValidatorBalances, +// stakingModuleBalances, +// ) +// bankGenState.Balances = banktypes.SanitizeGenesisBalances(bankGenState.Balances) + +// // update the denom metadata for the bank module +// bankGenState.DenomMetadata = append(bankGenState.DenomMetadata, banktypes.Metadata{ +// Description: "An example stable token", +// Display: uatomDenom, +// Base: uatomDenom, +// Symbol: uatomDenom, +// Name: uatomDenom, +// DenomUnits: []*banktypes.DenomUnit{ +// { +// Denom: uatomDenom, +// Exponent: 0, +// }, +// }, +// }) + +// // update bank module state +// appGenState[banktypes.ModuleName], err = cdc.MarshalJSON(bankGenState) +// s.Require().NoError(err) + +// return appGenState +// } + +// func (s *IntegrationTestSuite) initGenesis(c *chain, vestingMnemonic, jailedValMnemonic string) { +// var ( +// serverCtx = server.NewDefaultContext() +// config = serverCtx.Config +// validator = c.validators[0] +// ) + +// config.SetRoot(validator.configDir()) +// config.Moniker = validator.moniker + +// genFilePath := config.GenesisFile() +// appGenState, genDoc, err := genutiltypes.GenesisStateFromGenFile(genFilePath) +// s.Require().NoError(err) + +// appGenState = s.addGenesisVestingAndJailedAccounts( +// c, +// validator.configDir(), +// vestingMnemonic, +// jailedValMnemonic, +// appGenState, +// ) + +// var evidenceGenState evidencetypes.GenesisState +// s.Require().NoError(cdc.UnmarshalJSON(appGenState[evidencetypes.ModuleName], &evidenceGenState)) + +// evidenceGenState.Evidence = make([]*codectypes.Any, numberOfEvidences) +// for i := range evidenceGenState.Evidence { +// pk := ed25519.GenPrivKey() +// evidence := &evidencetypes.Equivocation{ +// Height: 1, +// Power: 100, +// Time: time.Now().UTC(), +// ConsensusAddress: sdk.ConsAddress(pk.PubKey().Address().Bytes()).String(), +// } +// evidenceGenState.Evidence[i], err = codectypes.NewAnyWithValue(evidence) +// s.Require().NoError(err) +// } + +// appGenState[evidencetypes.ModuleName], err = cdc.MarshalJSON(&evidenceGenState) +// s.Require().NoError(err) + +// var genUtilGenState genutiltypes.GenesisState +// s.Require().NoError(cdc.UnmarshalJSON(appGenState[genutiltypes.ModuleName], &genUtilGenState)) + +// // generate genesis txs +// genTxs := make([]json.RawMessage, len(c.validators)) +// for i, val := range c.validators { +// createValmsg, err := val.buildCreateValidatorMsg(stakingAmountCoin) +// s.Require().NoError(err) +// signedTx, err := val.signMsg(createValmsg) + +// s.Require().NoError(err) + +// txRaw, err := cdc.MarshalJSON(signedTx) +// s.Require().NoError(err) + +// genTxs[i] = txRaw +// } + +// genUtilGenState.GenTxs = genTxs + +// appGenState[genutiltypes.ModuleName], err = cdc.MarshalJSON(&genUtilGenState) +// s.Require().NoError(err) + +// genDoc.AppState, err = json.MarshalIndent(appGenState, "", " ") +// s.Require().NoError(err) + +// bz, err := tmjson.MarshalIndent(genDoc, "", " ") +// s.Require().NoError(err) + +// vestingPeriod, err := generateVestingPeriod() +// s.Require().NoError(err) + +// rawTx, _, err := buildRawTx() +// s.Require().NoError(err) + +// // write the updated genesis file to each validator. +// for _, val := range c.validators { +// err = writeFile(filepath.Join(val.configDir(), "config", "genesis.json"), bz) +// s.Require().NoError(err) + +// err = writeFile(filepath.Join(val.configDir(), vestingPeriodFile), vestingPeriod) +// s.Require().NoError(err) + +// err = writeFile(filepath.Join(val.configDir(), rawTxFile), rawTx) +// s.Require().NoError(err) +// } +// } + +// // initValidatorConfigs initializes the validator configs for the given chain. +// func (s *IntegrationTestSuite) initValidatorConfigs(c *chain) { +// for i, val := range c.validators { +// tmCfgPath := filepath.Join(val.configDir(), "config", "config.toml") + +// vpr := viper.New() +// vpr.SetConfigFile(tmCfgPath) +// s.Require().NoError(vpr.ReadInConfig()) + +// valConfig := tmconfig.DefaultConfig() + +// s.Require().NoError(vpr.Unmarshal(valConfig)) + +// valConfig.P2P.ListenAddress = "tcp://0.0.0.0:26656" +// valConfig.P2P.AddrBookStrict = false +// 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++ { +// if i == j { +// continue +// } + +// peer := c.validators[j] +// peerID := fmt.Sprintf("%s@%s%d:26656", peer.nodeKey.ID(), peer.moniker, j) +// peers = append(peers, peerID) +// } + +// valConfig.P2P.PersistentPeers = strings.Join(peers, ",") + +// tmconfig.WriteConfigFile(tmCfgPath, valConfig) + +// // set application configuration +// appCfgPath := filepath.Join(val.configDir(), "config", "app.toml") + +// appConfig := srvconfig.DefaultConfig() +// appConfig.API.Enable = true +// appConfig.MinGasPrices = fmt.Sprintf("%s%s", minGasPrice, uatomDenom) + +// srvconfig.SetConfigTemplate(srvconfig.DefaultConfigTemplate) +// srvconfig.WriteConfigFile(appCfgPath, appConfig) +// } +// } + +// // runValidators runs the validators in the chain +// func (s *IntegrationTestSuite) runValidators(c *chain, portOffset int) { +// s.T().Logf("starting Gaia %s validator containers...", c.id) + +// s.valResources[c.id] = make([]*dockertest.Resource, len(c.validators)) +// for i, val := range c.validators { +// runOpts := &dockertest.RunOptions{ +// Name: val.instanceName(), +// NetworkID: s.dkrNet.Network.ID, +// Mounts: []string{ +// fmt.Sprintf("%s/:%s", val.configDir(), gaiaHomePath), +// }, +// Repository: "cosmos/gaiad-e2e", +// } + +// s.Require().NoError(exec.Command("chmod", "-R", "0777", val.configDir()).Run()) //nolint:gosec // this is a test + +// // expose the first validator for debugging and communication +// 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)}}, +// "6061/tcp": {{HostIP: "", HostPort: fmt.Sprintf("%d", 6061+portOffset)}}, +// "6062/tcp": {{HostIP: "", HostPort: fmt.Sprintf("%d", 6062+portOffset)}}, +// "6063/tcp": {{HostIP: "", HostPort: fmt.Sprintf("%d", 6063+portOffset)}}, +// "6064/tcp": {{HostIP: "", HostPort: fmt.Sprintf("%d", 6064+portOffset)}}, +// "6065/tcp": {{HostIP: "", HostPort: fmt.Sprintf("%d", 6065+portOffset)}}, +// "9090/tcp": {{HostIP: "", HostPort: fmt.Sprintf("%d", 9090+portOffset)}}, +// "26656/tcp": {{HostIP: "", HostPort: fmt.Sprintf("%d", 26656+portOffset)}}, +// "26657/tcp": {{HostIP: "", HostPort: fmt.Sprintf("%d", 26657+portOffset)}}, +// } +// } + +// resource, err := s.dkrPool.RunWithOptions(runOpts, noRestart) +// s.Require().NoError(err) + +// s.valResources[c.id][i] = resource +// s.T().Logf("started Gaia %s validator container: %s", c.id, resource.Container.ID) +// } + +// rpcClient, err := rpchttp.New("tcp://localhost:26657", "/websocket") +// s.Require().NoError(err) + +// s.Require().Eventually( +// func() bool { +// ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) +// defer cancel() + +// status, err := rpcClient.Status(ctx) +// if err != nil { +// return false +// } + +// // let the node produce a few blocks +// if status.SyncInfo.CatchingUp || status.SyncInfo.LatestBlockHeight < 3 { +// return false +// } + +// return true +// }, +// 5*time.Minute, +// time.Second, +// "Gaia node failed to produce blocks", +// ) +// } + +// func noRestart(config *docker.HostConfig) { +// // in this case we don't want the nodes to restart on failure +// config.RestartPolicy = docker.RestartPolicy{ +// Name: "no", +// } +// } + +// // hermes0 is for ibc and packet-forward-middleware(PFM) test, hermes0 is keep running during the ibc and PFM test. +// func (s *IntegrationTestSuite) runIBCRelayer0() { +// s.T().Log("starting Hermes relayer container 0...") + +// tmpDir, err := os.MkdirTemp("", "gaia-e2e-testnet-hermes-") +// s.Require().NoError(err) +// s.tmpDirs = append(s.tmpDirs, tmpDir) + +// gaiaAVal := s.chainA.validators[0] +// gaiaBVal := s.chainB.validators[0] + +// gaiaARly := s.chainA.genesisAccounts[relayerAccountIndexHermes0] +// gaiaBRly := s.chainB.genesisAccounts[relayerAccountIndexHermes0] + +// hermesCfgPath := path.Join(tmpDir, "hermes") + +// s.Require().NoError(os.MkdirAll(hermesCfgPath, 0o755)) +// _, err = copyFile( +// filepath.Join("./scripts/", "hermes_bootstrap.sh"), +// filepath.Join(hermesCfgPath, "hermes_bootstrap.sh"), +// ) +// s.Require().NoError(err) + +// s.hermesResource0, err = s.dkrPool.RunWithOptions( +// &dockertest.RunOptions{ +// Name: fmt.Sprintf("%s-%s-relayer-0", s.chainA.id, s.chainB.id), +// Repository: "ghcr.io/cosmos/hermes-e2e", +// Tag: "1.0.0", +// NetworkID: s.dkrNet.Network.ID, +// Mounts: []string{ +// fmt.Sprintf("%s/:/root/hermes", hermesCfgPath), +// }, +// PortBindings: map[docker.Port][]docker.PortBinding{ +// "3031/tcp": {{HostIP: "", HostPort: "3031"}}, +// }, +// Env: []string{ +// fmt.Sprintf("GAIA_A_E2E_CHAIN_ID=%s", s.chainA.id), +// fmt.Sprintf("GAIA_B_E2E_CHAIN_ID=%s", s.chainB.id), +// fmt.Sprintf("GAIA_A_E2E_VAL_MNEMONIC=%s", gaiaAVal.mnemonic), +// fmt.Sprintf("GAIA_B_E2E_VAL_MNEMONIC=%s", gaiaBVal.mnemonic), +// fmt.Sprintf("GAIA_A_E2E_RLY_MNEMONIC=%s", gaiaARly.mnemonic), +// fmt.Sprintf("GAIA_B_E2E_RLY_MNEMONIC=%s", gaiaBRly.mnemonic), +// fmt.Sprintf("GAIA_A_E2E_VAL_HOST=%s", s.valResources[s.chainA.id][0].Container.Name[1:]), +// fmt.Sprintf("GAIA_B_E2E_VAL_HOST=%s", s.valResources[s.chainB.id][0].Container.Name[1:]), +// }, +// Entrypoint: []string{ +// "sh", +// "-c", +// "chmod +x /root/hermes/hermes_bootstrap.sh && /root/hermes/hermes_bootstrap.sh", +// }, +// }, +// noRestart, +// ) +// s.Require().NoError(err) + +// endpoint := fmt.Sprintf("http://%s/state", s.hermesResource0.GetHostPort("3031/tcp")) +// s.Require().Eventually( +// func() bool { +// resp, err := http.Get(endpoint) //nolint:gosec // this is a test +// if err != nil { +// return false +// } + +// defer resp.Body.Close() + +// bz, err := io.ReadAll(resp.Body) +// if err != nil { +// return false +// } + +// var respBody map[string]interface{} +// if err := json.Unmarshal(bz, &respBody); err != nil { +// return false +// } + +// status := respBody["status"].(string) +// result := respBody["result"].(map[string]interface{}) + +// return status == "success" && len(result["chains"].([]interface{})) == 2 +// }, +// 5*time.Minute, +// time.Second, +// "hermes relayer not healthy", +// ) + +// s.T().Logf("started Hermes relayer 0 container: %s", s.hermesResource0.Container.ID) + +// // XXX: Give time to both networks to start, otherwise we might see gRPC +// // transport errors. +// time.Sleep(10 * time.Second) + +// // create the client, connection and channel between the two Gaia chains +// s.createConnection() +// time.Sleep(10 * time.Second) +// s.createChannel() +// } + +// // hermes1 is for bypass-msg test. Hermes1 is to process asynchronous transactions, +// // Hermes1 has access to two Hermes configurations: one configuration allows paying fees, while the other does not. +// // With Hermes1, better control can be achieved regarding whether fees are paid when clearing transactions. +// func (s *IntegrationTestSuite) runIBCRelayer1() { +// s.T().Log("starting Hermes relayer container 1...") + +// tmpDir, err := os.MkdirTemp("", "gaia-e2e-testnet-hermes-") +// s.Require().NoError(err) +// s.tmpDirs = append(s.tmpDirs, tmpDir) + +// gaiaAVal := s.chainA.validators[0] +// gaiaBVal := s.chainB.validators[0] + +// gaiaARly := s.chainA.genesisAccounts[relayerAccountIndexHermes1] +// gaiaBRly := s.chainB.genesisAccounts[relayerAccountIndexHermes1] + +// hermesCfgPath := path.Join(tmpDir, "hermes") + +// s.Require().NoError(os.MkdirAll(hermesCfgPath, 0o755)) +// _, err = copyFile( +// filepath.Join("./scripts/", "hermes1_bootstrap.sh"), +// filepath.Join(hermesCfgPath, "hermes1_bootstrap.sh"), +// ) +// s.Require().NoError(err) + +// s.hermesResource1, err = s.dkrPool.RunWithOptions( +// &dockertest.RunOptions{ +// Name: fmt.Sprintf("%s-%s-relayer-1", s.chainA.id, s.chainB.id), +// Repository: "ghcr.io/cosmos/hermes-e2e", +// Tag: "1.0.0", +// NetworkID: s.dkrNet.Network.ID, +// Mounts: []string{ +// fmt.Sprintf("%s/:/root/hermes", hermesCfgPath), +// }, +// PortBindings: map[docker.Port][]docker.PortBinding{ +// "3032/tcp": {{HostIP: "", HostPort: "3032"}}, +// }, +// Env: []string{ +// fmt.Sprintf("GAIA_A_E2E_CHAIN_ID=%s", s.chainA.id), +// fmt.Sprintf("GAIA_B_E2E_CHAIN_ID=%s", s.chainB.id), +// fmt.Sprintf("GAIA_A_E2E_VAL_MNEMONIC=%s", gaiaAVal.mnemonic), +// fmt.Sprintf("GAIA_B_E2E_VAL_MNEMONIC=%s", gaiaBVal.mnemonic), +// fmt.Sprintf("GAIA_A_E2E_RLY_MNEMONIC=%s", gaiaARly.mnemonic), +// fmt.Sprintf("GAIA_B_E2E_RLY_MNEMONIC=%s", gaiaBRly.mnemonic), +// fmt.Sprintf("GAIA_A_E2E_VAL_HOST=%s", s.valResources[s.chainA.id][0].Container.Name[1:]), +// fmt.Sprintf("GAIA_B_E2E_VAL_HOST=%s", s.valResources[s.chainB.id][0].Container.Name[1:]), +// }, +// Entrypoint: []string{ +// "sh", +// "-c", +// "chmod +x /root/hermes/hermes1_bootstrap.sh && /root/hermes/hermes1_bootstrap.sh && tail -f /dev/null", +// }, +// }, +// noRestart, +// ) +// s.Require().NoError(err) + +// s.T().Logf("started Hermes relayer 1 container: %s", s.hermesResource1.Container.ID) + +// // XXX: Give time to both networks to start, otherwise we might see gRPC +// // transport errors. +// time.Sleep(10 * time.Second) +// } + +// func (s *IntegrationTestSuite) writeGovParamChangeProposalGlobalFees(c *chain, coins sdk.DecCoins) { +// type ParamInfo struct { +// Subspace string `json:"subspace"` +// Key string `json:"key"` +// Value sdk.DecCoins `json:"value"` +// } + +// type ParamChangeMessage struct { +// Title string `json:"title"` +// Description string `json:"description"` +// Changes []ParamInfo `json:"changes"` +// Deposit string `json:"deposit"` +// } + +// paramChangeProposalBody, err := json.MarshalIndent(ParamChangeMessage{ +// Title: "global fee test", +// Description: "global fee change", +// Changes: []ParamInfo{ +// { +// Subspace: "globalfee", +// Key: "MinimumGasPricesParam", +// Value: coins, +// }, +// }, +// Deposit: "1000uatom", +// }, "", " ") +// s.Require().NoError(err) + +// err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalGlobalFeeFilename), paramChangeProposalBody) +// s.Require().NoError(err) +// } + +// func (s *IntegrationTestSuite) writeGovParamChangeProposalBypassMsgs(c *chain, msgs []string) { +// type ParamInfo struct { +// Subspace string `json:"subspace"` +// Key string `json:"key"` +// Value []string `json:"value"` +// } + +// type ParamChangeMessage struct { +// Title string `json:"title"` +// Description string `json:"description"` +// Changes []ParamInfo `json:"changes"` +// Deposit string `json:"deposit"` +// } +// paramChangeProposalBody, err := json.MarshalIndent(ParamChangeMessage{ +// Title: "ChangeProposalBypassMsgs", +// Description: "global fee change", +// Changes: []ParamInfo{ +// { +// Subspace: "globalfee", +// Key: "BypassMinFeeMsgTypes", +// Value: msgs, +// }, +// }, +// Deposit: "1000uatom", +// }, "", " ") +// s.Require().NoError(err) + +// err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalBypassMsgFilename), paramChangeProposalBody) +// s.Require().NoError(err) +// } + +// func (s *IntegrationTestSuite) writeGovParamChangeProposalMaxTotalBypass(c *chain, gas uint64) { +// type ParamInfo struct { +// Subspace string `json:"subspace"` +// Key string `json:"key"` +// Value string `json:"value"` +// } + +// type ParamChangeMessage struct { +// Title string `json:"title"` +// Description string `json:"description"` +// Changes []ParamInfo `json:"changes"` +// Deposit string `json:"deposit"` +// } +// paramChangeProposalBody, err := json.MarshalIndent(ParamChangeMessage{ +// Title: "ChangeProposalMaxTotalBypass", +// Description: "global fee change", +// Changes: []ParamInfo{ +// { +// Subspace: "globalfee", +// Key: "MaxTotalBypassMinFeeMsgGasUsage", +// Value: strconv.FormatInt(int64(gas), 10), +// }, +// }, +// Deposit: "1000uatom", +// }, "", " ") +// s.Require().NoError(err) + +// err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalMaxTotalBypassFilename), paramChangeProposalBody) +// s.Require().NoError(err) +// } + // func (s *IntegrationTestSuite) writeGovCommunitySpendProposal(c *chain, amount string, recipient string) { -// proposalCommSpend := &distrtypes.CommunityPoolSpendProposalWithDeposit{ -// Title: "Community Pool Spend", -// Description: "Fund Team!", -// Recipient: recipient, -// Amount: amount, -// Deposit: "1000uatom", -// } -// commSpendBody, err := json.MarshalIndent(proposalCommSpend, "", " ") -// s.Require().NoError(err) -// -// err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalCommunitySpendFilename), commSpendBody) -// s.Require().NoError(err) -//} -// +// proposalCommSpend := &distrtypes.CommunityPoolSpendProposalWithDeposit{ +// Title: "Community Pool Spend", +// Description: "Fund Team!", +// Recipient: recipient, +// Amount: amount, +// Deposit: "1000uatom", +// } +// commSpendBody, err := json.MarshalIndent(proposalCommSpend, "", " ") +// s.Require().NoError(err) + +// err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalCommunitySpendFilename), commSpendBody) +// s.Require().NoError(err) +// } + // type ConsumerAdditionProposalWithDeposit struct { -// ccvprovider.ConsumerAdditionProposal -// Deposit string `json:"deposit"` -//} -// +// ccvprovider.ConsumerAdditionProposal +// Deposit string `json:"deposit"` +// } + // type ConsumerRemovalProposalWithDeposit struct { -// ccvprovider.ConsumerRemovalProposal -// Deposit string `json:"deposit"` -//} -// +// ccvprovider.ConsumerRemovalProposal +// Deposit string `json:"deposit"` +// } + // func (s *IntegrationTestSuite) writeAddRemoveConsumerProposals(c *chain, consumerChainID string) { -// hash, _ := json.Marshal("Z2VuX2hhc2g=") -// addProp := &ccvprovider.ConsumerAdditionProposal{ -// Title: "Create consumer chain", -// Description: "First consumer chain", -// ChainId: consumerChainID, -// InitialHeight: ibcclienttypes.Height{ -// RevisionHeight: 1, -// }, -// GenesisHash: hash, -// BinaryHash: hash, -// SpawnTime: time.Now(), -// UnbondingPeriod: time.Duration(100000000000), -// CcvTimeoutPeriod: time.Duration(100000000000), -// TransferTimeoutPeriod: time.Duration(100000000000), -// ConsumerRedistributionFraction: "0.75", -// BlocksPerDistributionTransmission: 10, -// HistoricalEntries: 10000, -// } -// addPropWithDeposit := ConsumerAdditionProposalWithDeposit{ -// ConsumerAdditionProposal: *addProp, -// Deposit: "1000uatom", -// } -// -// removeProp := &ccvprovider.ConsumerRemovalProposal{ -// Title: "Remove consumer chain", -// Description: "Removing consumer chain", -// ChainId: consumerChainID, -// StopTime: time.Now(), -// } -// -// removePropWithDeposit := ConsumerRemovalProposalWithDeposit{ -// ConsumerRemovalProposal: *removeProp, -// Deposit: "1000uatom", -// } -// -// consumerAddBody, err := json.MarshalIndent(addPropWithDeposit, "", " ") -// s.Require().NoError(err) -// -// consumerRemoveBody, err := json.MarshalIndent(removePropWithDeposit, "", " ") -// s.Require().NoError(err) -// -// err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalAddConsumerChainFilename), consumerAddBody) -// s.Require().NoError(err) -// err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalRemoveConsumerChainFilename), consumerRemoveBody) -// s.Require().NoError(err) -//} -// +// hash, _ := json.Marshal("Z2VuX2hhc2g=") +// addProp := &ccvprovider.ConsumerAdditionProposal{ +// Title: "Create consumer chain", +// Description: "First consumer chain", +// ChainId: consumerChainID, +// InitialHeight: ibcclienttypes.Height{ +// RevisionHeight: 1, +// }, +// GenesisHash: hash, +// BinaryHash: hash, +// SpawnTime: time.Now(), +// UnbondingPeriod: time.Duration(100000000000), +// CcvTimeoutPeriod: time.Duration(100000000000), +// TransferTimeoutPeriod: time.Duration(100000000000), +// ConsumerRedistributionFraction: "0.75", +// BlocksPerDistributionTransmission: 10, +// HistoricalEntries: 10000, +// } +// addPropWithDeposit := ConsumerAdditionProposalWithDeposit{ +// ConsumerAdditionProposal: *addProp, +// Deposit: "1000uatom", +// } + +// removeProp := &ccvprovider.ConsumerRemovalProposal{ +// Title: "Remove consumer chain", +// Description: "Removing consumer chain", +// ChainId: consumerChainID, +// StopTime: time.Now(), +// } + +// removePropWithDeposit := ConsumerRemovalProposalWithDeposit{ +// ConsumerRemovalProposal: *removeProp, +// Deposit: "1000uatom", +// } + +// consumerAddBody, err := json.MarshalIndent(addPropWithDeposit, "", " ") +// s.Require().NoError(err) + +// consumerRemoveBody, err := json.MarshalIndent(removePropWithDeposit, "", " ") +// s.Require().NoError(err) + +// err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalAddConsumerChainFilename), consumerAddBody) +// s.Require().NoError(err) +// err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalRemoveConsumerChainFilename), consumerRemoveBody) +// s.Require().NoError(err) +// } + // func configFile(filename string) string { -// filepath := filepath.Join(gaiaConfigPath, filename) -// return filepath -//} +// filepath := filepath.Join(gaiaConfigPath, filename) +// return filepath +// } diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index dcacda99b88..955d5a8bea4 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -1,118 +1,123 @@ package e2e // import ( -// "fmt" -//) -// +// "fmt" +// ) + // var ( -// runBankTest = true -// runBypassMinFeeTest = true -// runEncodeTest = true -// runEvidenceTest = true -// runFeeGrantTest = true -// runGlobalFeesTest = true -// runGovTest = true -// runIBCTest = true -// runSlashingTest = true -// runStakingAndDistributionTest = true -// runVestingTest = true -// runRestInterfacesTest = true -//) -// +// runBankTest = true +// runBypassMinFeeTest = true +// runEncodeTest = true +// runEvidenceTest = true +// runFeeGrantTest = true +// runGlobalFeesTest = true +// runGovTest = true +// runIBCTest = true +// runSlashingTest = true +// runStakingAndDistributionTest = true +// runVestingTest = true +// runRestInterfacesTest = true +// ) + // func (s *IntegrationTestSuite) TestRestInterfaces() { -// if !runRestInterfacesTest { -// s.T().Skip() -// } -// s.testRestInterfaces() -//} -// +// if !runRestInterfacesTest { +// s.T().Skip() +// } +// s.testRestInterfaces() +// } + // func (s *IntegrationTestSuite) TestBank() { -// if !runBankTest { -// s.T().Skip() -// } -// s.testBankTokenTransfer() -//} -// +// if !runBankTest { +// s.T().Skip() +// } +// s.testBankTokenTransfer() +// } + // func (s *IntegrationTestSuite) TestByPassMinFee() { -// if !runBypassMinFeeTest { -// s.T().Skip() -// } -// chainAPI := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) -// s.testBypassMinFeeWithdrawReward(chainAPI) -//} -// +// if !runBypassMinFeeTest { +// s.T().Skip() +// } +// chainAPI := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) +// s.testBypassMinFeeWithdrawReward(chainAPI) +// } + // func (s *IntegrationTestSuite) TestEncode() { -// if !runEncodeTest { -// s.T().Skip() -// } -// s.testEncode() -// s.testDecode() -//} -// +// if !runEncodeTest { +// s.T().Skip() +// } +// s.testEncode() +// s.testDecode() +// } + // func (s *IntegrationTestSuite) TestEvidence() { -// if !runEvidenceTest { -// s.T().Skip() -// } -// s.testEvidence() -//} -// +// if !runEvidenceTest { +// s.T().Skip() +// } +// s.testEvidence() +// } + // func (s *IntegrationTestSuite) TestFeeGrant() { -// if !runFeeGrantTest { -// s.T().Skip() -// } -// s.testFeeGrant() -//} -// +// if !runFeeGrantTest { +// s.T().Skip() +// } +// s.testFeeGrant() +// } + // func (s *IntegrationTestSuite) TestGlobalFees() { -// if !runGlobalFeesTest { -// s.T().Skip() -// } -// s.testGlobalFees() -// s.testQueryGlobalFeesInGenesis() -//} -// +// if !runGlobalFeesTest { +// s.T().Skip() +// } +// s.testGlobalFees() +// s.testQueryGlobalFeesInGenesis() +// } + // func (s *IntegrationTestSuite) TestGov() { -// if !runGovTest { -// s.T().Skip() -// } -// s.GovSoftwareUpgrade() -// s.GovCancelSoftwareUpgrade() -// s.GovCommunityPoolSpend() -// s.AddRemoveConsumerChain() -//} -// +// if !runGovTest { +// s.T().Skip() +// } +// s.GovSoftwareUpgrade() +// s.GovCancelSoftwareUpgrade() +// s.GovCommunityPoolSpend() +// s.AddRemoveConsumerChain() +// } + // func (s *IntegrationTestSuite) TestIBC() { -// if !runIBCTest { -// s.T().Skip() -// } -// s.testIBCTokenTransfer() -// s.testMultihopIBCTokenTransfer() -// s.testFailedMultihopIBCTokenTransfer() -//} -// +// if !runIBCTest { +// s.T().Skip() +// } +// s.testIBCTokenTransfer() +// s.testMultihopIBCTokenTransfer() +// s.testFailedMultihopIBCTokenTransfer() + +// // stop hermes0 to prevent hermes0 relaying transactions +// s.Require().NoError(s.dkrPool.Purge(s.hermesResource0)) +// HermesResource0Purged = true +// s.testIBCBypassMsg() +// } + // func (s *IntegrationTestSuite) TestSlashing() { -// if !runSlashingTest { -// s.T().Skip() -// } -// chainAPI := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) -// s.testSlashing(chainAPI) -//} -// -//// todo add fee test with wrong denom order +// if !runSlashingTest { +// s.T().Skip() +// } +// chainAPI := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) +// s.testSlashing(chainAPI) +// } + +// // todo add fee test with wrong denom order // func (s *IntegrationTestSuite) TestStakingAndDistribution() { -// if !runStakingAndDistributionTest { -// s.T().Skip() -// } -// s.testStaking() -// s.testDistribution() -//} -// +// if !runStakingAndDistributionTest { +// s.T().Skip() +// } +// s.testStaking() +// s.testDistribution() +// } + // func (s *IntegrationTestSuite) TestVesting() { -// if !runVestingTest { -// s.T().Skip() -// } -// chainAAPI := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) -// s.testDelayedVestingAccount(chainAAPI) -// s.testContinuousVestingAccount(chainAAPI) -// // s.testPeriodicVestingAccount(chainAAPI) TODO: add back when v0.45 adds the missing CLI command. -//} +// if !runVestingTest { +// s.T().Skip() +// } +// chainAAPI := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) +// s.testDelayedVestingAccount(chainAAPI) +// s.testContinuousVestingAccount(chainAAPI) +// // s.testPeriodicVestingAccount(chainAAPI) TODO: add back when v0.45 adds the missing CLI command. +// } diff --git a/tests/e2e/scripts/hermes1_bootstrap.sh b/tests/e2e/scripts/hermes1_bootstrap.sh new file mode 100755 index 00000000000..049c61b8ad4 --- /dev/null +++ b/tests/e2e/scripts/hermes1_bootstrap.sh @@ -0,0 +1,152 @@ +#!/bin/bash + +set -ex + +# initialize Hermes relayer configuration +mkdir -p /root/.hermes/ +touch /root/.hermes/config.toml + +echo $GAIA_B_E2E_RLY_MNEMONIC > /root/.hermes/GAIA_B_E2E_RLY_MNEMONIC.txt +echo $GAIA_A_E2E_RLY_MNEMONIC > /root/.hermes/GAIA_A_E2E_RLY_MNEMONIC.txt + +# setup Hermes relayer configuration with non-zero gas_price +tee /root/.hermes/config.toml <