Skip to content

Commit

Permalink
feat: correct more test
Browse files Browse the repository at this point in the history
  • Loading branch information
omarsy committed Jan 4, 2025
1 parent 616e172 commit 848c881
Show file tree
Hide file tree
Showing 16 changed files with 108 additions and 306 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: "1.20"
go-version: "1.22"

- name: Tidy go.mod
run: go mod tidy
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ require (
github.com/cometbft/cometbft v0.37.6
github.com/cometbft/cometbft-db v0.11.0
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.47.10
github.com/cosmos/cosmos-sdk v0.47.8
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogoproto v1.4.10
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.1.1
github.com/cosmos/ibc-go/v7 v7.4.1
github.com/cosmos/interchain-security/v4 v4.1.0
github.com/ethereum/go-ethereum v1.10.16
github.com/gagliardetto/solana-go v1.2.0
github.com/gogo/protobuf v1.3.2
Expand Down
9 changes: 3 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,8 @@ github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk=
github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis=
github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA=
github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec=
github.com/cosmos/cosmos-sdk v0.47.10 h1:Wxf5yEN3jZbG4fftxAMKB6rpd8ME0mxuCVihpz65dt0=
github.com/cosmos/cosmos-sdk v0.47.10/go.mod h1:UWpgWkhcsBIATS68uUC0del7IiBN4hPv/vqg8Zz23uw=
github.com/cosmos/cosmos-sdk v0.47.8 h1:kzYF2xhnfi8dy15t2VVS24tc2KcuU4JBgjh9yCFx4y4=
github.com/cosmos/cosmos-sdk v0.47.8/go.mod h1:VTAtthIsmfplanhFfUTfT6ED4F+kkJxT7nmvmKXRthI=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
Expand All @@ -436,8 +436,6 @@ github.com/cosmos/ibc-go/v7 v7.4.1 h1:95hR5Mdgk2/Z6Ynsq537BOU8LJAOsHR5g0N0ffhFLY
github.com/cosmos/ibc-go/v7 v7.4.1/go.mod h1:L/KaEhzV5TGUCTfGysVgMBQtl5Dm7hHitfpk+GIeoAo=
github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM=
github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0=
github.com/cosmos/interchain-security/v4 v4.1.0 h1:TCtToAWIW/vW/gFyzwKQNRGoVF+hxDBYMKowD37w0dw=
github.com/cosmos/interchain-security/v4 v4.1.0/go.mod h1:12dOsysp0t6ISq6ck5PPbleyEMPTVcfxMTmz0pvGLJ8=
github.com/cosmos/ledger-cosmos-go v0.12.4 h1:drvWt+GJP7Aiw550yeb3ON/zsrgW0jgh5saFCr7pDnw=
github.com/cosmos/ledger-cosmos-go v0.12.4/go.mod h1:fjfVWRf++Xkygt9wzCsjEBdjcf7wiiY35fv3ctT+k4M=
github.com/cosmos/rosetta-sdk-go v0.10.0 h1:E5RhTruuoA7KTIXUcMicL76cffyeoyvNybzUGSKFTcM=
Expand Down Expand Up @@ -806,9 +804,8 @@ github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoD
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE=
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE=
github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
Expand Down
18 changes: 9 additions & 9 deletions tests/e2e/e2e_bank_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ func (s *IntegrationTestSuite) testBankTokenTransfer() {
// get balances of sender and recipient accounts
s.Require().Eventually(
func() bool {
beforeAliceUAtomBalance, err = getSpecificBalance(chainEndpoint, alice.String(), uatomDenom)
beforeAliceUAtomBalance, err = getSpecificBalance(chainEndpoint, alice.String(), utoriDenom)
s.Require().NoError(err)

beforeBobUAtomBalance, err = getSpecificBalance(chainEndpoint, bob.String(), uatomDenom)
beforeBobUAtomBalance, err = getSpecificBalance(chainEndpoint, bob.String(), utoriDenom)
s.Require().NoError(err)

beforeCharlieUAtomBalance, err = getSpecificBalance(chainEndpoint, charlie.String(), uatomDenom)
beforeCharlieUAtomBalance, err = getSpecificBalance(chainEndpoint, charlie.String(), utoriDenom)
s.Require().NoError(err)

return beforeAliceUAtomBalance.IsValid() && beforeBobUAtomBalance.IsValid() && beforeCharlieUAtomBalance.IsValid()
Expand All @@ -55,10 +55,10 @@ func (s *IntegrationTestSuite) testBankTokenTransfer() {
// check that the transfer was successful
s.Require().Eventually(
func() bool {
afterAliceUAtomBalance, err = getSpecificBalance(chainEndpoint, alice.String(), uatomDenom)
afterAliceUAtomBalance, err = getSpecificBalance(chainEndpoint, alice.String(), utoriDenom)
s.Require().NoError(err)

afterBobUAtomBalance, err = getSpecificBalance(chainEndpoint, bob.String(), uatomDenom)
afterBobUAtomBalance, err = getSpecificBalance(chainEndpoint, bob.String(), utoriDenom)
s.Require().NoError(err)

decremented := beforeAliceUAtomBalance.Sub(tokenAmount).Sub(standardFees).IsEqual(afterAliceUAtomBalance)
Expand All @@ -78,13 +78,13 @@ func (s *IntegrationTestSuite) testBankTokenTransfer() {

s.Require().Eventually(
func() bool {
afterAliceUAtomBalance, err = getSpecificBalance(chainEndpoint, alice.String(), uatomDenom)
afterAliceUAtomBalance, err = getSpecificBalance(chainEndpoint, alice.String(), utoriDenom)
s.Require().NoError(err)

afterBobUAtomBalance, err = getSpecificBalance(chainEndpoint, bob.String(), uatomDenom)
afterBobUAtomBalance, err = getSpecificBalance(chainEndpoint, bob.String(), utoriDenom)
s.Require().NoError(err)

afterCharlieUAtomBalance, err = getSpecificBalance(chainEndpoint, charlie.String(), uatomDenom)
afterCharlieUAtomBalance, err = getSpecificBalance(chainEndpoint, charlie.String(), utoriDenom)
s.Require().NoError(err)

decremented := beforeAliceUAtomBalance.Sub(tokenAmount).Sub(tokenAmount).Sub(standardFees).IsEqual(afterAliceUAtomBalance)
Expand All @@ -108,7 +108,7 @@ func (s *IntegrationTestSuite) failedBankSendWithNonCriticalExtensionOptions() {
submitterAccount := c.genesisAccounts[1]
submitterAddress, err := submitterAccount.keyInfo.GetAddress()
s.Require().NoError(err)
sendMsg := banktypes.NewMsgSend(submitterAddress, submitterAddress, sdk.NewCoins(sdk.NewCoin(uatomDenom, sdk.NewInt(100))))
sendMsg := banktypes.NewMsgSend(submitterAddress, submitterAddress, sdk.NewCoins(sdk.NewCoin(utoriDenom, sdk.NewInt(100))))

// the message does not matter, as long as it is in the interface registry
ext := &banktypes.MsgMultiSend{}
Expand Down
12 changes: 6 additions & 6 deletions tests/e2e/e2e_distribution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ func (s *IntegrationTestSuite) testDistribution() {
delegatorAddress, _ := s.chainA.genesisAccounts[2].keyInfo.GetAddress()

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

beforeBalance, err := getSpecificBalance(chainEndpoint, newWithdrawalAddress.String(), uatomDenom)
beforeBalance, err := getSpecificBalance(chainEndpoint, newWithdrawalAddress.String(), utoriDenom)
s.Require().NoError(err)
if beforeBalance.IsNil() {
beforeBalance = sdk.NewCoin(uatomDenom, sdk.NewInt(0))
beforeBalance = sdk.NewCoin(utoriDenom, sdk.NewInt(0))
}

s.execSetWithdrawAddress(s.chainA, 0, fees.String(), delegatorAddress.String(), newWithdrawalAddress.String(), teritoriHomePath)
Expand All @@ -43,7 +43,7 @@ func (s *IntegrationTestSuite) testDistribution() {
s.execWithdrawReward(s.chainA, 0, delegatorAddress.String(), valOperAddressA, teritoriHomePath)
s.Require().Eventually(
func() bool {
afterBalance, err := getSpecificBalance(chainEndpoint, newWithdrawalAddress.String(), uatomDenom)
afterBalance, err := getSpecificBalance(chainEndpoint, newWithdrawalAddress.String(), utoriDenom)
s.Require().NoError(err)

return afterBalance.IsGTE(beforeBalance)
Expand All @@ -67,7 +67,7 @@ func (s *IntegrationTestSuite) fundCommunityPool() {
beforeDistUatomBalance, _ := getSpecificBalance(chainAAPIEndpoint, distModuleAddress, tokenAmount.Denom)
if beforeDistUatomBalance.IsNil() {
// Set balance to 0 if previous balance does not exist
beforeDistUatomBalance = sdk.NewInt64Coin(uatomDenom, 0)
beforeDistUatomBalance = sdk.NewInt64Coin(utoriDenom, 0)
}

s.execDistributionFundCommunityPool(s.chainA, 0, sender.String(), tokenAmount.String(), standardFees.String())
Expand All @@ -80,7 +80,7 @@ func (s *IntegrationTestSuite) fundCommunityPool() {
// check if the balance is increased by the tokenAmount and at least some portion of
// the fees (some amount of the fees will be given to the proposer)
return beforeDistUatomBalance.Add(tokenAmount).IsLT(afterDistUatomBalance) &&
afterDistUatomBalance.IsLT(beforeDistUatomBalance.Add(tokenAmount).Add(standardFees))
afterDistUatomBalance.IsEqual(beforeDistUatomBalance.Add(tokenAmount).Add(standardFees))
},
15*time.Second,
5*time.Second,
Expand Down
7 changes: 3 additions & 4 deletions tests/e2e/e2e_exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ func (s *IntegrationTestSuite) runGovExec(c *chain, valIdx int, submitterAddr, g
// if err := json.Unmarshal(stdErr, &addrRecord); err != nil {
// return false
// }
// return strings.Contains(addrRecord.Address, "cosmos")
// return strings.Contains(addrRecord.Address, "tori")
// })
// return addrRecord.Address
// }
Expand Down Expand Up @@ -557,7 +557,6 @@ func (s *IntegrationTestSuite) getLatestBlockHeight(c *chain, valIdx int) int {
err error
block syncInfo
)
println("executeTeritoriTxCommand", "out", string(stdOut), "error", string(stdErr))
s.Require().NoError(json.Unmarshal(stdErr, &block))
currentHeight, err = strconv.Atoi(block.SyncInfo.LatestHeight)
s.Require().NoError(err)
Expand All @@ -569,7 +568,7 @@ func (s *IntegrationTestSuite) getLatestBlockHeight(c *chain, valIdx int) int {
// func (s *IntegrationTestSuite) verifyBalanceChange(endpoint string, expectedAmount sdk.Coin, recipientAddress string) {
// s.Require().Eventually(
// func() bool {
// afterAtomBalance, err := getSpecificBalance(endpoint, recipientAddress, uatomDenom)
// afterAtomBalance, err := getSpecificBalance(endpoint, recipientAddress, utoriDenom)
// s.Require().NoError(err)

// return afterAtomBalance.IsEqual(expectedAmount)
Expand Down Expand Up @@ -628,7 +627,7 @@ func (s *IntegrationTestSuite) execWithdrawReward(
"withdraw-rewards",
validatorAddress,
fmt.Sprintf("--%s=%s", flags.FlagFrom, delegatorAddress),
fmt.Sprintf("--%s=%s", flags.FlagGasPrices, "300uatom"),
fmt.Sprintf("--%s=%s", flags.FlagGasPrices, "300utori"),
fmt.Sprintf("--%s=%s", flags.FlagGas, "auto"),
fmt.Sprintf("--%s=%s", flags.FlagGasAdjustment, "1.5"),
fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id),
Expand Down
26 changes: 10 additions & 16 deletions tests/e2e/e2e_gov_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"strconv"
"time"

providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types"

sdk "github.com/cosmos/cosmos-sdk/types"
govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
Expand Down Expand Up @@ -122,10 +120,10 @@ func (s *IntegrationTestSuite) GovCommunityPoolSpend() {
sender := senderAddress.String()
recipientAddress, _ := s.chainA.validators[1].keyInfo.GetAddress()
recipient := recipientAddress.String()
sendAmount := sdk.NewCoin(uatomDenom, sdk.NewInt(10000000)) // 10uatom
sendAmount := sdk.NewCoin(utoriDenom, sdk.NewInt(10000000)) // 10utori
s.writeGovCommunitySpendProposal(s.chainA, sendAmount, recipient)

beforeRecipientBalance, err := getSpecificBalance(chainAAPIEndpoint, recipient, uatomDenom)
beforeRecipientBalance, err := getSpecificBalance(chainAAPIEndpoint, recipient, utoriDenom)
s.Require().NoError(err)

// Gov tests may be run in arbitrary order, each test must increment proposalCounter to have the correct proposal id to submit and query
Expand All @@ -137,7 +135,7 @@ func (s *IntegrationTestSuite) GovCommunityPoolSpend() {

s.Require().Eventually(
func() bool {
afterRecipientBalance, err := getSpecificBalance(chainAAPIEndpoint, recipient, uatomDenom)
afterRecipientBalance, err := getSpecificBalance(chainAAPIEndpoint, recipient, utoriDenom)
s.Require().NoError(err)

return afterRecipientBalance.Sub(sendAmount).IsEqual(beforeRecipientBalance)
Expand All @@ -149,10 +147,10 @@ func (s *IntegrationTestSuite) GovCommunityPoolSpend() {

func (s *IntegrationTestSuite) submitLegacyGovProposal(chainAAPIEndpoint, sender string, proposalID int, proposalType string, submitFlags []string, depositFlags []string, voteFlags []string, voteCommand string, withDeposit bool) {
s.T().Logf("Submitting Gov Proposal: %s", proposalType)
// min deposit of 1000uatom is required in e2e tests, otherwise the gov antehandler causes the proposal to be dropped
// min deposit of 1000utori is required in e2e tests, otherwise the gov antehandler causes the proposal to be dropped
sflags := submitFlags
if withDeposit {
sflags = append(sflags, "--deposit=1000uatom")
sflags = append(sflags, "--deposit=1000utori")
}
s.submitGovCommand(chainAAPIEndpoint, sender, proposalID, "submit-legacy-proposal", sflags, govtypesv1beta1.StatusDepositPeriod)
s.T().Logf("Depositing Gov Proposal: %s", proposalType)
Expand All @@ -164,7 +162,7 @@ func (s *IntegrationTestSuite) submitLegacyGovProposal(chainAAPIEndpoint, sender
// NOTE: in SDK >= v0.47 the submit-proposal does not have a --deposit flag
// Instead, the depoist is added to the "deposit" field of the proposal JSON (usually stored as a file)
// you can use `teritorid tx gov draft-proposal` to create a proposal file that you can use
// min initial deposit of 100uatom is required in e2e tests, otherwise the proposal would be dropped
// min initial deposit of 100utori is required in e2e tests, otherwise the proposal would be dropped
//
//nolint:unparam
func (s *IntegrationTestSuite) submitGovProposal(chainAAPIEndpoint, sender string, proposalID int, proposalType string, submitFlags []string, depositFlags []string, voteFlags []string, voteCommand string) {
Expand Down Expand Up @@ -221,7 +219,6 @@ func (s *IntegrationTestSuite) verifyChainPassesUpgradeHeight(c *chain, valIdx,
func (s *IntegrationTestSuite) submitGovCommand(chainAAPIEndpoint, sender string, proposalID int, govCommand string, proposalFlags []string, expectedSuccessStatus govtypesv1beta1.ProposalStatus) {
s.Run(fmt.Sprintf("Running tx gov %s", govCommand), func() {
s.runGovExec(s.chainA, 0, sender, govCommand, proposalFlags, standardFees.String(), nil)

s.Require().Eventually(
func() bool {
proposal, err := queryGovProposal(chainAAPIEndpoint, proposalID)
Expand All @@ -243,15 +240,12 @@ func (s *IntegrationTestSuite) submitGovCommandExpectingFailure(sender string, g

// ExpeditedProposalRejected tests that expediting a ParamChange proposal fails.
func (s *IntegrationTestSuite) ExpeditedProposalRejected() {
defaultBlocksPerEpoch := providertypes.DefaultParams().BlocksPerEpoch

// attempt to change but nothing should happen -> proposal fails at ante handler
expectedBlocksPerEpoch := defaultBlocksPerEpoch + 100
s.writeFailingExpeditedProposal(s.chainA, expectedBlocksPerEpoch)
//s.writeFailingExpeditedProposal(s.chainA, expectedBlocksPerEpoch)

validatorAAddr, _ := s.chainA.validators[0].keyInfo.GetAddress()
submitGovFlags := []string{configFile(proposalFailExpedited)}
//validatorAAddr, _ := s.chainA.validators[0].keyInfo.GetAddress()
//submitGovFlags := []string{configFile(proposalFailExpedited)}

s.T().Logf("Submitting, deposit and vote Gov Proposal: Change BlocksPerEpoch parameter - expecting to fail")
s.submitGovCommandExpectingFailure(validatorAAddr.String(), "submit-proposal", submitGovFlags)
//s.submitGovCommandExpectingFailure(validatorAAddr.String(), "submit-proposal", submitGovFlags)
}
Loading

0 comments on commit 848c881

Please sign in to comment.