Skip to content

Commit

Permalink
Merge branch 'main' into bump-sdk-0.47.15
Browse files Browse the repository at this point in the history
  • Loading branch information
sampocs authored Jan 28, 2025
2 parents 53a93a5 + d1070b2 commit f0dc86c
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 4 deletions.
78 changes: 78 additions & 0 deletions app/upgrades/v25/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@ package v25_test
import (
"testing"

sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/suite"

ibctesting "github.com/cosmos/ibc-go/v7/testing"

"github.com/Stride-Labs/stride/v24/app/apptesting"
v25 "github.com/Stride-Labs/stride/v24/app/upgrades/v25"
epochtypes "github.com/Stride-Labs/stride/v24/x/epochs/types"
recordtypes "github.com/Stride-Labs/stride/v24/x/records/types"
stakeibctypes "github.com/Stride-Labs/stride/v24/x/stakeibc/types"
oldstaketiatypes "github.com/Stride-Labs/stride/v24/x/staketia/legacytypes"
"github.com/Stride-Labs/stride/v24/x/staketia/types"
staketiatypes "github.com/Stride-Labs/stride/v24/x/staketia/types"
)

type UpgradeTestSuite struct {
Expand All @@ -21,5 +32,72 @@ func TestKeeperTestSuite(t *testing.T) {
}

func (s *UpgradeTestSuite) TestUpgrade() {
upgradeHeight := int64(4)

// Setup state before upgrade
checkStaketiaMigration := s.SetupStaketiaMigration()

// Run upgrade
s.ConfirmUpgradeSucceededs(v25.UpgradeName, upgradeHeight)

// Validate state after upgrade
checkStaketiaMigration()
}

func (s *UpgradeTestSuite) SetupStaketiaMigration() func() {
delegatedBalance := sdkmath.NewInt(100)

// Create a transfer channel (which will create a connection)
s.CreateTransferChannel(staketiatypes.CelestiaChainId)

// Mint stTIA for the redemption rate
s.FundAccount(s.TestAccs[0], sdk.NewCoin("st"+staketiatypes.CelestiaNativeTokenDenom, sdk.NewInt(1000)))

// Store the staketia host zone
s.App.StaketiaKeeper.SetLegacyHostZone(s.Ctx, oldstaketiatypes.HostZone{
ChainId: staketiatypes.CelestiaChainId,
NativeTokenDenom: staketiatypes.CelestiaNativeTokenDenom,
NativeTokenIbcDenom: staketiatypes.CelestiaNativeTokenIBCDenom,
DepositAddress: s.TestAccs[1].String(),
TransferChannelId: ibctesting.FirstChannelID,
MinRedemptionRate: sdk.MustNewDecFromStr("0.90"),
MaxRedemptionRate: sdk.MustNewDecFromStr("1.5"),
RedemptionRate: sdk.MustNewDecFromStr("1.2"),
DelegatedBalance: delegatedBalance,
})

// Create epoch trackers and EURs which are needed for the stakeibc registration
s.App.StakeibcKeeper.SetEpochTracker(s.Ctx, stakeibctypes.EpochTracker{
EpochIdentifier: epochtypes.DAY_EPOCH,
EpochNumber: uint64(1),
})
s.App.StakeibcKeeper.SetEpochTracker(s.Ctx, stakeibctypes.EpochTracker{
EpochIdentifier: epochtypes.STRIDE_EPOCH,
EpochNumber: uint64(1),
})
epochUnbondingRecord := recordtypes.EpochUnbondingRecord{
EpochNumber: uint64(1),
HostZoneUnbondings: []*recordtypes.HostZoneUnbonding{},
}
s.App.RecordsKeeper.SetEpochUnbondingRecord(s.Ctx, epochUnbondingRecord)

// Before we call the migration function, temporarily update the variable to be connection-0 to match the above
// and then set it back after the function call for other tests that use it
mainnetConnectionId := staketiatypes.CelestiaConnectionId
types.CelestiaConnectionId = ibctesting.FirstConnectionID

// Return a callback to check the state after the upgrade
return func() {
// Set back the connectionID
types.CelestiaConnectionId = mainnetConnectionId

// Confirm the stakeibc host zone was created
hostZone, found := s.App.StakeibcKeeper.GetHostZone(s.Ctx, staketiatypes.CelestiaChainId)
s.Require().True(found, "Host zone should have been found")
s.Require().Equal(delegatedBalance, hostZone.TotalDelegations, "Delegated balance")

// Confirm the validator set was registered
s.Require().Equal(len(hostZone.Validators), len(v25.Validators), "Number of validators")
s.Require().Equal(hostZone.Validators[0].Address, "celestiavaloper1uvytvhunccudw8fzaxvsrumec53nawyj939gj9", "First validator")
}
}
8 changes: 4 additions & 4 deletions scripts/version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ update_version ./scripts/protocgen.sh

echo ">>> Committing changes..."

# git add .
# git commit -m "updated package from $OLD_VERSION -> $NEW_VERSION"
git add .
git commit -m "updated package from $OLD_VERSION -> $NEW_VERSION"

# Re-generate protos
echo ">>> Rebuilding protos..."

make proto-all

# git add .
# git commit -m 'generated protos'
git add .
git commit -m 'generated protos'

echo "Done"

0 comments on commit f0dc86c

Please sign in to comment.