Skip to content

Commit

Permalink
test re-org (#1913)
Browse files Browse the repository at this point in the history
* pause

* no vscode errors

* rewrite go.sum, go.work.sum and fix amino import

* remove mauth docs

* gofumpt

* fix find

* cant get docker to build locally

* debug ibc test

* fix ibc test

* passing e2e

* clean up commented out tests

* remove more mauth

* forgot to save

* add back middleware test

* fix upgrade

* fix test setup

* add TODO note

* remove multihop test

* re-organized tests to make it easier to skip when working on a single one

* remove gov tests

* removed multihop tests
  • Loading branch information
okwme authored Dec 5, 2022
1 parent 824d80f commit 24671d2
Show file tree
Hide file tree
Showing 11 changed files with 568 additions and 475 deletions.
59 changes: 59 additions & 0 deletions tests/e2e/e2e_bank_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package e2e

import (
"fmt"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
)

func (s *IntegrationTestSuite) testBankTokenTransfer() {
s.Run("send_photon_between_accounts", func() {
var err error
senderAddress := s.chainA.validators[0].keyInfo.GetAddress()
sender := senderAddress.String()

recipientAddress := s.chainA.validators[1].keyInfo.GetAddress()
recipient := recipientAddress.String()

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)

beforeRecipientUAtomBalance, err = getSpecificBalance(chainAAPIEndpoint, recipient, uatomDenom)
s.Require().NoError(err)

return beforeSenderUAtomBalance.IsValid() && beforeRecipientUAtomBalance.IsValid()
},
10*time.Second,
5*time.Second,
)

s.execBankSend(s.chainA, 0, sender, recipient, tokenAmount.String(), standardFees.String(), false)

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
},
time.Minute,
5*time.Second,
)
})
}
22 changes: 22 additions & 0 deletions tests/e2e/e2e_bypassminfee_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package e2e

import (
"cosmossdk.io/math"
)

func (s *IntegrationTestSuite) testByPassMinFeeWithdrawReward() {
paidFeeAmt := math.LegacyMustNewDecFromStr(minGasPrice).Mul(math.LegacyNewDec(gas)).String()
payee := s.chainA.validators[0].keyInfo.GetAddress()
// pass
s.T().Logf("bypass-msg with fee in the denom of global fee, pass")
s.execWithdrawAllRewards(s.chainA, 0, payee.String(), paidFeeAmt+uatomDenom, false)
// pass
s.T().Logf("bypass-msg with zero coin in the denom of global fee, pass")
s.execWithdrawAllRewards(s.chainA, 0, payee.String(), "0"+uatomDenom, false)
// pass
s.T().Logf("bypass-msg with zero coin not in the denom of global fee, pass")
s.execWithdrawAllRewards(s.chainA, 0, payee.String(), "0"+photonDenom, false)
// fail
s.T().Logf("bypass-msg with non-zero coin not in the denom of global fee, fail")
s.execWithdrawAllRewards(s.chainA, 0, payee.String(), paidFeeAmt+photonDenom, true)
}
24 changes: 15 additions & 9 deletions tests/e2e/e2e_distribution_test.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
package e2e

import (
"fmt"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
)

func (s *IntegrationTestSuite) testDistribution(
chainEndpoint,
delegatorAddress,
newWithdrawalAddress,
valOperAddressA,
homePath string,
) {
func (s *IntegrationTestSuite) testDistribution() {

chainEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp"))

validatorB := s.chainA.validators[1]
validatorBAddr := validatorB.keyInfo.GetAddress()

valOperAddressA := sdk.ValAddress(validatorBAddr).String()

delegatorAddress := s.chainA.genesisAccounts[2].keyInfo.GetAddress().String()

newWithdrawalAddress := s.chainA.genesisAccounts[3].keyInfo.GetAddress().String()
fees := sdk.NewCoin(uatomDenom, sdk.NewInt(1000))

beforeBalance, err := getSpecificBalance(chainEndpoint, newWithdrawalAddress, uatomDenom)
Expand All @@ -21,7 +27,7 @@ func (s *IntegrationTestSuite) testDistribution(
beforeBalance = sdk.NewCoin(uatomDenom, sdk.NewInt(0))
}

s.execSetWithdrawAddress(s.chainA, 0, fees.String(), delegatorAddress, newWithdrawalAddress, homePath)
s.execSetWithdrawAddress(s.chainA, 0, fees.String(), delegatorAddress, newWithdrawalAddress, gaiaHomePath)

// Verify
s.Require().Eventually(
Expand All @@ -35,7 +41,7 @@ func (s *IntegrationTestSuite) testDistribution(
5*time.Second,
)

s.execWithdrawReward(s.chainA, 0, delegatorAddress, valOperAddressA, homePath)
s.execWithdrawReward(s.chainA, 0, delegatorAddress, valOperAddressA, gaiaHomePath)
s.Require().Eventually(
func() bool {
afterBalance, err := getSpecificBalance(chainEndpoint, newWithdrawalAddress, uatomDenom)
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/e2e_encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const (
rawTxFile = "tx_raw.json"
)

func (s *IntegrationTestSuite) TestEncode() {
func (s *IntegrationTestSuite) testEncode() {
chain := s.chainA
_, encoded, err := buildRawTx()
s.Require().NoError(err)
Expand All @@ -21,7 +21,7 @@ func (s *IntegrationTestSuite) TestEncode() {
s.Require().Equal(encoded, got)
}

func (s *IntegrationTestSuite) TestDecode() {
func (s *IntegrationTestSuite) testDecode() {
chain := s.chainA
rawTx, encoded, err := buildRawTx()
s.Require().NoError(err)
Expand Down
26 changes: 25 additions & 1 deletion tests/e2e/e2e_evidence_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package e2e

import (
"context"
"fmt"
"time"

"github.com/cosmos/cosmos-sdk/x/evidence/exported"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
)

func (s *IntegrationTestSuite) TestEvidence() {
func (s *IntegrationTestSuite) testEvidence() {
s.Run("test evidence queries", func() {
var (
valIdx = 0
Expand All @@ -27,3 +29,25 @@ func (s *IntegrationTestSuite) TestEvidence() {
}
})
}

func (s *IntegrationTestSuite) execQueryEvidence(c *chain, valIdx int, hash string) (res evidencetypes.Equivocation) {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

s.T().Logf("querying evidence %s on chain %s", hash, c.id)

gaiaCommand := []string{
gaiadBinary,
queryCommand,
evidencetypes.ModuleName,
hash,
}

s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, func(stdOut []byte, stdErr []byte) bool {
// TODO parse evidence after fix the SDK
// https://github.com/cosmos/cosmos-sdk/issues/13444
// s.Require().NoError(yaml.Unmarshal(stdOut, &res))
return true
})
return res
}
4 changes: 1 addition & 3 deletions tests/e2e/e2e_feegrant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ Test Benchmarks:
4. Try to send a transaction from bob with Alice as a fee granter again. Should fail
because all amount granted was expended
*/
func (s *IntegrationTestSuite) TestFeeGrant() {
// TODO: Fix and add back this test
s.T().Skip()
func (s *IntegrationTestSuite) testFeeGrant() {
s.Run("test fee grant module", func() {
var (
valIdx = 0
Expand Down
Loading

0 comments on commit 24671d2

Please sign in to comment.