diff --git a/tests/e2e/e2e_exec_test.go b/tests/e2e/e2e_exec_test.go index 3805ce5ccf0fb..2bc479ef513d0 100644 --- a/tests/e2e/e2e_exec_test.go +++ b/tests/e2e/e2e_exec_test.go @@ -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 + + 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() diff --git a/tests/e2e/e2e_globalfee_proposal_test.go b/tests/e2e/e2e_globalfee_proposal_test.go new file mode 100644 index 0000000000000..16d34b7d8de2f --- /dev/null +++ b/tests/e2e/e2e_globalfee_proposal_test.go @@ -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, + ) +} diff --git a/tests/e2e/e2e_ica_test.go b/tests/e2e/e2e_ica_test.go index 80a35175c24f9..364324686f687 100644 --- a/tests/e2e/e2e_ica_test.go +++ b/tests/e2e/e2e_ica_test.go @@ -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 @@ -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")) @@ -165,6 +164,5 @@ func (s *IntegrationTestSuite) TestICA_2_BankSend() { s.Require().Equal(sendIBCamt, ibcAmt) - // todo add ica delegation after delegation e2e merged }) } diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 07460a360b259..687bff13f9986 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -69,6 +69,8 @@ const ( icaOwnerAccountIndex = 1 numberOfEvidences = 10 slashingShares int64 = 10000 + + proposalGlobalFee = "proposal_globalfee.json" ) var ( @@ -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) } diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index fbe6619f74be6..fa816e6bd2c15 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -6,7 +6,6 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) func (s *IntegrationTestSuite) TestGov() { @@ -36,36 +35,36 @@ func (s *IntegrationTestSuite) TestQueryGlobalFeesInGenesis() { } /* -global fee in genesis is "0.00001uatom", which is the same as min_gas_price. -This initial value setup is for not to fail other e2e tests. global fee e2e tests: -0. initial globalfee = 0.00001uatom, min_gas_price = 0.00001uatom +initial setup: initial globalfee = 0.00001uatom, min_gas_price = 0.00001uatom +(This initial value setup is to pass other e2e tests) -test1. gov proposal globalfee = [], min_gas_price=0.00001uatom, query globalfee still get empty +test1: gov proposal globalfee = [], min_gas_price=0.00001uatom, query globalfee still get empty - tx with fee denom photon, fail - tx with zero fee denom photon, fail - tx with fee denom uatom, pass - tx with fee empty, fail -test2. gov propose globalfee = 0.000001uatom(lower than min_gas_price) +test2: gov propose globalfee = 0.000001uatom(lower than min_gas_price) - tx with fee higher than 0.000001uatom but lower than 0.00001uatom, fail - tx with fee higher than/equal to 0.00001uatom, pass - tx with fee photon fail -test3. gov propose globalfee = 0.0001uatom (higher than min_gas_price) +test3: gov propose globalfee = 0.0001uatom (higher than min_gas_price) - tx with fee equal to 0.0001uatom, pass - tx with fee equal to 0.00001uatom, fail -test4. gov propose globalfee = 0.000001uatom (lower than min_gas_price), 0photon +test4: gov propose globalfee = 0.000001uatom (lower than min_gas_price), 0photon - tx with fee 0.0000001photon, fail - tx with fee 0.000001photon, pass - tx with empty fee, pass - tx with fee photon pass - tx with fee 0photon, 0.000005uatom fail - tx with fee 0photon, 0.00001uatom pass -5. check balance correct: all the sucessful tx sent token amt is received -6. gov propose change back to initial globalfee = 0.00001photon, This is for not influence other e2e tests. +test5: check balance correct: all the successful bank sent tokens are received +test6: gov propose change back to initial globalfee = 0.00001photon, This is for not influence other e2e tests. */ + func (s *IntegrationTestSuite) TestGlobalFees() { chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) @@ -76,6 +75,7 @@ func (s *IntegrationTestSuite) TestGlobalFees() { recipientAddress, err := s.chainA.validators[1].keyInfo.GetAddress() s.Require().NoError(err) recipient := recipientAddress.String() + var beforeRecipientPhotonBalance sdk.Coin s.Require().Eventually( func() bool { @@ -94,93 +94,64 @@ func (s *IntegrationTestSuite) TestGlobalFees() { sendAmt := int64(1000) token := sdk.NewInt64Coin(photonDenom, sendAmt) // send 1000photon each time sucessBankSendCount := 0 + // ---------------------------- test1: globalfee empty -------------------------------------------- // prepare gov globalfee proposal emptyGlobalFee := sdk.DecCoins{} - s.writeGovParamChangeProposalGlobalFees(s.chainA, emptyGlobalFee) - - // gov proposing new fees proposalCounter++ - s.T().Logf("Proposal number: %d", proposalCounter) - s.T().Logf("Submitting, deposit and vote legacy Gov Proposal: change global fees empty") - s.submitLegacyGovProposal(chainAAPIEndpoint, submitter, standardFees.String(), "param-change", proposalCounter, configFile("proposal_globalfee.json")) - s.depositGovProposal(chainAAPIEndpoint, submitter, standardFees.String(), proposalCounter) - s.voteGovProposal(chainAAPIEndpoint, submitter, standardFees.String(), proposalCounter, "yes", false) + s.govProposeNewGlobalfee(emptyGlobalFee, proposalCounter, submitter, standardFees.String()) + paidFeeAmt := math.LegacyMustNewDecFromStr(minGasPrice).Mul(math.LegacyNewDec(gas)).String() - // 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 + s.T().Logf("test case: empty global fee, globalfee=%s, min_gas_price=%s", emptyGlobalFee.String(), minGasPrice+uatomDenom) + txBankSends := []txBankSend{ + { + from: submitter, + to: recipient, + amt: token.String(), + fees: "0" + uatomDenom, + log: "Tx fee is zero coin with correct denom: uatom, fail", + expectErr: true, }, - 15*time.Second, - 5*time.Second, - ) - var globalFees sdk.DecCoins - 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: when global fee is empty, when query, it shows empty rather than default ante.DefaultZeroGlobalFee() = 0uatom. - return globalFees.IsEqual(emptyGlobalFee) + { + from: submitter, + to: recipient, + amt: token.String(), + fees: "", + log: "Tx fee is empty, fail", + expectErr: true, }, - 15*time.Second, - 5*time.Second, - ) - - paidFeeAmt := math.LegacyMustNewDecFromStr(minGasPrice).Mul(math.LegacyNewDec(gas)).String() - - s.T().Logf("test case: empty global fee, globalfee=%s, min_gas_price=%s", globalFees.String(), minGasPrice+uatomDenom) - s.T().Logf("Tx fee is zero coin with correct denom: uatom, fail") - s.execBankSend(s.chainA, 0, submitter, recipient, token.String(), "0"+uatomDenom, true) - s.T().Logf("Tx fee is empty, fail") - s.execBankSend(s.chainA, 0, submitter, recipient, token.String(), "", true) - s.T().Logf("Tx with wrong denom: photon, fail") - s.execBankSend(s.chainA, 0, submitter, recipient, token.String(), "4"+photonDenom, true) - s.T().Logf("Tx fee is zero coins of wrong denom: photon, fail") - s.execBankSend(s.chainA, 0, submitter, recipient, token.String(), "0"+photonDenom, true) - s.T().Logf("Tx fee is higher than min_gas_price, pass") - s.execBankSend(s.chainA, 0, submitter, recipient, token.String(), paidFeeAmt+uatomDenom, false) - sucessBankSendCount++ + { + from: submitter, + to: recipient, + amt: token.String(), + fees: "4" + photonDenom, + log: "Tx with wrong denom: photon, fail", + expectErr: true, + }, + { + from: submitter, + to: recipient, + amt: token.String(), + fees: "0" + photonDenom, + log: "Tx fee is zero coins of wrong denom: photon, fail", + expectErr: true, + }, + { + from: submitter, + to: recipient, + amt: token.String(), + fees: paidFeeAmt + uatomDenom, + log: "Tx fee is higher than min_gas_price, pass", + expectErr: false, + }, + } + sucessBankSendCount += s.execBankSendBatch(s.chainA, 0, txBankSends...) // ------------------ test2: globalfee lower than min_gas_price ----------------------------------- // prepare gov globalfee proposal lowGlobalFee := sdk.DecCoins{sdk.NewDecCoinFromDec(uatomDenom, sdk.MustNewDecFromStr(lowGlobalFeesAmt))} - s.writeGovParamChangeProposalGlobalFees(s.chainA, lowGlobalFee) - - // gov proposing new fees proposalCounter++ - s.T().Logf("Proposal number: %d", proposalCounter) - s.T().Logf("Submitting, deposit and vote legacy Gov Proposal: change global fees empty") - s.submitLegacyGovProposal(chainAAPIEndpoint, submitter, standardFees.String(), "param-change", proposalCounter, configFile("proposal_globalfee.json")) - s.depositGovProposal(chainAAPIEndpoint, submitter, standardFees.String(), proposalCounter) - s.voteGovProposal(chainAAPIEndpoint, submitter, standardFees.String(), 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) - - return globalFees.IsEqual(lowGlobalFee) - }, - 15*time.Second, - 5*time.Second, - ) + s.govProposeNewGlobalfee(lowGlobalFee, proposalCounter, submitter, standardFees.String()) paidFeeAmt = math.LegacyMustNewDecFromStr(minGasPrice).Mul(math.LegacyNewDec(gas)).String() paidFeeAmtLowMinGasHighGlobalFee := math.LegacyMustNewDecFromStr(lowGlobalFeesAmt). @@ -189,63 +160,73 @@ func (s *IntegrationTestSuite) TestGlobalFees() { String() paidFeeAmtLowGlobalFee := math.LegacyMustNewDecFromStr(lowGlobalFeesAmt).Quo(math.LegacyNewDec(2)).String() - s.T().Logf("test case: global fee is lower than min_gas_price, globalfee=%s, min_gas_price=%s", globalFees.String(), minGasPrice+uatomDenom) - s.T().Logf("Tx fee higher than/equal to min_gas_price and global fee, pass") - s.execBankSend(s.chainA, 0, submitter, recipient, token.String(), paidFeeAmt+uatomDenom, false) - sucessBankSendCount++ - s.T().Logf("Tx fee lower than/equal to min_gas_price and global fee, pass") - s.execBankSend(s.chainA, 0, submitter, recipient, token.String(), paidFeeAmtLowGlobalFee+uatomDenom, true) - s.T().Logf("Tx fee lower than/equal global fee and lower than min_gas_price, fail") - s.execBankSend(s.chainA, 0, submitter, recipient, token.String(), paidFeeAmtLowMinGasHighGlobalFee+uatomDenom, true) - s.T().Logf("Tx fee has wrong denom, fail") - s.execBankSend(s.chainA, 0, submitter, recipient, token.String(), paidFeeAmt+photonDenom, true) + s.T().Logf("test case: global fee is lower than min_gas_price, globalfee=%s, min_gas_price=%s", lowGlobalFee.String(), minGasPrice+uatomDenom) + txBankSends = []txBankSend{ + { + from: submitter, + to: recipient, + amt: token.String(), + fees: paidFeeAmt + uatomDenom, + log: "Tx fee higher than/equal to min_gas_price and global fee, pass", + expectErr: false, + }, + { + from: submitter, + to: recipient, + amt: token.String(), + fees: paidFeeAmtLowGlobalFee + uatomDenom, + log: "Tx fee lower than/equal to min_gas_price and global fee, pass", + expectErr: true, + }, + { + from: submitter, + to: recipient, + amt: token.String(), + fees: paidFeeAmtLowMinGasHighGlobalFee + uatomDenom, + log: "Tx fee lower than/equal global fee and lower than min_gas_price, fail", + expectErr: true, + }, + { + from: submitter, + to: recipient, + amt: token.String(), + fees: paidFeeAmt + photonDenom, + log: "Tx fee has wrong denom, fail", + expectErr: true, + }, + } + sucessBankSendCount += s.execBankSendBatch(s.chainA, 0, txBankSends...) // ------------------ test3: globalfee higher than min_gas_price ---------------------------------- // prepare gov globalfee proposal highGlobalFee := sdk.DecCoins{sdk.NewDecCoinFromDec(uatomDenom, sdk.MustNewDecFromStr(highGlobalFeeAmt))} - s.writeGovParamChangeProposalGlobalFees(s.chainA, highGlobalFee) - - // gov proposing new fees proposalCounter++ - s.T().Logf("Proposal number: %d", proposalCounter) - s.T().Logf("Submitting, deposit and vote legacy Gov Proposal: change global fees empty") - s.submitLegacyGovProposal(chainAAPIEndpoint, submitter, paidFeeAmt+uatomDenom, "param-change", proposalCounter, configFile("proposal_globalfee.json")) - s.depositGovProposal(chainAAPIEndpoint, submitter, paidFeeAmt+uatomDenom, proposalCounter) - s.voteGovProposal(chainAAPIEndpoint, submitter, paidFeeAmt+uatomDenom, 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) - - return globalFees.IsEqual(highGlobalFee) - }, - 15*time.Second, - 5*time.Second, - ) + s.govProposeNewGlobalfee(highGlobalFee, proposalCounter, submitter, paidFeeAmt+uatomDenom) paidFeeAmt = math.LegacyMustNewDecFromStr(highGlobalFeeAmt).Mul(math.LegacyNewDec(gas)).String() paidFeeAmtHigherMinGasLowerGalobalFee := math.LegacyMustNewDecFromStr(minGasPrice). Quo(math.LegacyNewDec(2)).String() - s.T().Logf("test case: global fee is higher than min_gas_price, globalfee=%s, min_gas_price=%s", globalFees.String(), minGasPrice+uatomDenom) - s.T().Logf("Tx fee is higher than/equal to global fee and min_gas_price, pass") - s.execBankSend(s.chainA, 0, submitter, recipient, token.String(), paidFeeAmt+uatomDenom, false) - sucessBankSendCount++ - s.T().Logf("Tx fee is higher than/equal to min_gas_price but lower than global fee, fail") - s.execBankSend(s.chainA, 0, submitter, recipient, token.String(), paidFeeAmtHigherMinGasLowerGalobalFee+uatomDenom, true) + s.T().Logf("test case: global fee is higher than min_gas_price, globalfee=%s, min_gas_price=%s", highGlobalFee.String(), minGasPrice+uatomDenom) + txBankSends = []txBankSend{ + { + from: submitter, + to: recipient, + amt: token.String(), + fees: paidFeeAmt + uatomDenom, + log: "Tx fee is higher than/equal to global fee and min_gas_price, pass", + expectErr: false, + }, + { + from: submitter, + to: recipient, + amt: token.String(), + fees: paidFeeAmtHigherMinGasLowerGalobalFee + uatomDenom, + log: "Tx fee is higher than/equal to min_gas_price but lower than global fee, fail", + expectErr: true, + }, + } + sucessBankSendCount += s.execBankSendBatch(s.chainA, 0, txBankSends...) // ---------------------------- test4: global fee with two denoms ----------------------------------- // prepare gov globalfee proposal @@ -253,37 +234,8 @@ func (s *IntegrationTestSuite) TestGlobalFees() { sdk.NewDecCoinFromDec(photonDenom, sdk.NewDec(0)), sdk.NewDecCoinFromDec(uatomDenom, sdk.MustNewDecFromStr(lowGlobalFeesAmt)), }.Sort() - s.writeGovParamChangeProposalGlobalFees(s.chainA, mixGlobalFee) - - // gov proposing new fees proposalCounter++ - s.T().Logf("Proposal number: %d", proposalCounter) - s.T().Logf("Submitting, deposit and vote legacy Gov Proposal: change global fees empty") - s.submitLegacyGovProposal(chainAAPIEndpoint, submitter, paidFeeAmt+uatomDenom, "param-change", proposalCounter, configFile("proposal_globalfee.json")) - s.depositGovProposal(chainAAPIEndpoint, submitter, paidFeeAmt+uatomDenom, proposalCounter) - s.voteGovProposal(chainAAPIEndpoint, submitter, paidFeeAmt+uatomDenom, 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) - return globalFees.IsEqual(mixGlobalFee) - }, - 15*time.Second, - 5*time.Second, - ) + s.govProposeNewGlobalfee(mixGlobalFee, proposalCounter, submitter, paidFeeAmt+uatomDenom) // equal to min_gas_price paidFeeAmt = math.LegacyMustNewDecFromStr(minGasPrice).Mul(math.LegacyNewDec(gas)).String() @@ -292,31 +244,85 @@ func (s *IntegrationTestSuite) TestGlobalFees() { Mul(math.LegacyNewDec(gas)). String() - s.T().Logf("test case: global fees contain multiple denoms: one zero coin, one non-zero coin, globalfee=%s, min_gas_price=%s", globalFees.String(), minGasPrice+uatomDenom) - s.T().Logf("Tx with fee higher than/equal to one of denom's amount the global fee, pass") - s.execBankSend(s.chainA, 0, submitter, recipient, token.String(), paidFeeAmt+uatomDenom, false) - sucessBankSendCount++ - s.T().Logf("Tx with fee lower than one of denom's amount the global fee, fail") - s.execBankSend(s.chainA, 0, submitter, recipient, token.String(), paidFeeAmtLow+uatomDenom, true) - s.T().Logf("Tx with fee empty fee, pass") - s.execBankSend(s.chainA, 0, submitter, recipient, token.String(), "", false) - sucessBankSendCount++ - s.T().Logf("Tx with zero coin in the denom of zero coin of global fee, pass") - s.execBankSend(s.chainA, 0, submitter, recipient, token.String(), "0"+photonDenom, false) - sucessBankSendCount++ - s.T().Logf("Tx with non-zero coin in the denom of zero coin of global fee, pass") - s.execBankSend(s.chainA, 0, submitter, recipient, token.String(), "2"+photonDenom, false) - sucessBankSendCount++ - s.T().Logf("Tx with mulitple fee coins, zero coin and low fee, fail") - s.execBankSend(s.chainA, 0, submitter, recipient, token.String(), "0"+photonDenom+","+paidFeeAmtLow+uatomDenom, true) - s.T().Logf("Tx with mulitple fee coins, zero coin and high fee, pass") - s.execBankSend(s.chainA, 0, submitter, recipient, token.String(), "0"+photonDenom+","+paidFeeAmt+uatomDenom, false) - sucessBankSendCount++ - s.T().Logf("Tx with mulitple fee coins, all higher than global fee and min_gas_price") - s.execBankSend(s.chainA, 0, submitter, recipient, token.String(), "2"+photonDenom+","+paidFeeAmt+uatomDenom, false) - sucessBankSendCount++ - // --------------------------------------------------------------------------- + s.T().Logf("test case: global fees contain multiple denoms: one zero coin, one non-zero coin, globalfee=%s, min_gas_price=%s", mixGlobalFee.String(), minGasPrice+uatomDenom) + txBankSends = []txBankSend{ + { + from: submitter, + to: recipient, + amt: token.String(), + fees: paidFeeAmt + uatomDenom, + log: "Tx with fee higher than/equal to one of denom's amount the global fee, pass", + expectErr: false, + }, + { + from: submitter, + to: recipient, + amt: token.String(), + fees: paidFeeAmtLow + uatomDenom, + log: "Tx with fee lower than one of denom's amount the global fee, fail", + expectErr: true, + }, + { + from: submitter, + to: recipient, + amt: token.String(), + fees: "", + log: "Tx with fee empty fee, pass", + expectErr: false, + }, + { + from: submitter, + to: recipient, + amt: token.String(), + fees: "0" + photonDenom, + log: "Tx with zero coin in the denom of zero coin of global fee, pass", + expectErr: false, + }, + { + from: submitter, + to: recipient, + amt: token.String(), + fees: "0" + photonDenom, + log: "Tx with zero coin in the denom of zero coin of global fee, pass", + expectErr: false, + }, + { + from: submitter, + to: recipient, + amt: token.String(), + fees: "2" + photonDenom, + log: "Tx with non-zero coin in the denom of zero coin of global fee, pass", + expectErr: false, + }, + { + from: submitter, + to: recipient, + amt: token.String(), + fees: "0" + photonDenom + "," + paidFeeAmtLow + uatomDenom, + log: "Tx with multiple fee coins, zero coin and low fee, fail", + expectErr: true, + }, + { + from: submitter, + to: recipient, + amt: token.String(), + fees: "0" + photonDenom + "," + paidFeeAmt + uatomDenom, + log: "Tx with multiple fee coins, zero coin and high fee, pass", + expectErr: false, + }, + + { + from: submitter, + to: recipient, + amt: token.String(), + fees: "2" + photonDenom + "," + paidFeeAmt + uatomDenom, + log: "Tx with multiple fee coins, all higher than global fee and min_gas_price", + expectErr: false, + }, + } + sucessBankSendCount += s.execBankSendBatch(s.chainA, 0, txBankSends...) + // --------------------------------------------------------------------------- // check the balance is correct after previous txs s.Require().Eventually( func() bool { @@ -334,38 +340,8 @@ func (s *IntegrationTestSuite) TestGlobalFees() { s.T().Logf("Propose to change back to original global fees: %s", initialGlobalFeeAmt+uatomDenom) oldfees, err := sdk.ParseDecCoins(initialGlobalFeeAmt + uatomDenom) s.Require().NoError(err) - s.writeGovParamChangeProposalGlobalFees(s.chainA, oldfees) - proposalCounter++ - s.T().Logf("Proposal number: %d", proposalCounter) - s.T().Logf("Submitting, deposit and vote legacy Gov Proposal: change back global fees") - // fee is 0uatom - s.submitLegacyGovProposal(chainAAPIEndpoint, submitter, paidFeeAmt+photonDenom, "param-change", proposalCounter, configFile("proposal_globalfee.json")) - s.depositGovProposal(chainAAPIEndpoint, submitter, paidFeeAmt+photonDenom, proposalCounter) - s.voteGovProposal(chainAAPIEndpoint, submitter, paidFeeAmt+photonDenom, proposalCounter, "yes", false) - - // query the proposal status and 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 { - fees, err := queryGlobalFees(chainAAPIEndpoint) - s.T().Logf("After gov proposal to change back global fees: %s", oldfees.String()) - s.Require().NoError(err) - - return fees.IsEqual(oldfees) - }, - 15*time.Second, - 5*time.Second, - ) + s.govProposeNewGlobalfee(oldfees, proposalCounter, submitter, paidFeeAmt+photonDenom) } func (s *IntegrationTestSuite) TestByPassMinFeeWithdrawReward() { @@ -429,3 +405,8 @@ func (s *IntegrationTestSuite) TestSlashing() { chainAPI := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) s.testSlashing(chainAPI) } + +func (s *IntegrationTestSuite) TestICA() { + s.icaRegister() + s.icaBankSend() +}