Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
vishal-kanna committed Sep 28, 2024
1 parent 9a2dc93 commit 1b70699
Show file tree
Hide file tree
Showing 8 changed files with 245 additions and 18 deletions.
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,7 @@ func (app *App) setupUpgradeStoreLoaders() {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{
feemarkettypes.StoreKey,
feeabstypes.StoreKey,
},
}
// configure store loader that checks if version == upgradeHeight and applies store upgrades
Expand Down
2 changes: 1 addition & 1 deletion tests/upgrade/integration/v3/cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
ExpectedBlockSeconds int64 = 1
ExtraBlocks int64 = 10
UpgradeName = upgradeV3.UpgradeName
DepositAmount = "10000000ncheq"
DepositAmount = "1000000000ncheq"
NetworkConfigDir = "network-config"
KeyringDir = "keyring-test"
)
Expand Down
2 changes: 1 addition & 1 deletion tests/upgrade/integration/v3/cli/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func CalculateUpgradeHeight(container string, binary string) (int64, int64, erro
if err != nil {
return 0, 0, err
}
return currentHeight + VotingPeriod/ExpectedBlockSeconds + ExtraBlocks*2, votingEndHeight, nil
return currentHeight + VotingPeriod/ExpectedBlockSeconds + ExtraBlocks*2, votingEndHeight + 100, nil
}

// Added to wait for the upgrade to be applied.
Expand Down
14 changes: 0 additions & 14 deletions tests/upgrade/integration/v3/generated/mint/proposal.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build integration

package integration

import (
Expand Down
92 changes: 92 additions & 0 deletions tests/upgrade/integration/v3/post_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package integration

import (
"path/filepath"

cli "github.com/cheqd/cheqd-node/tests/upgrade/integration/v3/cli"
govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = Describe("Upgrade - Post", func() {

Check failure on line 14 in tests/upgrade/integration/v3/post_test.go

View workflow job for this annotation

GitHub Actions / Lint / Golang

File is not `gofumpt`-ed (gofumpt)
Context("After a software upgrade execution has concluded", func() {
It("should wait for node catching up", func() {
By("pinging the node status until catching up is flagged as false")
err := cli.WaitForCaughtUp(cli.Validator0, cli.CliBinaryName, cli.VotingPeriod*6)
Expect(err).To(BeNil())
})

It("should wait for node catching up", func() {
By("pinging the node status until catching up is flagged as false")
err := cli.WaitForCaughtUp(cli.Validator0, cli.CliBinaryName, cli.VotingPeriod*6)
Expect(err).To(BeNil())
})
It("should submit a parameter change proposal for did module (optimistic)", func() {
By("passing the proposal file to the container")
_, err := cli.LocalnetExecCopyAbsoluteWithPermissions(filepath.Join("proposal.json"), cli.DockerHome, cli.Validator0)
Expect(err).To(BeNil())

By("sending a SubmitParamChangeProposal transaction from `validator0` container")
res, err := cli.SubmitProposal(cli.Validator0, "proposal.json")
Expect(err).To(BeNil())
Expect(res.Code).To(BeEquivalentTo(0))
})

It("should wait for the proposal submission to be included in a block", func() {
By("getting the current block height")
currentHeight, err := cli.GetCurrentBlockHeight(cli.Validator0, cli.CliBinaryName)
Expect(err).To(BeNil())

By("waiting for the proposal to be included in a block")
err = cli.WaitForChainHeight(cli.Validator0, cli.CliBinaryName, currentHeight+10, cli.VotingPeriod*3)
Expect(err).To(BeNil())
})

It("should vote for the parameter change proposal from `validator1` container", func() {
By("sending a VoteProposal transaction from `validator1` container")
res, err := cli.VoteProposal(cli.Validator1, "2", "yes")
Expect(err).To(BeNil())
Expect(res.Code).To(BeEquivalentTo(0))
})

It("should vote for the parameter change proposal from `validator2` container", func() {
By("sending a VoteProposal transaction from `validator2` container")
res, err := cli.VoteProposal(cli.Validator2, "2", "yes")
Expect(err).To(BeNil())
Expect(res.Code).To(BeEquivalentTo(0))
})

It("should vote for the parameter change proposal from `validator3` container", func() {
By("sending a VoteProposal transaction from `validator3` container")
res, err := cli.VoteProposal(cli.Validator3, "2", "yes")
Expect(err).To(BeNil())
Expect(res.Code).To(BeEquivalentTo(0))
})
It("should vote for the parameter change proposal from `validator3` container", func() {
By("sending a VoteProposal transaction from `validator3` container")
res, err := cli.VoteProposal(cli.Validator0, "2", "yes")
Expect(err).To(BeNil())
Expect(res.Code).To(BeEquivalentTo(0))
})
It("should wait for the proposal to pass", func() {
By("getting the current block height")
currentHeight, err := cli.GetCurrentBlockHeight(cli.Validator0, cli.CliBinaryName)
Expect(err).To(BeNil())

By("waiting for the proposal to pass")
err = cli.WaitForChainHeight(cli.Validator0, cli.CliBinaryName, currentHeight+20, cli.VotingPeriod*100)
Expect(err).To(BeNil())
})

It("should check the proposal status to ensure it has passed", func() {
By("sending a QueryProposal query from `validator0` container")
proposal, err := cli.QueryProposal(cli.Validator0, "2")
Expect(err).To(BeNil())
Expect(proposal.Status).To(BeEquivalentTo(govtypesv1.StatusPassed))
})

Check failure on line 90 in tests/upgrade/integration/v3/post_test.go

View workflow job for this annotation

GitHub Actions / Lint / Golang

File is not `gofumpt`-ed (gofumpt)
})
})
150 changes: 150 additions & 0 deletions tests/upgrade/integration/v3/pre_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
package integration

import (
"fmt"

cli "github.com/cheqd/cheqd-node/tests/upgrade/integration/v3/cli"
govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = Describe("Upgrade - Pre", func() {

Check failure on line 13 in tests/upgrade/integration/v3/pre_test.go

View workflow job for this annotation

GitHub Actions / Lint / Golang

File is not `gofumpt`-ed (gofumpt)
Context("Before a software upgrade execution is initiated", func() {
It("should wait for chain to bootstrap", func() {
By("pinging the node status until the voting end height is reached")
err := cli.WaitForChainHeight(cli.Validator0, cli.CliBinaryName, cli.BootstrapHeight, cli.BootstrapPeriod)
Expect(err).To(BeNil())
})

var UpgradeHeight int64
var VotingEndHeight int64

It("should calculate the upgrade height", func() {
By("getting the current block height and calculating the voting end height")
var err error
UpgradeHeight, VotingEndHeight, err = cli.CalculateUpgradeHeight(cli.Validator0, cli.CliBinaryName)
Expect(err).To(BeNil())
fmt.Printf("Upgrade height: %d\n", UpgradeHeight)
fmt.Printf("Voting end height: %d\n", VotingEndHeight)
})

It("should submit a software upgrade proposal", func() {
By("sending a SubmitUpgradeProposal transaction from `validator0` container")
res, err := cli.SubmitUpgradeProposalLegacy(VotingEndHeight, cli.Validator0)
Expect(err).To(BeNil())
fmt.Println("response is>>>>>>.", res)
Expect(res.Code).To(BeEquivalentTo(0))
})

It("should wait for a certain number of blocks to be produced", func() {
By("fetching the current chain height")
currentHeight, err := cli.GetCurrentBlockHeight(cli.Validator0, cli.CliBinaryName)
Expect(err).To(BeNil())

By("waiting for 10 blocks to be produced on top, after the upgrade")
err = cli.WaitForChainHeight(cli.Validator0, cli.CliBinaryName, currentHeight+10, cli.VotingPeriod*6)
Expect(err).To(BeNil())
})

It("should deposit tokens for the software upgrade proposal", func() {
By("sending a DepositGov transaction from `validator0` container")
res, err := cli.DepositGov(cli.Validator0)
Expect(err).To(BeNil())
Expect(res.Code).To(BeEquivalentTo(0))
fmt.Println("response>>>>>>>>>>>>", res)
})

It("should wait for the proposal submission to be included in a block", func() {
By("getting the current block height")
currentHeight, err := cli.GetCurrentBlockHeight(cli.Validator0, cli.CliBinaryName)
Expect(err).To(BeNil())

By("waiting for the proposal to be included in a block")
err = cli.WaitForChainHeight(cli.Validator0, cli.CliBinaryName, currentHeight+3, cli.VotingPeriod*3)
Expect(err).To(BeNil())
})

It("should vote for the software upgrade proposal from `validator0` container", func() {
By("sending a VoteProposal transaction from `validator0` container")
res, err := cli.VoteProposal(cli.Validator0, "1", "yes")
Expect(err).To(BeNil())
fmt.Println("response>>>>>>>>>>>>>>", res)

Expect(res.Code).To(BeEquivalentTo(0))
})

It("should wait for a certain number of blocks to be produced", func() {
By("fetching the current chain height")
currentHeight, err := cli.GetCurrentBlockHeight(cli.Validator0, cli.CliBinaryName)
Expect(err).To(BeNil())

By("waiting for 10 blocks to be produced on top, after the upgrade")
err = cli.WaitForChainHeight(cli.Validator0, cli.CliBinaryName, currentHeight+3, cli.VotingPeriod*6)
Expect(err).To(BeNil())
})
It("should vote for the software upgrade proposal from `validator1` container", func() {
By("sending a VoteProposal transaction from `validator1` container")
res, err := cli.VoteProposal(cli.Validator1, "1", "yes")
Expect(err).To(BeNil())
fmt.Println("response>>>>>>>>>>>>>>", res)

Expect(res.Code).To(BeEquivalentTo(0))
})
It("should wait for a certain number of blocks to be produced", func() {
By("fetching the current chain height")
currentHeight, err := cli.GetCurrentBlockHeight(cli.Validator0, cli.CliBinaryName)
Expect(err).To(BeNil())

By("waiting for 10 blocks to be produced on top, after the upgrade")
err = cli.WaitForChainHeight(cli.Validator0, cli.CliBinaryName, currentHeight+3, cli.VotingPeriod*6)
Expect(err).To(BeNil())
})

It("should vote for the software upgrade proposal from `validator2` container", func() {
By("sending a VoteProposal transaction from `validator2` container")
res, err := cli.VoteProposal(cli.Validator2, "1", "yes")
Expect(err).To(BeNil())
fmt.Println("response>>>>>>>>>>>>>>", res)
Expect(res.Code).To(BeEquivalentTo(0))
})

It("should wait for a certain number of blocks to be produced", func() {
By("fetching the current chain height")
currentHeight, err := cli.GetCurrentBlockHeight(cli.Validator0, cli.CliBinaryName)
Expect(err).To(BeNil())

By("waiting for 10 blocks to be produced on top, after the upgrade")
err = cli.WaitForChainHeight(cli.Validator0, cli.CliBinaryName, currentHeight+3, cli.VotingPeriod*6)
Expect(err).To(BeNil())
})
It("should vote for the software upgrade proposal from `validator3` container", func() {
By("sending a VoteProposal transaction from `validator3` container")
res, err := cli.VoteProposal(cli.Validator3, "1", "yes")
Expect(err).To(BeNil())
fmt.Println("response>>>>>>>>>>>>>>", res)

Expect(res.Code).To(BeEquivalentTo(0))
})

It("should wait for the voting end height to be reached", func() {
By("pinging the node status until the voting end height is reached")
err := cli.WaitForChainHeight(cli.Validator0, cli.CliBinaryName, VotingEndHeight, cli.VotingPeriod*10)
Expect(err).To(BeNil())
})

It("should query the proposal status to ensure it has passed", func() {
By("sending a QueryProposal Msg from `validator0` container")
proposal, err := cli.QueryProposal(cli.Validator0, "1")
Expect(err).To(BeNil())
Expect(proposal.Status).To(BeEquivalentTo(govtypesv1.StatusPassed))
})

It("should wait for the upgrade height to be reached", func() {
By("pinging the node status until the upgrade height is reached")
err := cli.WaitForChainHeight(cli.Validator0, cli.CliBinaryName, UpgradeHeight, cli.VotingPeriod)
Expect(err).To(BeNil())
})
})
})
File renamed without changes.

0 comments on commit 1b70699

Please sign in to comment.