Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
hoank101 committed Feb 6, 2024
1 parent 0c4534e commit a77bad0
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 23 deletions.
16 changes: 8 additions & 8 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package app

import (
"cosmossdk.io/math"
"encoding/json"
"fmt"
"testing"
"time"

"cosmossdk.io/math"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
Expand All @@ -13,15 +16,12 @@ import (
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakinghelper "github.com/cosmos/cosmos-sdk/x/staking/testutil"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"testing"
"time"

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
config "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app/params"
dbm "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
tdmtypes "github.com/cometbft/cometbft/proto/tendermint/types"
tmtypes "github.com/cometbft/cometbft/types"

"github.com/cosmos/cosmos-sdk/baseapp"
Expand Down Expand Up @@ -56,10 +56,10 @@ type KeeperTestHelper struct {
StakingHelper *stakinghelper.Helper
}

func (s *KeeperTestHelper) Setup(_ *testing.T, chainID string) {
func (s *KeeperTestHelper) Setup(_ *testing.T) {
t := s.T()
s.App = SetupApp(t)
s.Ctx = s.App.BaseApp.NewContext(false, tdmtypes.Header{Height: 1, ChainID: "test-1", Time: time.Now().UTC()})
s.Ctx = s.App.BaseApp.NewContext(false, tmproto.Header{Height: 1, ChainID: "test-1", Time: time.Now().UTC()})
s.QueryHelper = &baseapp.QueryServiceTestHelper{
GRPCQueryRouter: s.App.GRPCQueryRouter(),
Ctx: s.Ctx,
Expand Down Expand Up @@ -274,7 +274,7 @@ func (s *KeeperTestHelper) Commit() {
oldHeight := s.Ctx.BlockHeight()
oldHeader := s.Ctx.BlockHeader()
s.App.Commit()
newHeader := tdmtypes.Header{Height: oldHeight + 1, ChainID: "testing", Time: oldHeader.Time.Add(time.Second)}
newHeader := tmproto.Header{Height: oldHeight + 1, ChainID: "testing", Time: oldHeader.Time.Add(time.Second)}
s.App.BeginBlock(abci.RequestBeginBlock{Header: newHeader})
s.Ctx = s.App.NewContext(false, newHeader)
}
Expand Down Expand Up @@ -358,7 +358,7 @@ func (s *KeeperTestHelper) BeginNewBlockWithProposer(proposer sdk.ValAddress) {

newBlockTime := s.Ctx.BlockTime().Add(5 * time.Second)

header := tdmtypes.Header{Height: s.Ctx.BlockHeight() + 1, Time: newBlockTime}
header := tmproto.Header{Height: s.Ctx.BlockHeight() + 1, Time: newBlockTime}
newCtx := s.Ctx.WithBlockTime(newBlockTime).WithBlockHeight(s.Ctx.BlockHeight() + 1)
s.Ctx = newCtx
lastCommitInfo := abci.CommitInfo{
Expand Down
6 changes: 4 additions & 2 deletions app/upgrades/v4_1_0/mainnet_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package v4

import (
"encoding/json"

authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
bankKeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"

Expand All @@ -14,7 +15,8 @@ import (

func CreateMainnetVestingAccount(ctx sdk.Context,
bankKeeper bankKeeper.Keeper,
accountKeeper authkeeper.AccountKeeper) (*vestingtypes.ContinuousVestingAccount, math.Int) {
accountKeeper authkeeper.AccountKeeper,
) (vestingtypes.ContinuousVestingAccount, math.Int) {
str := `{"@type":"/cosmos.vesting.v1beta1.ContinuousVestingAccount","base_vesting_account":{"base_account":{"address":"migaloo1alga5e8vr6ccr9yrg0kgxevpt5xgmgrvqgujs6","pub_key":{"@type":"/cosmos.crypto.multisig.LegacyAminoPubKey","threshold":4,"public_keys":[{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AlnzK22KrkylnvTCvZZc8eZnydtQuzCWLjJJSMFUvVHf"},{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"Aiw2Ftg+fnoHDU7M3b0VMRsI0qurXlerW0ahtfzSDZA4"},{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AvEHv+MVYRVau8FbBcJyG0ql85Tbbn7yhSA0VGmAY4ku"},{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"Az5VHWqi3zMJu1rLGcu2EgNXLLN+al4Dy/lj6UZTzTCl"},{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"Ai4GlSH3uG+joMnAFbQC3jQeHl9FPvVTlRmwIFt7d7TI"},{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A2kAzH2bZr530jmFq/bRFrT2q8SRqdnfIebba+YIBqI1"}]},"account_number":46,"sequence":27},"original_vesting":[{"denom":"uwhale","amount":"22165200000000"}],"delegated_free":[{"denom":"uwhale","amount":"443382497453"}],"delegated_vesting":[{"denom":"uwhale","amount":"22129422502547"}],"end_time":1770994800},"start_time":1676300400}`

var acc vestingtypes.ContinuousVestingAccount
Expand All @@ -31,5 +33,5 @@ func CreateMainnetVestingAccount(ctx sdk.Context,
}

accountKeeper.SetAccount(ctx, &acc)
return &acc, vesting
return acc, vesting
}
21 changes: 13 additions & 8 deletions app/upgrades/v4_1_0/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ func CreateUpgradeHandler(
func migrateMultisigVesting(ctx sdk.Context,
stakingKeeper stakingKeeper.Keeper,
bankKeeper bankKeeper.Keeper,
accountKeeper authkeeper.AccountKeeper) {
accountKeeper authkeeper.AccountKeeper,
) {
currentAddr := sdk.MustAccAddressFromBech32(NotionalMultisigVestingAccount)
newAddr := sdk.MustAccAddressFromBech32(NewNotionalMultisigVestingAccount)

Expand All @@ -88,7 +89,8 @@ func migrateMultisigVesting(ctx sdk.Context,

func processMigrateMultisig(ctx sdk.Context, stakingKeeper stakingKeeper.Keeper,
bankKeeper bankKeeper.Keeper, currentAddr, newAddr sdk.AccAddress,
oldAcc *vestingtypes.ContinuousVestingAccount) { // nolint:gocritic
oldAcc *vestingtypes.ContinuousVestingAccount,
) {
redelegated, err := completeAllRedelegations(ctx, ctx.BlockTime(), stakingKeeper, currentAddr)
if err != nil {
panic(err)
Expand All @@ -102,7 +104,7 @@ func processMigrateMultisig(ctx sdk.Context, stakingKeeper stakingKeeper.Keeper,
fmt.Printf("currentAddr Instant Redelegations: %s\n", redelegated)
fmt.Printf("currentAddr Instant Unbonding: %s\n", unbonded)

//delegate vesting coin to validator
// delegate vesting coin to validator
err = delegateToValidator(ctx, stakingKeeper, currentAddr, oldAcc.GetVestingCoins(ctx.BlockTime())[0].Amount)
if err != nil {
panic(err)
Expand All @@ -121,16 +123,17 @@ func processMigrateMultisig(ctx sdk.Context, stakingKeeper stakingKeeper.Keeper,
if err != nil {
panic(err)
}

}

func GetVestingCoin(ctx sdk.Context, acc *vestingtypes.ContinuousVestingAccount) (unvested math.Int) {
vestingCoin := acc.GetVestingCoins(ctx.BlockTime())
return vestingCoin[0].Amount
}

func completeAllRedelegations(ctx sdk.Context, now time.Time,
stakingKeeper stakingKeeper.Keeper,
accAddr sdk.AccAddress) (math.Int, error) {
accAddr sdk.AccAddress,
) (math.Int, error) {
redelegatedAmt := math.ZeroInt()

for _, activeRedelegation := range stakingKeeper.GetRedelegations(ctx, accAddr, 65535) {
Expand All @@ -155,7 +158,8 @@ func completeAllRedelegations(ctx sdk.Context, now time.Time,

func unbondAllAndFinish(ctx sdk.Context, now time.Time,
stakingKeeper stakingKeeper.Keeper,
accAddr sdk.AccAddress) (math.Int, error) {
accAddr sdk.AccAddress,
) (math.Int, error) {
unbondedAmt := math.ZeroInt()

// Unbond all delegations from the account
Expand Down Expand Up @@ -196,8 +200,9 @@ func unbondAllAndFinish(ctx sdk.Context, now time.Time,
// delegate to top 10 validator
func delegateToValidator(ctx sdk.Context,
stakingKeeper stakingKeeper.Keeper,
accAddr sdk.AccAddress, totalVestingBalance math.Int) error {

accAddr sdk.AccAddress,
totalVestingBalance math.Int,
) error {
listValidator := stakingKeeper.GetBondedValidatorsByPower(ctx)
totalValidatorDelegate := math.Min(10, len(listValidator))
balanceDelegate := totalVestingBalance.Quo(totalVestingBalance)
Expand Down
6 changes: 3 additions & 3 deletions app/upgrades/v4_1_0/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package v4_test

import (
"fmt"
"testing"

"github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app/params"
v4 "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app/upgrades/v4_1_0"
sdk "github.com/cosmos/cosmos-sdk/types"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"testing"

apptesting "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app"
"github.com/stretchr/testify/suite"
Expand All @@ -23,7 +24,7 @@ func TestUpgradeTestSuite(t *testing.T) {

// Ensures the test does not error out.
func (s *UpgradeTestSuite) TestUpgrade() {
s.Setup(s.T(), apptesting.SimAppChainID)
s.Setup(s.T())
// == CREATE MOCK VESTING ACCOUNT ==
cVesting, unvested := v4.CreateMainnetVestingAccount(s.Ctx, s.App.BankKeeper, s.App.AccountKeeper)
vestingAddr := cVesting.GetAddress()
Expand Down Expand Up @@ -79,5 +80,4 @@ func (s *UpgradeTestSuite) TestUpgrade() {
vestedBalance := cVesting.GetVestedCoins(s.Ctx.BlockTime())
fmt.Printf("New multisign Upgrade Balance: %s\n", newBalance)
s.Require().True(newBalance.AmountOf(params.BaseDenom).LTE(vestedBalance.AmountOf(params.BaseDenom)))

}
2 changes: 1 addition & 1 deletion x/feeburn/ante/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type AnteTestSuite struct {

// SetupTest setups a new test, with new app, context, and anteHandler.
func (suite *AnteTestSuite) SetupTest() {
suite.Setup(suite.T(), apptesting.SimAppChainID)
suite.Setup(suite.T())

// Set up TxConfig.
encodingConfig := simapp.MakeTestEncodingConfig()
Expand Down
2 changes: 1 addition & 1 deletion x/feeburn/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type KeeperTestSuite struct {

// SetupTest setups a new test, with new app, context, and anteHandler.
func (suite *KeeperTestSuite) SetupTest() {
suite.Setup(suite.T(), apptesting.SimAppChainID)
suite.Setup(suite.T())

// Set up TxConfig.
encodingConfig := config.MakeEncodingConfig()
Expand Down

0 comments on commit a77bad0

Please sign in to comment.