Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: e2e test #1840

Merged
merged 15 commits into from
Nov 17, 2022
30 changes: 30 additions & 0 deletions tests/e2e/e2e_exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,36 @@ func (s *IntegrationTestSuite) execBankSend(
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
}

func (s *IntegrationTestSuite) execBankSendBatch(
c *chain,
valIdx int,
txs ...txBankSend,
) int {
sucessBankSendCount := 0
Pantani marked this conversation as resolved.
Show resolved Hide resolved

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()
Expand Down
44 changes: 44 additions & 0 deletions tests/e2e/e2e_globalfee_proposal_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package e2e

import (
"fmt"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)

func (s *IntegrationTestSuite) govProposeNewGlobalfee(newGlobalfee sdk.DecCoins, proposalCounter int, submitter string, fees string) {
s.writeGovParamChangeProposalGlobalFees(s.chainA, newGlobalfee)
chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp"))
// gov proposing new fees
s.T().Logf("Proposal number: %d", proposalCounter)
s.T().Logf("Submitting, deposit and vote legacy Gov Proposal: change global fee to %s", newGlobalfee.String())
s.submitLegacyGovProposal(chainAAPIEndpoint, submitter, fees, "param-change", proposalCounter, configFile(proposalGlobalFee))
s.depositGovProposal(chainAAPIEndpoint, submitter, fees, proposalCounter)
s.voteGovProposal(chainAAPIEndpoint, submitter, fees, proposalCounter, "yes", false)

// query the proposal status and new fee
s.Require().Eventually(
func() bool {
proposal, err := queryGovProposal(chainAAPIEndpoint, proposalCounter)
s.Require().NoError(err)
return proposal.GetProposal().Status == govv1beta1.StatusPassed
},
15*time.Second,
5*time.Second,
)

s.Require().Eventually(
func() bool {
globalFees, err := queryGlobalFees(chainAAPIEndpoint)
s.T().Logf("After gov new global fee proposal: %s", globalFees.String())
s.Require().NoError(err)

// attention: if global fee is empty, when query globalfee, it shows empty rather than default ante.DefaultZeroGlobalFee() = 0uatom.
return globalFees.IsEqual(newGlobalfee)
},
15*time.Second,
5*time.Second,
)
}
6 changes: 2 additions & 4 deletions tests/e2e/e2e_ica_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

// TestICARegister must run before any other
func (s *IntegrationTestSuite) TestICA_1_Register() {
func (s *IntegrationTestSuite) icaRegister() {
s.Run("register_ICA", func() {
connectionID := "connection-0"
var owner string
Expand All @@ -38,8 +38,7 @@ func (s *IntegrationTestSuite) TestICA_1_Register() {
})
}

func (s *IntegrationTestSuite) TestICA_2_BankSend() {

func (s *IntegrationTestSuite) icaBankSend() {
s.Run("test ica transactions", func() {
chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp"))
chainBAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainB.id][0].GetHostPort("1317/tcp"))
Expand Down Expand Up @@ -165,6 +164,5 @@ func (s *IntegrationTestSuite) TestICA_2_BankSend() {

s.Require().Equal(sendIBCamt, ibcAmt)

// todo add ica delegation after delegation e2e merged
})
}
4 changes: 3 additions & 1 deletion tests/e2e/e2e_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ const (
icaOwnerAccountIndex = 1
numberOfEvidences = 10
slashingShares int64 = 10000

proposalGlobalFee = "proposal_globalfee.json"
)

var (
Expand Down Expand Up @@ -736,7 +738,7 @@ func (s *IntegrationTestSuite) writeGovParamChangeProposalGlobalFees(c *chain, c
}, "", " ")
s.Require().NoError(err)

err = writeFile(filepath.Join(c.validators[0].configDir(), "config", "proposal_globalfee.json"), paramChangeProposalBody)
err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalGlobalFee), paramChangeProposalBody)
s.Require().NoError(err)
}

Expand Down
Loading