From d823c27914aae040e95478ca127d4deed9fef453 Mon Sep 17 00:00:00 2001 From: Benjamin DENEUX Date: Mon, 3 Apr 2023 17:01:12 +0200 Subject: [PATCH] feat(vesting): update to sdk047 --- Makefile | 1 + app/app.go | 2 +- x/vesting/client/testutil/cli_test.go | 18 - x/vesting/client/testutil/suite.go | 225 --- x/vesting/module.go | 16 +- x/vesting/msg_server.go | 31 +- x/vesting/msg_server_test.go | 314 ++++ x/vesting/testutil/expected_keepers_mocks.go | 82 + x/vesting/types/tx.pb.go | 87 +- x/vesting/types/vesting.pb.go | 75 +- x/vesting/types/vesting_account_test.go | 1718 +++++++++--------- 11 files changed, 1357 insertions(+), 1212 deletions(-) delete mode 100644 x/vesting/client/testutil/cli_test.go delete mode 100644 x/vesting/client/testutil/suite.go create mode 100644 x/vesting/msg_server_test.go create mode 100644 x/vesting/testutil/expected_keepers_mocks.go diff --git a/Makefile b/Makefile index 48106f5e..49af2d8b 100644 --- a/Makefile +++ b/Makefile @@ -403,6 +403,7 @@ mock: ## Generate all the mocks (for tests) @echo "${COLOR_CYAN} 🧱 Generating all the mocks${COLOR_RESET}" @go install github.com/golang/mock/mockgen@v1.6.0 @mockgen -source=x/mint/types/expected_keepers.go -package testutil -destination x/mint/testutil/expected_keepers_mocks.go + @mockgen -source=x/vesting/types/expected_keepers.go -package testutil -destination x/vesting/testutil/expected_keepers_mocks.go @mockgen -source=x/logic/types/expected_keepers.go -package testutil -destination x/logic/testutil/expected_keepers_mocks.go @mockgen -destination x/logic/testutil/gas_mocks.go -package testutil github.com/cosmos/cosmos-sdk/store/types GasMeter @mockgen -destination x/logic/testutil/fs_mocks.go -package testutil -source=x/logic/fs/fs.go diff --git a/app/app.go b/app/app.go index 514ce82c..319e8a69 100644 --- a/app/app.go +++ b/app/app.go @@ -427,7 +427,7 @@ func New( app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, - authtypes.NewModuleAddress(govtypes.ModuleName), + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) app.DistrKeeper = distrkeeper.NewKeeper( diff --git a/x/vesting/client/testutil/cli_test.go b/x/vesting/client/testutil/cli_test.go deleted file mode 100644 index 1035ca75..00000000 --- a/x/vesting/client/testutil/cli_test.go +++ /dev/null @@ -1,18 +0,0 @@ -//go:build norace -// +build norace - -package testutil - -import ( - "testing" - - "github.com/cosmos/cosmos-sdk/testutil/network" - - "github.com/stretchr/testify/suite" -) - -func TestIntegrationTestSuite(t *testing.T) { - cfg := network.DefaultConfig() - cfg.NumValidators = 1 - suite.Run(t, NewIntegrationTestSuite(cfg)) -} diff --git a/x/vesting/client/testutil/suite.go b/x/vesting/client/testutil/suite.go deleted file mode 100644 index 3da35efb..00000000 --- a/x/vesting/client/testutil/suite.go +++ /dev/null @@ -1,225 +0,0 @@ -package testutil - -import ( - "fmt" - - "github.com/gogo/protobuf/proto" - "github.com/stretchr/testify/suite" - - "github.com/cosmos/cosmos-sdk/client/flags" - clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" - "github.com/cosmos/cosmos-sdk/testutil/network" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/okp4/okp4d/x/vesting/client/cli" -) - -type IntegrationTestSuite struct { - suite.Suite - - cfg network.Config - network *network.Network -} - -func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite { - return &IntegrationTestSuite{cfg: cfg} -} - -func (s *IntegrationTestSuite) SetupSuite() { - s.T().Log("setting up integration test suite") - - var err error - s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg) - s.Require().NoError(err) - - _, err = s.network.WaitForHeight(1) - s.Require().NoError(err) -} - -func (s *IntegrationTestSuite) TearDownSuite() { - s.T().Log("tearing down integration test suite") - s.network.Cleanup() -} - -//nolint:funlen -func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() { - val := s.network.Validators[0] - - testCases := map[string]struct { - args []string - expectErr bool - expectedCode uint32 - respType proto.Message - }{ - "create a continuous vesting account": { - args: []string{ - sdk.AccAddress("addr2_______________").String(), - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String(), - "4070908800", - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), - }, - expectErr: false, - expectedCode: 0, - respType: &sdk.TxResponse{}, - }, - "create a delayed vesting account": { - args: []string{ - sdk.AccAddress("addr3_______________").String(), - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String(), - "4070908800", - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), - fmt.Sprintf("--%s=true", cli.FlagDelayed), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), - }, - expectErr: false, - expectedCode: 0, - respType: &sdk.TxResponse{}, - }, - "invalid address": { - args: []string{ - "addr4", - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String(), - "4070908800", - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), - }, - expectErr: true, - expectedCode: 0, - respType: &sdk.TxResponse{}, - }, - "invalid coins": { - args: []string{ - sdk.AccAddress("addr4_______________").String(), - "fooo", - "4070908800", - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), - }, - expectErr: true, - expectedCode: 0, - respType: &sdk.TxResponse{}, - }, - "invalid end time": { - args: []string{ - sdk.AccAddress("addr4_______________").String(), - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String(), - "-4070908800", - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), - }, - expectErr: true, - expectedCode: 0, - respType: &sdk.TxResponse{}, - }, - } - - // Synchronize height between test runs, to ensure sequence numbers are - // properly updated. - height, err := s.network.LatestHeight() - if err != nil { - s.T().Fatalf("Getting initial latest height: %v", err) - } - s.T().Logf("Initial latest height: %d", height) - for name, tc := range testCases { - tc := tc - - s.Run(name, func() { - clientCtx := val.ClientCtx - - bw, err := clitestutil.ExecTestCLICmd(clientCtx, cli.NewMsgCreateVestingAccountCmd(), tc.args) - if tc.expectErr { - s.Require().Error(err) - } else { - s.Require().NoError(err) - s.Require().NoError(clientCtx.Codec.UnmarshalJSON(bw.Bytes(), tc.respType), bw.String()) - - txResp := tc.respType.(*sdk.TxResponse) - s.Require().Equal(tc.expectedCode, txResp.Code) - } - }) - - next, err := s.network.WaitForHeight(height + 1) - if err != nil { - s.T().Fatalf("Waiting for height %d: %v", height+1, err) - } - height = next - s.T().Logf("Height now: %d", height) - } -} - -//nolint:funlen -func (s *IntegrationTestSuite) TestNewMsgCreatePermanentLockedAccountCmd() { - val := s.network.Validators[0] - - testCases := map[string]struct { - args []string - expectErr bool - expectedCode uint32 - respType proto.Message - }{ - "create a permanent locked account": { - args: []string{ - sdk.AccAddress("addr4_______________").String(), - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String(), - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), - }, - expectErr: false, - expectedCode: 0, - respType: &sdk.TxResponse{}, - }, - "invalid address": { - args: []string{ - "addr4", - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String(), - "4070908800", - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), - }, - expectErr: true, - expectedCode: 0, - respType: &sdk.TxResponse{}, - }, - "invalid coins": { - args: []string{ - sdk.AccAddress("addr4_______________").String(), - "fooo", - "4070908800", - fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), - }, - expectErr: true, - expectedCode: 0, - respType: &sdk.TxResponse{}, - }, - } - - // Synchronize height between test runs, to ensure sequence numbers are - // properly updated. - height, err := s.network.LatestHeight() - s.Require().NoError(err, "Getting initial latest height") - s.T().Logf("Initial latest height: %d", height) - for name, tc := range testCases { - tc := tc - - s.Run(name, func() { - clientCtx := val.ClientCtx - - bw, err := clitestutil.ExecTestCLICmd(clientCtx, cli.NewMsgCreatePermanentLockedAccountCmd(), tc.args) - if tc.expectErr { - s.Require().Error(err) - } else { - s.Require().NoError(err) - s.Require().NoError(clientCtx.Codec.UnmarshalJSON(bw.Bytes(), tc.respType), bw.String()) - - txResp := tc.respType.(*sdk.TxResponse) - s.Require().Equal(tc.expectedCode, txResp.Code) - } - }) - next, err := s.network.WaitForHeight(height + 1) - s.Require().NoError(err, "Waiting for height...") - height = next - s.T().Logf("Height now: %d", height) - } -} diff --git a/x/vesting/module.go b/x/vesting/module.go index 5c23e072..e0fc66b4 100644 --- a/x/vesting/module.go +++ b/x/vesting/module.go @@ -3,9 +3,9 @@ package vesting import ( "encoding/json" + abci "github.com/cometbft/cometbft/abci/types" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" - abci "github.com/tendermint/tendermint/abci/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -87,25 +87,11 @@ func NewAppModule(ak keeper.AccountKeeper, bk types.BankKeeper) AppModule { // RegisterInvariants performs a no-op; there are no invariants to enforce. func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} -// Deprecated: Route returns the module's message router and handler. -func (am AppModule) Route() sdk.Route { - return sdk.Route{} -} - -// QuerierRoute returns an empty string as the module contains no query -// functionality. -func (AppModule) QuerierRoute() string { return "" } - // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), NewMsgServerImpl(am.accountKeeper, am.bankKeeper)) } -// LegacyQuerierHandler performs a no-op. -func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { - return nil -} - // InitGenesis performs a no-op. func (am AppModule) InitGenesis(_ sdk.Context, _ codec.JSONCodec, _ json.RawMessage) []abci.ValidatorUpdate { return []abci.ValidatorUpdate{} diff --git a/x/vesting/msg_server.go b/x/vesting/msg_server.go index ebb53299..ed068a6b 100644 --- a/x/vesting/msg_server.go +++ b/x/vesting/msg_server.go @@ -87,13 +87,6 @@ func (s msgServer) CreateVestingAccount(goCtx context.Context, return nil, err } - ctx.EventManager().EmitEvent( - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - ) - return &types.MsgCreateVestingAccountResponse{}, nil } @@ -150,13 +143,6 @@ func (s msgServer) CreatePermanentLockedAccount(goCtx context.Context, return nil, err } - ctx.EventManager().EmitEvent( - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - ) - return &types.MsgCreatePermanentLockedAccountResponse{}, nil } @@ -187,6 +173,10 @@ func (s msgServer) CreatePeriodicVestingAccount(goCtx context.Context, totalCoins = totalCoins.Add(period.Amount...) } + if err := bk.IsSendEnabledCoins(ctx, totalCoins...); err != nil { + return nil, err + } + baseAccount := authtypes.NewBaseAccountWithAddress(to) baseAccount = ak.NewAccount(ctx, baseAccount).(*authtypes.BaseAccount) vestingAccount := types.NewPeriodicVestingAccount(baseAccount, totalCoins.Sort(), msg.StartTime, msg.VestingPeriods) @@ -212,12 +202,6 @@ func (s msgServer) CreatePeriodicVestingAccount(goCtx context.Context, return nil, err } - ctx.EventManager().EmitEvent( - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - ) return &types.MsgCreatePeriodicVestingAccountResponse{}, nil } @@ -277,12 +261,5 @@ func (s msgServer) CreateCliffVestingAccount(goCtx context.Context, return nil, err } - ctx.EventManager().EmitEvent( - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - ) - return &types.MsgCreateCliffVestingAccountResponse{}, nil } diff --git a/x/vesting/msg_server_test.go b/x/vesting/msg_server_test.go new file mode 100644 index 00000000..a9f15a59 --- /dev/null +++ b/x/vesting/msg_server_test.go @@ -0,0 +1,314 @@ +package vesting_test + +import ( + "testing" + "time" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + tmtime "github.com/cometbft/cometbft/types/time" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/suite" + + "github.com/cosmos/cosmos-sdk/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/okp4/okp4d/x/vesting" + vestingtestutil "github.com/okp4/okp4d/x/vesting/testutil" + vestingtypes "github.com/okp4/okp4d/x/vesting/types" +) + +var ( + fromAddr = sdk.AccAddress([]byte("from1________________")) + to1Addr = sdk.AccAddress([]byte("to1__________________")) + to2Addr = sdk.AccAddress([]byte("to2__________________")) + to3Addr = sdk.AccAddress([]byte("to3__________________")) + fooCoin = sdk.NewInt64Coin("foo", 100) + periodCoin = sdk.NewInt64Coin("foo", 20) +) + +type VestingTestSuite struct { + suite.Suite + + ctx sdk.Context + accountKeeper authkeeper.AccountKeeper + bankKeeper *vestingtestutil.MockBankKeeper + msgServer vestingtypes.MsgServer +} + +func (s *VestingTestSuite) SetupTest() { + key := sdk.NewKVStoreKey(authtypes.StoreKey) + testCtx := testutil.DefaultContextWithDB(s.T(), key, sdk.NewTransientStoreKey("transient_test")) + s.ctx = testCtx.Ctx.WithBlockHeader(tmproto.Header{Time: tmtime.Now()}) + encCfg := moduletestutil.MakeTestEncodingConfig() + + maccPerms := map[string][]string{} + + ctrl := gomock.NewController(s.T()) + s.bankKeeper = vestingtestutil.NewMockBankKeeper(ctrl) + s.accountKeeper = authkeeper.NewAccountKeeper( + encCfg.Codec, + key, + authtypes.ProtoBaseAccount, + maccPerms, + "cosmos", + authtypes.NewModuleAddress("gov").String(), + ) + + vestingtypes.RegisterInterfaces(encCfg.InterfaceRegistry) + authtypes.RegisterInterfaces(encCfg.InterfaceRegistry) + s.msgServer = vesting.NewMsgServerImpl(s.accountKeeper, s.bankKeeper) +} + +func (s *VestingTestSuite) TestCreateVestingAccount() { + testCases := map[string]struct { + preRun func() + input *vestingtypes.MsgCreateVestingAccount + expErr bool + expErrMsg string + }{ + "create for existing account": { + preRun: func() { + toAcc := s.accountKeeper.NewAccountWithAddress(s.ctx, to1Addr) + s.bankKeeper.EXPECT().IsSendEnabledCoins(gomock.Any(), fooCoin).Return(nil) + s.accountKeeper.SetAccount(s.ctx, toAcc) + s.bankKeeper.EXPECT().BlockedAddr(to1Addr).Return(false) + }, + input: vestingtypes.NewMsgCreateVestingAccount( + fromAddr, + to1Addr, + sdk.Coins{fooCoin}, + time.Now().Unix(), + true, + ), + expErr: true, + expErrMsg: "already exists", + }, + "create a valid delayed vesting account": { + preRun: func() { + s.bankKeeper.EXPECT().IsSendEnabledCoins(gomock.Any(), fooCoin).Return(nil) + s.bankKeeper.EXPECT().BlockedAddr(to2Addr).Return(false) + s.bankKeeper.EXPECT().SendCoins(gomock.Any(), fromAddr, to2Addr, sdk.Coins{fooCoin}).Return(nil) + }, + input: vestingtypes.NewMsgCreateVestingAccount( + fromAddr, + to2Addr, + sdk.Coins{fooCoin}, + time.Now().Unix(), + true, + ), + expErr: false, + expErrMsg: "", + }, + "create a valid continuous vesting account": { + preRun: func() { + s.bankKeeper.EXPECT().IsSendEnabledCoins(gomock.Any(), fooCoin).Return(nil) + s.bankKeeper.EXPECT().BlockedAddr(to3Addr).Return(false) + s.bankKeeper.EXPECT().SendCoins(gomock.Any(), fromAddr, to3Addr, sdk.Coins{fooCoin}).Return(nil) + }, + input: vestingtypes.NewMsgCreateVestingAccount( + fromAddr, + to3Addr, + sdk.Coins{fooCoin}, + time.Now().Unix(), + false, + ), + expErr: false, + expErrMsg: "", + }, + } + + for name, tc := range testCases { + s.Run(name, func() { + tc.preRun() + _, err := s.msgServer.CreateVestingAccount(s.ctx, tc.input) + if tc.expErr { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.expErrMsg) + } else { + s.Require().NoError(err) + } + }) + } +} + +func (s *VestingTestSuite) TestCreatePermanentLockedAccount() { + testCases := map[string]struct { + preRun func() + input *vestingtypes.MsgCreatePermanentLockedAccount + expErr bool + expErrMsg string + }{ + "create for existing account": { + preRun: func() { + toAcc := s.accountKeeper.NewAccountWithAddress(s.ctx, to1Addr) + s.bankKeeper.EXPECT().IsSendEnabledCoins(gomock.Any(), fooCoin).Return(nil) + s.bankKeeper.EXPECT().BlockedAddr(to1Addr).Return(false) + s.accountKeeper.SetAccount(s.ctx, toAcc) + }, + input: vestingtypes.NewMsgCreatePermanentLockedAccount( + fromAddr, + to1Addr, + sdk.Coins{fooCoin}, + ), + expErr: true, + expErrMsg: "already exists", + }, + "create a valid permanent locked account": { + preRun: func() { + s.bankKeeper.EXPECT().IsSendEnabledCoins(gomock.Any(), fooCoin).Return(nil) + s.bankKeeper.EXPECT().BlockedAddr(to2Addr).Return(false) + s.bankKeeper.EXPECT().SendCoins(gomock.Any(), fromAddr, to2Addr, sdk.Coins{fooCoin}).Return(nil) + }, + input: vestingtypes.NewMsgCreatePermanentLockedAccount( + fromAddr, + to2Addr, + sdk.Coins{fooCoin}, + ), + expErr: false, + expErrMsg: "", + }, + } + + for name, tc := range testCases { + s.Run(name, func() { + tc.preRun() + _, err := s.msgServer.CreatePermanentLockedAccount(s.ctx, tc.input) + if tc.expErr { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.expErrMsg) + } else { + s.Require().NoError(err) + } + }) + } +} + +func (s *VestingTestSuite) TestCreatePeriodicVestingAccount() { + testCases := []struct { + name string + preRun func() + input *vestingtypes.MsgCreatePeriodicVestingAccount + expErr bool + expErrMsg string + }{ + { + name: "create for existing account", + preRun: func() { + toAcc := s.accountKeeper.NewAccountWithAddress(s.ctx, to1Addr) + s.accountKeeper.SetAccount(s.ctx, toAcc) + }, + input: vestingtypes.NewMsgCreatePeriodicVestingAccount( + fromAddr, + to1Addr, + time.Now().Unix(), + []vestingtypes.Period{ + { + Length: 10, + Amount: sdk.NewCoins(periodCoin), + }, + }, + ), + expErr: true, + expErrMsg: "already exists", + }, + { + name: "create a valid periodic vesting account", + preRun: func() { + s.bankKeeper.EXPECT().IsSendEnabledCoins(gomock.Any(), periodCoin.Add(fooCoin)).Return(nil) + s.bankKeeper.EXPECT().SendCoins(gomock.Any(), fromAddr, to2Addr, gomock.Any()).Return(nil) + }, + input: vestingtypes.NewMsgCreatePeriodicVestingAccount( + fromAddr, + to2Addr, + time.Now().Unix(), + []vestingtypes.Period{ + { + Length: 10, + Amount: sdk.NewCoins(periodCoin), + }, + { + Length: 20, + Amount: sdk.NewCoins(fooCoin), + }, + }, + ), + expErr: false, + expErrMsg: "", + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + tc.preRun() + _, err := s.msgServer.CreatePeriodicVestingAccount(s.ctx, tc.input) + if tc.expErr { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.expErrMsg) + } else { + s.Require().NoError(err) + } + }) + } +} + +func (s *VestingTestSuite) TestCreateCliffVestingAccount() { + testCases := map[string]struct { + preRun func() + input *vestingtypes.MsgCreateCliffVestingAccount + expErr bool + expErrMsg string + }{ + "create for existing account": { + preRun: func() { + toAcc := s.accountKeeper.NewAccountWithAddress(s.ctx, to1Addr) + s.bankKeeper.EXPECT().IsSendEnabledCoins(gomock.Any(), fooCoin).Return(nil) + s.accountKeeper.SetAccount(s.ctx, toAcc) + s.bankKeeper.EXPECT().BlockedAddr(to1Addr).Return(false) + }, + input: vestingtypes.NewMsgCreateCliffVestingAccount( + fromAddr, + to1Addr, + sdk.Coins{fooCoin}, + time.Now().Add(24*time.Hour).Unix(), + time.Now().Add(12*time.Hour).Unix(), + ), + expErr: true, + expErrMsg: "already exists", + }, + "create a valid cliff vesting account": { + preRun: func() { + s.bankKeeper.EXPECT().IsSendEnabledCoins(gomock.Any(), fooCoin).Return(nil) + s.bankKeeper.EXPECT().BlockedAddr(to3Addr).Return(false) + s.bankKeeper.EXPECT().SendCoins(gomock.Any(), fromAddr, to3Addr, sdk.Coins{fooCoin}).Return(nil) + }, + input: vestingtypes.NewMsgCreateCliffVestingAccount( + fromAddr, + to3Addr, + sdk.Coins{fooCoin}, + time.Now().Add(24*time.Hour).Unix(), + time.Now().Add(12*time.Hour).Unix(), + ), + expErr: false, + expErrMsg: "", + }, + } + + for name, tc := range testCases { + s.Run(name, func() { + tc.preRun() + _, err := s.msgServer.CreateCliffVestingAccount(s.ctx, tc.input) + if tc.expErr { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.expErrMsg) + } else { + s.Require().NoError(err) + } + }) + } +} + +func TestVestingTestSuite(t *testing.T) { + suite.Run(t, new(VestingTestSuite)) +} diff --git a/x/vesting/testutil/expected_keepers_mocks.go b/x/vesting/testutil/expected_keepers_mocks.go new file mode 100644 index 00000000..08fca1cc --- /dev/null +++ b/x/vesting/testutil/expected_keepers_mocks.go @@ -0,0 +1,82 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: x/vesting/types/expected_keepers.go + +// Package testutil is a generated GoMock package. +package testutil + +import ( + reflect "reflect" + + types "github.com/cosmos/cosmos-sdk/types" + gomock "github.com/golang/mock/gomock" +) + +// MockBankKeeper is a mock of BankKeeper interface. +type MockBankKeeper struct { + ctrl *gomock.Controller + recorder *MockBankKeeperMockRecorder +} + +// MockBankKeeperMockRecorder is the mock recorder for MockBankKeeper. +type MockBankKeeperMockRecorder struct { + mock *MockBankKeeper +} + +// NewMockBankKeeper creates a new mock instance. +func NewMockBankKeeper(ctrl *gomock.Controller) *MockBankKeeper { + mock := &MockBankKeeper{ctrl: ctrl} + mock.recorder = &MockBankKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockBankKeeper) EXPECT() *MockBankKeeperMockRecorder { + return m.recorder +} + +// BlockedAddr mocks base method. +func (m *MockBankKeeper) BlockedAddr(addr types.AccAddress) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "BlockedAddr", addr) + ret0, _ := ret[0].(bool) + return ret0 +} + +// BlockedAddr indicates an expected call of BlockedAddr. +func (mr *MockBankKeeperMockRecorder) BlockedAddr(addr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlockedAddr", reflect.TypeOf((*MockBankKeeper)(nil).BlockedAddr), addr) +} + +// IsSendEnabledCoins mocks base method. +func (m *MockBankKeeper) IsSendEnabledCoins(ctx types.Context, coins ...types.Coin) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range coins { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "IsSendEnabledCoins", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// IsSendEnabledCoins indicates an expected call of IsSendEnabledCoins. +func (mr *MockBankKeeperMockRecorder) IsSendEnabledCoins(ctx interface{}, coins ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, coins...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsSendEnabledCoins", reflect.TypeOf((*MockBankKeeper)(nil).IsSendEnabledCoins), varargs...) +} + +// SendCoins mocks base method. +func (m *MockBankKeeper) SendCoins(ctx types.Context, fromAddr, toAddr types.AccAddress, amt types.Coins) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendCoins", ctx, fromAddr, toAddr, amt) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendCoins indicates an expected call of SendCoins. +func (mr *MockBankKeeperMockRecorder) SendCoins(ctx, fromAddr, toAddr, amt interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoins", reflect.TypeOf((*MockBankKeeper)(nil).SendCoins), ctx, fromAddr, toAddr, amt) +} diff --git a/x/vesting/types/tx.pb.go b/x/vesting/types/tx.pb.go index e865f78e..7ac020d9 100644 --- a/x/vesting/types/tx.pb.go +++ b/x/vesting/types/tx.pb.go @@ -6,12 +6,13 @@ package types import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/msgservice" _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/gogo/protobuf/grpc" - proto "github.com/gogo/protobuf/proto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -494,47 +495,47 @@ func init() { func init() { proto.RegisterFile("vesting/v1beta1/tx.proto", fileDescriptor_c66d8e2aee35e411) } var fileDescriptor_c66d8e2aee35e411 = []byte{ - // 630 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x55, 0xbf, 0x6f, 0xd3, 0x40, - 0x14, 0xce, 0x25, 0x21, 0x6d, 0xae, 0x08, 0x84, 0x69, 0x15, 0x27, 0x6a, 0xec, 0xd4, 0xe2, 0x87, - 0x41, 0xaa, 0xdd, 0x96, 0x22, 0xa1, 0x2c, 0xa8, 0x89, 0xc4, 0x44, 0x25, 0x64, 0x21, 0x06, 0x96, - 0xc8, 0xb1, 0x2f, 0xc6, 0x4a, 0xec, 0x8b, 0x7c, 0xd7, 0xaa, 0x19, 0x61, 0x44, 0x0c, 0x4c, 0xb0, - 0x32, 0x33, 0xf1, 0x67, 0x74, 0xec, 0xc8, 0x14, 0x20, 0x19, 0x60, 0xee, 0x1f, 0x80, 0x90, 0xef, - 0xec, 0xd0, 0x24, 0x8e, 0x4b, 0x25, 0xc4, 0xc0, 0x12, 0x3b, 0xef, 0xfb, 0xde, 0xbb, 0xf7, 0x3e, - 0x7f, 0xcf, 0x86, 0xe2, 0x21, 0x22, 0xd4, 0xf5, 0x1d, 0xfd, 0x70, 0xbb, 0x8d, 0xa8, 0xb9, 0xad, - 0xd3, 0x23, 0xad, 0x1f, 0x60, 0x8a, 0x85, 0xab, 0x11, 0xa2, 0x45, 0x48, 0x45, 0xb2, 0x30, 0xf1, - 0x30, 0xd1, 0xdb, 0x26, 0x41, 0x13, 0xba, 0x85, 0x5d, 0x9f, 0x27, 0x54, 0x4a, 0x11, 0xee, 0x91, - 0xb0, 0x5a, 0x78, 0x89, 0x80, 0x55, 0x07, 0x3b, 0x98, 0xdd, 0xea, 0xe1, 0x5d, 0x14, 0xad, 0xce, - 0x9e, 0x1c, 0x9f, 0xc7, 0x60, 0xe5, 0x4d, 0x16, 0x96, 0xf6, 0x89, 0xd3, 0x0c, 0x90, 0x49, 0xd1, - 0x33, 0x0e, 0xed, 0x59, 0x16, 0x3e, 0xf0, 0xa9, 0xb0, 0x01, 0x2f, 0x77, 0x02, 0xec, 0xb5, 0x4c, - 0xdb, 0x0e, 0x10, 0x21, 0x22, 0xa8, 0x01, 0xb5, 0x68, 0xac, 0x84, 0xb1, 0x3d, 0x1e, 0x12, 0xaa, - 0x10, 0x52, 0x3c, 0x21, 0x64, 0x19, 0xa1, 0x48, 0x71, 0x0c, 0x5b, 0xb0, 0x60, 0x7a, 0x61, 0x2d, - 0x31, 0x57, 0xcb, 0xa9, 0x2b, 0x3b, 0x65, 0x8d, 0x37, 0xaf, 0x85, 0xc3, 0xc5, 0x13, 0x6b, 0x4d, - 0xec, 0xfa, 0x8d, 0xad, 0xe3, 0xa1, 0x9c, 0xf9, 0xf8, 0x45, 0x56, 0x1d, 0x97, 0xbe, 0x38, 0x68, - 0x6b, 0x16, 0xf6, 0xf4, 0x68, 0x52, 0x7e, 0xd9, 0x24, 0x76, 0x57, 0xa7, 0x83, 0x3e, 0x22, 0x2c, - 0x81, 0x18, 0x51, 0x69, 0xa1, 0x0c, 0x97, 0x91, 0x6f, 0xb7, 0xa8, 0xeb, 0x21, 0x31, 0x5f, 0x03, - 0x6a, 0xce, 0x58, 0x42, 0xbe, 0xfd, 0xd4, 0xf5, 0x90, 0x20, 0xc2, 0x25, 0x1b, 0xf5, 0xcc, 0x01, - 0xb2, 0xc5, 0x42, 0x0d, 0xa8, 0xcb, 0x46, 0xfc, 0xb7, 0xbe, 0xf6, 0xe3, 0x83, 0x0c, 0x5e, 0x7d, - 0xff, 0x74, 0x77, 0x6a, 0x44, 0x65, 0x03, 0xca, 0x0b, 0xd4, 0x30, 0x10, 0xe9, 0x63, 0x9f, 0x20, - 0xe5, 0x27, 0x38, 0xc3, 0x79, 0x82, 0x02, 0xcf, 0xf4, 0x91, 0x4f, 0x1f, 0x63, 0xab, 0x8b, 0xec, - 0x58, 0xb9, 0x7a, 0x92, 0x72, 0x8d, 0xd2, 0xe9, 0x50, 0xbe, 0x3e, 0x30, 0xbd, 0x5e, 0x5d, 0x99, - 0x3a, 0x74, 0x5a, 0xd2, 0xdd, 0x79, 0x49, 0x1b, 0x6b, 0xa7, 0x43, 0xf9, 0x1a, 0xcf, 0xfc, 0x8d, - 0x29, 0xff, 0x5a, 0xe9, 0x7a, 0x3e, 0x14, 0x4d, 0xb9, 0x03, 0x6f, 0x9f, 0x33, 0xff, 0x44, 0xab, - 0x6f, 0x33, 0x5a, 0xb9, 0xd8, 0x76, 0xad, 0xbf, 0xee, 0xb2, 0x2a, 0x84, 0x84, 0x9a, 0x01, 0xe5, - 0x16, 0xc8, 0x31, 0x0b, 0x14, 0x59, 0x84, 0x99, 0xe0, 0x11, 0x8c, 0x77, 0xac, 0xd5, 0x67, 0x2d, - 0x10, 0x31, 0xcf, 0x34, 0x2a, 0x69, 0x33, 0xbb, 0xa7, 0xf1, 0x16, 0x1b, 0xf9, 0x50, 0x21, 0xe3, - 0x4a, 0x84, 0xf2, 0x20, 0x61, 0x96, 0xc9, 0xcc, 0x5b, 0x66, 0x46, 0x8e, 0x84, 0x11, 0x27, 0x72, - 0xbc, 0xcb, 0xc2, 0xf5, 0x09, 0xb7, 0xd9, 0x73, 0x3b, 0x9d, 0xff, 0x6e, 0xe3, 0xaa, 0x10, 0x5a, - 0xe1, 0x60, 0x1c, 0xbc, 0xc4, 0x9f, 0x05, 0x8b, 0x84, 0xf0, 0xa2, 0xb5, 0xbb, 0x05, 0x6f, 0xa4, - 0xe9, 0x12, 0x0b, 0xb8, 0xf3, 0x3e, 0x0f, 0x73, 0xfb, 0xc4, 0x11, 0x02, 0xb8, 0x9a, 0xf8, 0xc6, - 0x52, 0xe7, 0x9e, 0xe8, 0x82, 0x6d, 0xae, 0x6c, 0xfd, 0x29, 0x33, 0x3e, 0x5b, 0x78, 0x0d, 0xe0, - 0x7a, 0xea, 0xd2, 0xa7, 0x94, 0x4c, 0xce, 0xa8, 0x3c, 0xb8, 0x68, 0x46, 0x72, 0x33, 0x49, 0x5b, - 0x95, 0xde, 0x4c, 0x42, 0xc6, 0x39, 0xcd, 0xa4, 0xd8, 0x5a, 0x78, 0x09, 0x60, 0x79, 0xb1, 0xa7, - 0x37, 0x17, 0xd7, 0x4d, 0xa0, 0x57, 0xee, 0x5f, 0x88, 0x1e, 0xf7, 0xd0, 0x78, 0x78, 0x3c, 0x92, - 0xc0, 0xc9, 0x48, 0x02, 0x5f, 0x47, 0x12, 0x78, 0x3b, 0x96, 0x32, 0x27, 0x63, 0x29, 0xf3, 0x79, - 0x2c, 0x65, 0x9e, 0xdf, 0x3c, 0x63, 0x6f, 0xdc, 0xed, 0xef, 0xb2, 0x1f, 0x5b, 0x3f, 0x8a, 0x3f, - 0x84, 0xdc, 0xe1, 0xed, 0x02, 0xfb, 0x1e, 0xde, 0xfb, 0x15, 0x00, 0x00, 0xff, 0xff, 0xcf, 0x75, - 0xd6, 0xe9, 0xaa, 0x07, 0x00, 0x00, + // 635 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x55, 0x3d, 0x6f, 0xd3, 0x40, + 0x18, 0xce, 0x25, 0x21, 0x6d, 0xae, 0x08, 0x84, 0x69, 0x15, 0x27, 0x6a, 0xec, 0xd4, 0xe2, 0xc3, + 0x20, 0xd5, 0x6e, 0x4b, 0x91, 0x50, 0x16, 0xd4, 0x44, 0x62, 0xa2, 0x12, 0xb2, 0x10, 0x03, 0x4b, + 0xe4, 0xd8, 0x17, 0x63, 0x25, 0xf6, 0x45, 0xbe, 0x6b, 0xd5, 0x8c, 0x30, 0x22, 0x06, 0x26, 0x58, + 0x99, 0x99, 0xf8, 0x19, 0x1d, 0x3b, 0x32, 0x05, 0x48, 0x06, 0x98, 0xfb, 0x03, 0x10, 0xf2, 0x9d, + 0x1d, 0x9a, 0xc4, 0x71, 0xa9, 0x84, 0x18, 0x58, 0x62, 0xfb, 0x7d, 0xde, 0xcf, 0xe7, 0x9e, 0x37, + 0x07, 0xc5, 0x43, 0x44, 0xa8, 0xeb, 0x3b, 0xfa, 0xe1, 0x76, 0x1b, 0x51, 0x73, 0x5b, 0xa7, 0x47, + 0x5a, 0x3f, 0xc0, 0x14, 0x0b, 0x57, 0x23, 0x44, 0x8b, 0x90, 0x8a, 0x64, 0x61, 0xe2, 0x61, 0xa2, + 0xb7, 0x4d, 0x82, 0x26, 0xee, 0x16, 0x76, 0x7d, 0x1e, 0x50, 0x29, 0x45, 0xb8, 0x47, 0xc2, 0x6c, + 0xe1, 0x23, 0x02, 0x56, 0x1d, 0xec, 0x60, 0xf6, 0xaa, 0x87, 0x6f, 0x91, 0xb5, 0x3a, 0x5b, 0x39, + 0xae, 0xc7, 0xe1, 0x32, 0xcf, 0xd6, 0xe2, 0x71, 0xfc, 0x83, 0x43, 0xca, 0x9b, 0x2c, 0x2c, 0xed, + 0x13, 0xa7, 0x19, 0x20, 0x93, 0xa2, 0x67, 0x3c, 0x6a, 0xcf, 0xb2, 0xf0, 0x81, 0x4f, 0x85, 0x0d, + 0x78, 0xb9, 0x13, 0x60, 0xaf, 0x65, 0xda, 0x76, 0x80, 0x08, 0x11, 0x41, 0x0d, 0xa8, 0x45, 0x63, + 0x25, 0xb4, 0xed, 0x71, 0x93, 0x50, 0x85, 0x90, 0xe2, 0x89, 0x43, 0x96, 0x39, 0x14, 0x29, 0x8e, + 0x61, 0x0b, 0x16, 0x4c, 0x2f, 0xcc, 0x25, 0xe6, 0x6a, 0x39, 0x75, 0x65, 0xa7, 0xac, 0x45, 0xc5, + 0xc3, 0xb9, 0x63, 0x32, 0xb4, 0x26, 0x76, 0xfd, 0xc6, 0xd6, 0xf1, 0x50, 0xce, 0x7c, 0xfc, 0x22, + 0xab, 0x8e, 0x4b, 0x5f, 0x1c, 0xb4, 0x35, 0x0b, 0x7b, 0x51, 0xa7, 0xd1, 0x63, 0x93, 0xd8, 0x5d, + 0x9d, 0x0e, 0xfa, 0x88, 0xb0, 0x00, 0x62, 0x44, 0xa9, 0x85, 0x32, 0x5c, 0x46, 0xbe, 0xdd, 0xa2, + 0xae, 0x87, 0xc4, 0x7c, 0x0d, 0xa8, 0x39, 0x63, 0x09, 0xf9, 0xf6, 0x53, 0xd7, 0x43, 0x82, 0x08, + 0x97, 0x6c, 0xd4, 0x33, 0x07, 0xc8, 0x16, 0x0b, 0x35, 0xa0, 0x2e, 0x1b, 0xf1, 0x67, 0x7d, 0xed, + 0xc7, 0x07, 0x19, 0xbc, 0xfa, 0xfe, 0xe9, 0xee, 0xd4, 0x88, 0xca, 0x06, 0x94, 0x17, 0xb0, 0x61, + 0x20, 0xd2, 0xc7, 0x3e, 0x41, 0xca, 0x4f, 0x70, 0xc6, 0xe7, 0x09, 0x0a, 0x3c, 0xd3, 0x47, 0x3e, + 0x7d, 0x8c, 0xad, 0x2e, 0xb2, 0x63, 0xe6, 0xea, 0x49, 0xcc, 0x35, 0x4a, 0xa7, 0x43, 0xf9, 0xfa, + 0xc0, 0xf4, 0x7a, 0x75, 0x65, 0xaa, 0xe8, 0x34, 0xa5, 0xbb, 0xf3, 0x94, 0x36, 0xd6, 0x4e, 0x87, + 0xf2, 0x35, 0x1e, 0xf9, 0x1b, 0x53, 0xfe, 0x35, 0xd3, 0xf5, 0x7c, 0x48, 0x9a, 0x72, 0x07, 0xde, + 0x3e, 0x67, 0xfe, 0x09, 0x57, 0xdf, 0x66, 0xb8, 0x72, 0xb1, 0xed, 0x5a, 0x7f, 0x5d, 0x65, 0x55, + 0x08, 0x09, 0x35, 0x03, 0xca, 0x25, 0x90, 0x63, 0x12, 0x28, 0x32, 0x0b, 0x13, 0xc1, 0x23, 0x18, + 0xaf, 0x5f, 0xab, 0xcf, 0x5a, 0x20, 0x62, 0x9e, 0x71, 0x54, 0xd2, 0x66, 0xd6, 0x52, 0xe3, 0x2d, + 0x36, 0xf2, 0x21, 0x43, 0xc6, 0x95, 0x08, 0xe5, 0x46, 0xc2, 0x24, 0x93, 0x99, 0x97, 0xcc, 0x0c, + 0x1d, 0x09, 0x23, 0x4e, 0xe8, 0x78, 0x97, 0x85, 0xeb, 0x13, 0xdf, 0x66, 0xcf, 0xed, 0x74, 0xfe, + 0xbb, 0x8d, 0xab, 0x42, 0x68, 0x85, 0x83, 0x71, 0xf0, 0x12, 0x3f, 0x0b, 0x66, 0x09, 0xe1, 0x45, + 0x6b, 0x77, 0x0b, 0xde, 0x48, 0xe3, 0x25, 0x26, 0x70, 0xe7, 0x7d, 0x1e, 0xe6, 0xf6, 0x89, 0x23, + 0x04, 0x70, 0x35, 0xf1, 0x1f, 0x4b, 0x9d, 0x3b, 0xd1, 0x05, 0xdb, 0x5c, 0xd9, 0xfa, 0x53, 0xcf, + 0xb8, 0xb6, 0xf0, 0x1a, 0xc0, 0xf5, 0xd4, 0xa5, 0x4f, 0x49, 0x99, 0x1c, 0x51, 0x79, 0x70, 0xd1, + 0x88, 0xe4, 0x66, 0x92, 0xb6, 0x2a, 0xbd, 0x99, 0x84, 0x88, 0x73, 0x9a, 0x49, 0x91, 0xb5, 0xf0, + 0x12, 0xc0, 0xf2, 0x62, 0x4d, 0x6f, 0x2e, 0xce, 0x9b, 0xe0, 0x5e, 0xb9, 0x7f, 0x21, 0xf7, 0xb8, + 0x87, 0xc6, 0xc3, 0xe3, 0x91, 0x04, 0x4e, 0x46, 0x12, 0xf8, 0x3a, 0x92, 0xc0, 0xdb, 0xb1, 0x94, + 0x39, 0x19, 0x4b, 0x99, 0xcf, 0x63, 0x29, 0xf3, 0xfc, 0xe6, 0x19, 0x79, 0xe3, 0x6e, 0x7f, 0x97, + 0xfd, 0xd8, 0xfa, 0x51, 0x7c, 0x47, 0x72, 0x85, 0xb7, 0x0b, 0xec, 0x3e, 0xbc, 0xf7, 0x2b, 0x00, + 0x00, 0xff, 0xff, 0x04, 0xca, 0x3e, 0x7e, 0xc5, 0x07, 0x00, 0x00, } func (this *MsgCreateVestingAccount) Equal(that interface{}) bool { diff --git a/x/vesting/types/vesting.pb.go b/x/vesting/types/vesting.pb.go index 693b3e3f..e7b78c00 100644 --- a/x/vesting/types/vesting.pb.go +++ b/x/vesting/types/vesting.pb.go @@ -5,11 +5,12 @@ package types import ( fmt "fmt" + _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types1 "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/x/auth/types" _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/gogo/protobuf/proto" + proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" @@ -335,43 +336,43 @@ func init() { func init() { proto.RegisterFile("vesting/v1beta1/vesting.proto", fileDescriptor_eac461ec52018387) } var fileDescriptor_eac461ec52018387 = []byte{ - // 565 bytes of a gzipped FileDescriptorProto + // 571 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0x31, 0x6f, 0xd3, 0x40, - 0x14, 0xf6, 0xd5, 0x21, 0x94, 0x2b, 0xb4, 0xc5, 0x94, 0x92, 0x22, 0xd5, 0x89, 0x8a, 0x90, 0xb2, - 0x60, 0xd3, 0xc2, 0xd4, 0x05, 0x91, 0xa0, 0x4a, 0x48, 0x0c, 0x28, 0x42, 0x0c, 0x30, 0x44, 0x67, - 0xfb, 0xc5, 0x39, 0x25, 0xbe, 0x8b, 0x7c, 0x97, 0xa8, 0x5d, 0x60, 0x45, 0x62, 0x61, 0x64, 0xcc, - 0xcc, 0x4f, 0xe0, 0x17, 0x74, 0xcc, 0xc8, 0x54, 0x50, 0x22, 0x31, 0xf0, 0x2b, 0x90, 0xef, 0xce, - 0x6e, 0x48, 0xd6, 0x52, 0x75, 0xb1, 0xef, 0xbd, 0xe7, 0xf7, 0xbe, 0xef, 0xbb, 0xf7, 0xce, 0x87, - 0x77, 0x47, 0x20, 0x24, 0x65, 0xb1, 0x3f, 0xda, 0x0f, 0x40, 0x92, 0x7d, 0xdf, 0xd8, 0xde, 0x20, - 0xe5, 0x92, 0x3b, 0x1b, 0xb9, 0x69, 0xc2, 0xf7, 0xdd, 0x90, 0x8b, 0x84, 0x0b, 0x9f, 0x0c, 0x65, - 0xb7, 0xc8, 0xc9, 0x0c, 0x9d, 0x50, 0xc4, 0x03, 0x22, 0xa0, 0x88, 0x87, 0x9c, 0x32, 0x13, 0xdf, - 0x8a, 0x79, 0xcc, 0xd5, 0xd2, 0xcf, 0x56, 0xda, 0xbb, 0xf7, 0xc7, 0xc6, 0x4e, 0x83, 0x08, 0x78, - 0xab, 0xd1, 0x9e, 0x87, 0x21, 0x1f, 0x32, 0xe9, 0xbc, 0xc4, 0x37, 0xb3, 0x3a, 0x6d, 0xa2, 0xed, - 0x0a, 0xaa, 0xa1, 0xfa, 0xda, 0x41, 0xcd, 0xd3, 0x18, 0x9e, 0x82, 0x35, 0x18, 0x5e, 0x96, 0x6e, - 0xf2, 0x1a, 0xa5, 0xc9, 0x59, 0x15, 0xb5, 0xd6, 0x82, 0x73, 0x97, 0x33, 0xc2, 0x9b, 0x3c, 0xa5, - 0x31, 0x65, 0xa4, 0xdf, 0x36, 0x9a, 0x2a, 0x2b, 0x35, 0xbb, 0xbe, 0x76, 0xb0, 0x93, 0x97, 0xcb, - 0x3e, 0x2f, 0xca, 0x35, 0x39, 0x65, 0x8d, 0xc7, 0xa7, 0x67, 0x55, 0xeb, 0xdb, 0xcf, 0x6a, 0x3d, - 0xa6, 0xb2, 0x3b, 0x0c, 0xbc, 0x90, 0x27, 0xbe, 0xd1, 0xa7, 0x5f, 0x8f, 0x44, 0xd4, 0xf3, 0xe5, - 0xc9, 0x00, 0x84, 0x4a, 0x10, 0xad, 0x8d, 0x1c, 0xc4, 0x28, 0x71, 0x52, 0xbc, 0x1e, 0x41, 0x1f, - 0x62, 0x22, 0x21, 0x6a, 0x77, 0x52, 0x80, 0x8a, 0x7d, 0xf1, 0xa8, 0xb7, 0x0a, 0x88, 0xa3, 0x14, - 0xc0, 0x39, 0xc6, 0xb7, 0xcf, 0x31, 0x73, 0xb1, 0xa5, 0x8b, 0x87, 0xdd, 0x2c, 0x50, 0x72, 0xb5, - 0x3b, 0x78, 0x15, 0x58, 0xd4, 0x96, 0x34, 0x81, 0xca, 0xb5, 0x1a, 0xaa, 0xdb, 0xad, 0xeb, 0xc0, - 0xa2, 0x37, 0x34, 0x81, 0xc3, 0xd5, 0x4f, 0xe3, 0xaa, 0xf5, 0x75, 0x5c, 0xb5, 0xf6, 0xc6, 0x08, - 0x57, 0x9a, 0x9c, 0x49, 0xca, 0x86, 0x7c, 0x28, 0x16, 0x5a, 0xfe, 0x1e, 0x6f, 0xa9, 0x96, 0x1b, - 0xda, 0x0b, 0xad, 0x7f, 0xe0, 0x2d, 0xcc, 0xa3, 0xb7, 0x3c, 0x35, 0xa6, 0xfb, 0x4e, 0xb0, 0x3c, - 0x4f, 0xbb, 0x18, 0x0b, 0x49, 0x52, 0xa9, 0x09, 0xae, 0x28, 0x82, 0x37, 0x94, 0x67, 0x81, 0xe2, - 0x07, 0x7c, 0xf7, 0x05, 0xf4, 0xc9, 0x49, 0xa1, 0xec, 0x32, 0xe8, 0xcd, 0xe1, 0x7f, 0x46, 0xb8, - 0xfc, 0x1a, 0x52, 0xca, 0x23, 0x67, 0x1b, 0x97, 0xfb, 0xc0, 0x62, 0xd9, 0x55, 0x18, 0x76, 0xcb, - 0x58, 0x4e, 0x88, 0xcb, 0x24, 0x51, 0xd8, 0xff, 0x61, 0x8c, 0x4d, 0xe9, 0xc3, 0x92, 0x62, 0xf3, - 0x1b, 0xe1, 0x6d, 0xcd, 0x86, 0x86, 0x57, 0xa7, 0x5d, 0xce, 0x11, 0xce, 0xff, 0x4e, 0xed, 0x81, - 0x62, 0x27, 0xcc, 0xd9, 0xba, 0xb7, 0x04, 0xab, 0xd9, 0x37, 0x4a, 0xd9, 0x46, 0xb4, 0xd6, 0x4d, - 0x54, 0x3b, 0xc5, 0xdc, 0xb6, 0x7f, 0x54, 0x3a, 0x13, 0xc2, 0x80, 0xc9, 0x57, 0x3c, 0xec, 0x41, - 0x74, 0xc9, 0x7d, 0xff, 0x8e, 0xf0, 0x9d, 0x66, 0x9f, 0x76, 0x3a, 0x57, 0x68, 0x9b, 0x77, 0x31, - 0x0e, 0x33, 0x4a, 0x3a, 0x6c, 0xeb, 0xb0, 0xf2, 0xfc, 0x7b, 0x68, 0x1a, 0xcf, 0x4e, 0xa7, 0x2e, - 0x9a, 0x4c, 0x5d, 0xf4, 0x6b, 0xea, 0xa2, 0x2f, 0x33, 0xd7, 0x9a, 0xcc, 0x5c, 0xeb, 0xc7, 0xcc, - 0xb5, 0xde, 0x3d, 0x9c, 0x1b, 0x3c, 0xde, 0x1b, 0x3c, 0x55, 0x8f, 0xc8, 0x3f, 0xce, 0x2f, 0x1b, - 0x3d, 0x7b, 0x41, 0x59, 0x5d, 0x06, 0x4f, 0xfe, 0x06, 0x00, 0x00, 0xff, 0xff, 0x2e, 0xa6, 0x40, - 0xda, 0x94, 0x06, 0x00, 0x00, + 0x14, 0xb6, 0xeb, 0x10, 0xca, 0x15, 0xda, 0x62, 0x4a, 0x49, 0x90, 0xe2, 0x44, 0x45, 0x48, 0x59, + 0xb0, 0x69, 0x61, 0xea, 0x82, 0x48, 0x50, 0x25, 0x24, 0x06, 0x14, 0x21, 0x06, 0x18, 0xac, 0xb3, + 0xfd, 0xe2, 0x9c, 0x12, 0xdf, 0x45, 0xbe, 0x4b, 0xd4, 0x2e, 0xb0, 0x22, 0xb1, 0x30, 0x32, 0x66, + 0xe6, 0x27, 0xf0, 0x0b, 0x3a, 0x66, 0x64, 0x2a, 0x28, 0x91, 0x18, 0xf8, 0x15, 0xc8, 0x77, 0x67, + 0x37, 0x24, 0x6b, 0xa9, 0xba, 0x24, 0xf7, 0xde, 0x97, 0xef, 0xbe, 0xef, 0xdd, 0x7b, 0x97, 0x43, + 0xb5, 0x31, 0x70, 0x41, 0x68, 0xec, 0x8d, 0xf7, 0x03, 0x10, 0x78, 0xdf, 0xd3, 0xb1, 0x3b, 0x4c, + 0x99, 0x60, 0xf6, 0x56, 0x1e, 0x6a, 0xf8, 0xbe, 0x13, 0x32, 0x9e, 0x30, 0xee, 0xe1, 0x91, 0xe8, + 0x15, 0x9c, 0x2c, 0x50, 0x84, 0x02, 0x0f, 0x30, 0x87, 0x02, 0x0f, 0x19, 0xa1, 0x1a, 0xdf, 0x89, + 0x59, 0xcc, 0xe4, 0xd2, 0xcb, 0x56, 0x3a, 0x5b, 0x55, 0x2c, 0x5f, 0x01, 0x2a, 0x50, 0xd0, 0xde, + 0x1f, 0x0b, 0xd9, 0x2d, 0xcc, 0xe1, 0xad, 0x32, 0xf2, 0x3c, 0x0c, 0xd9, 0x88, 0x0a, 0xfb, 0x25, + 0xba, 0x99, 0x49, 0xf8, 0x58, 0xc5, 0x15, 0xb3, 0x61, 0x36, 0x37, 0x0e, 0x1a, 0xae, 0xe6, 0x4a, + 0x47, 0x5a, 0xde, 0xcd, 0xe8, 0x9a, 0xd7, 0x2a, 0x4d, 0xcf, 0xea, 0x66, 0x67, 0x23, 0x38, 0x4f, + 0xd9, 0x63, 0xb4, 0xcd, 0x52, 0x12, 0x13, 0x8a, 0x07, 0xbe, 0x2e, 0xb7, 0xb2, 0xd6, 0xb0, 0x9a, + 0x1b, 0x07, 0xd5, 0x7c, 0xbb, 0xec, 0xe7, 0xc5, 0x76, 0x6d, 0x46, 0x68, 0xeb, 0xf1, 0xe9, 0x59, + 0xdd, 0xf8, 0xf6, 0xb3, 0xde, 0x8c, 0x89, 0xe8, 0x8d, 0x02, 0x37, 0x64, 0x89, 0xf6, 0xad, 0xbf, + 0x1e, 0xf1, 0xa8, 0xef, 0x89, 0x93, 0x21, 0x70, 0x49, 0xe0, 0x9d, 0xad, 0x5c, 0x44, 0x57, 0x62, + 0xa7, 0x68, 0x33, 0x82, 0x01, 0xc4, 0x58, 0x40, 0xe4, 0x77, 0x53, 0x80, 0x8a, 0x75, 0xf1, 0xaa, + 0xb7, 0x0a, 0x89, 0xa3, 0x14, 0xc0, 0x3e, 0x46, 0xb7, 0xcf, 0x35, 0xf3, 0x62, 0x4b, 0x17, 0x2f, + 0xbb, 0x5d, 0xa8, 0xe4, 0xd5, 0x56, 0xd1, 0x3a, 0xd0, 0xc8, 0x17, 0x24, 0x81, 0xca, 0xb5, 0x86, + 0xd9, 0xb4, 0x3a, 0xd7, 0x81, 0x46, 0x6f, 0x48, 0x02, 0x87, 0xeb, 0x9f, 0x26, 0x75, 0xe3, 0xeb, + 0xa4, 0x6e, 0xec, 0x4d, 0x4c, 0x54, 0x69, 0x33, 0x2a, 0x08, 0x1d, 0xb1, 0x11, 0x5f, 0x6a, 0xf9, + 0x7b, 0xb4, 0x23, 0x5b, 0xae, 0x6d, 0x2f, 0xb5, 0xfe, 0x81, 0xbb, 0x34, 0xaa, 0xee, 0xea, 0xd4, + 0xe8, 0xee, 0xdb, 0xc1, 0xea, 0x3c, 0xd5, 0x10, 0xe2, 0x02, 0xa7, 0x42, 0x19, 0x5c, 0x93, 0x06, + 0x6f, 0xc8, 0xcc, 0x92, 0xc5, 0x0f, 0xe8, 0xee, 0x0b, 0x18, 0xe0, 0x93, 0xa2, 0xb2, 0xcb, 0xb0, + 0xb7, 0xa0, 0xff, 0xd9, 0x44, 0xe5, 0xd7, 0x90, 0x12, 0x16, 0xd9, 0xbb, 0xa8, 0x3c, 0x00, 0x1a, + 0x8b, 0x9e, 0xd4, 0xb0, 0x3a, 0x3a, 0xb2, 0x43, 0x54, 0xc6, 0x89, 0xd4, 0xfe, 0x0f, 0x63, 0xac, + 0xb7, 0x3e, 0x2c, 0x49, 0x37, 0xbf, 0x4d, 0xb4, 0xab, 0xdc, 0x90, 0xf0, 0xea, 0xb4, 0xcb, 0x3e, + 0x42, 0xf9, 0x1f, 0x97, 0x3f, 0x94, 0xee, 0xb8, 0xbe, 0x5b, 0xf7, 0x56, 0x64, 0x95, 0xfb, 0x56, + 0x29, 0x3b, 0x88, 0xce, 0xa6, 0x46, 0x55, 0x92, 0x2f, 0x1c, 0xfb, 0x47, 0x59, 0x67, 0x82, 0x29, + 0x50, 0xf1, 0x8a, 0x85, 0x7d, 0x88, 0x2e, 0xb9, 0xef, 0xdf, 0x4d, 0x74, 0xa7, 0x3d, 0x20, 0xdd, + 0xee, 0x15, 0x3a, 0xe6, 0x1a, 0x42, 0x61, 0x66, 0x49, 0xc1, 0x96, 0x82, 0x65, 0xe6, 0xdf, 0x4b, + 0xd3, 0x7a, 0x76, 0x3a, 0x73, 0xcc, 0xe9, 0xcc, 0x31, 0x7f, 0xcd, 0x1c, 0xf3, 0xcb, 0xdc, 0x31, + 0xa6, 0x73, 0xc7, 0xf8, 0x31, 0x77, 0x8c, 0x77, 0x0f, 0x17, 0x06, 0x8f, 0xf5, 0x87, 0x4f, 0xe5, + 0x47, 0xe4, 0x1d, 0xe7, 0xef, 0x90, 0x9a, 0xbd, 0xa0, 0x2c, 0x1f, 0x83, 0x27, 0x7f, 0x03, 0x00, + 0x00, 0xff, 0xff, 0x26, 0x3c, 0x56, 0xde, 0xaf, 0x06, 0x00, 0x00, } func (m *BaseVestingAccount) Marshal() (dAtA []byte, err error) { diff --git a/x/vesting/types/vesting_account_test.go b/x/vesting/types/vesting_account_test.go index 2e6e9492..ef603243 100644 --- a/x/vesting/types/vesting_account_test.go +++ b/x/vesting/types/vesting_account_test.go @@ -1,848 +1,874 @@ package types_test -import ( - "testing" - "time" - - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - tmtime "github.com/tendermint/tendermint/types/time" - - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" - "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/testutil/testdata" - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/okp4/okp4d/x/vesting/types" -) - -var ( - stakeDenom = "stake" - feeDenom = "fee" -) - -type VestingAccountTestSuite struct { - suite.Suite - - app *simapp.SimApp - ctx sdk.Context -} - -func (s *VestingAccountTestSuite) SetupTest() { - checkTx := false - s.app = simapp.Setup(s.T(), checkTx) - - s.ctx = s.app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1}) -} - -func TestGetVestedCoinsContVestingAcc(t *testing.T) { - now := tmtime.Now() - endTime := now.Add(24 * time.Hour) - - bacc, origCoins := initBaseAccount() - cva := types.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) - - // require no coins vested in the very beginning of the vesting schedule - vestedCoins := cva.GetVestedCoins(now) - require.Nil(t, vestedCoins) - - // require all coins vested at the end of the vesting schedule - vestedCoins = cva.GetVestedCoins(endTime) - require.Equal(t, origCoins, vestedCoins) - - // require 50% of coins vested - vestedCoins = cva.GetVestedCoins(now.Add(12 * time.Hour)) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}, vestedCoins) - - // require 100% of coins vested - vestedCoins = cva.GetVestedCoins(now.Add(48 * time.Hour)) - require.Equal(t, origCoins, vestedCoins) -} - -func TestGetVestingCoinsContVestingAcc(t *testing.T) { - now := tmtime.Now() - endTime := now.Add(24 * time.Hour) - - bacc, origCoins := initBaseAccount() - cva := types.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) - - // require all coins vesting in the beginning of the vesting schedule - vestingCoins := cva.GetVestingCoins(now) - require.Equal(t, origCoins, vestingCoins) - - // require no coins vesting at the end of the vesting schedule - vestingCoins = cva.GetVestingCoins(endTime) - require.Nil(t, vestingCoins) - - // require 50% of coins vesting - vestingCoins = cva.GetVestingCoins(now.Add(12 * time.Hour)) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}, vestingCoins) -} - -func TestSpendableCoinsContVestingAcc(t *testing.T) { - now := tmtime.Now() - endTime := now.Add(24 * time.Hour) - - bacc, origCoins := initBaseAccount() - cva := types.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) - - // require that all original coins are locked at the end of the vesting - // schedule - lockedCoins := cva.LockedCoins(now) - require.Equal(t, origCoins, lockedCoins) - - // require that there exist no locked coins at the end of the vesting - lockedCoins = cva.LockedCoins(endTime) - require.Equal(t, sdk.NewCoins(), lockedCoins) - - // require that all vested coins (50%) are spendable - lockedCoins = cva.LockedCoins(now.Add(12 * time.Hour)) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}, lockedCoins) -} - -func TestTrackDelegationContVestingAcc(t *testing.T) { - now := tmtime.Now() - endTime := now.Add(24 * time.Hour) - - bacc, origCoins := initBaseAccount() - - // require the ability to delegate all vesting coins - cva := types.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) - cva.TrackDelegation(now, origCoins, origCoins) - require.Equal(t, origCoins, cva.DelegatedVesting) - require.Nil(t, cva.DelegatedFree) - - // require the ability to delegate all vested coins - cva = types.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) - cva.TrackDelegation(endTime, origCoins, origCoins) - require.Nil(t, cva.DelegatedVesting) - require.Equal(t, origCoins, cva.DelegatedFree) - - // require the ability to delegate all vesting coins (50%) and all vested coins (50%) - cva = types.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) - cva.TrackDelegation(now.Add(12*time.Hour), origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}, cva.DelegatedVesting) - require.Nil(t, cva.DelegatedFree) - - cva.TrackDelegation(now.Add(12*time.Hour), origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}, cva.DelegatedVesting) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}, cva.DelegatedFree) - - // require no modifications when delegation amount is zero or not enough funds - cva = types.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) - require.Panics(t, func() { - cva.TrackDelegation(endTime, origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 1000000)}) - }) - require.Nil(t, cva.DelegatedVesting) - require.Nil(t, cva.DelegatedFree) -} - -func TestTrackUndelegationContVestingAcc(t *testing.T) { - now := tmtime.Now() - endTime := now.Add(24 * time.Hour) - - bacc, origCoins := initBaseAccount() - - // require the ability to undelegate all vesting coins - cva := types.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) - cva.TrackDelegation(now, origCoins, origCoins) - cva.TrackUndelegation(origCoins) - require.Nil(t, cva.DelegatedFree) - require.Nil(t, cva.DelegatedVesting) - - // require the ability to undelegate all vested coins - cva = types.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) - - cva.TrackDelegation(endTime, origCoins, origCoins) - cva.TrackUndelegation(origCoins) - require.Nil(t, cva.DelegatedFree) - require.Nil(t, cva.DelegatedVesting) - - // require no modifications when the undelegation amount is zero - cva = types.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) - - require.Panics(t, func() { - cva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 0)}) - }) - require.Nil(t, cva.DelegatedFree) - require.Nil(t, cva.DelegatedVesting) - - // vest 50% and delegate to two validators - cva = types.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) - cva.TrackDelegation(now.Add(12*time.Hour), origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) - cva.TrackDelegation(now.Add(12*time.Hour), origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) - - // undelegate from one validator that got slashed 50% - cva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 25)}) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 25)}, cva.DelegatedFree) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}, cva.DelegatedVesting) - - // undelegate from the other validator that did not get slashed - cva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) - require.Nil(t, cva.DelegatedFree) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 25)}, cva.DelegatedVesting) -} - -func TestGetVestedCoinsDelVestingAcc(t *testing.T) { - now := tmtime.Now() - endTime := now.Add(24 * time.Hour) - - bacc, origCoins := initBaseAccount() - - // require no coins are vested until schedule maturation - dva := types.NewDelayedVestingAccount(bacc, origCoins, endTime.Unix()) - vestedCoins := dva.GetVestedCoins(now) - require.Nil(t, vestedCoins) - - // require all coins be vested at schedule maturation - vestedCoins = dva.GetVestedCoins(endTime) - require.Equal(t, origCoins, vestedCoins) -} - -func TestGetVestingCoinsDelVestingAcc(t *testing.T) { - now := tmtime.Now() - endTime := now.Add(24 * time.Hour) - - bacc, origCoins := initBaseAccount() - - // require all coins vesting at the beginning of the schedule - dva := types.NewDelayedVestingAccount(bacc, origCoins, endTime.Unix()) - vestingCoins := dva.GetVestingCoins(now) - require.Equal(t, origCoins, vestingCoins) - - // require no coins vesting at schedule maturation - vestingCoins = dva.GetVestingCoins(endTime) - require.Nil(t, vestingCoins) -} - -func TestSpendableCoinsDelVestingAcc(t *testing.T) { - now := tmtime.Now() - endTime := now.Add(24 * time.Hour) - - bacc, origCoins := initBaseAccount() - - // require that all coins are locked in the beginning of the vesting - // schedule - dva := types.NewDelayedVestingAccount(bacc, origCoins, endTime.Unix()) - lockedCoins := dva.LockedCoins(now) - require.True(t, lockedCoins.IsEqual(origCoins)) - - // require that all coins are spendable after the maturation of the vesting - // schedule - lockedCoins = dva.LockedCoins(endTime) - require.Equal(t, sdk.NewCoins(), lockedCoins) - - // require that all coins are still vesting after some time - lockedCoins = dva.LockedCoins(now.Add(12 * time.Hour)) - require.True(t, lockedCoins.IsEqual(origCoins)) - - // delegate some locked coins - // require that locked is reduced - delegatedAmount := sdk.NewCoins(sdk.NewInt64Coin(stakeDenom, 50)) - dva.TrackDelegation(now.Add(12*time.Hour), origCoins, delegatedAmount) - lockedCoins = dva.LockedCoins(now.Add(12 * time.Hour)) - require.True(t, lockedCoins.IsEqual(origCoins.Sub(delegatedAmount...))) -} - -func TestTrackDelegationDelVestingAcc(t *testing.T) { - now := tmtime.Now() - endTime := now.Add(24 * time.Hour) - - bacc, origCoins := initBaseAccount() - - // require the ability to delegate all vesting coins - dva := types.NewDelayedVestingAccount(bacc, origCoins, endTime.Unix()) - dva.TrackDelegation(now, origCoins, origCoins) - require.Equal(t, origCoins, dva.DelegatedVesting) - require.Nil(t, dva.DelegatedFree) - - // require the ability to delegate all vested coins - dva = types.NewDelayedVestingAccount(bacc, origCoins, endTime.Unix()) - dva.TrackDelegation(endTime, origCoins, origCoins) - require.Nil(t, dva.DelegatedVesting) - require.Equal(t, origCoins, dva.DelegatedFree) - - // require the ability to delegate all coins half way through the vesting - // schedule - dva = types.NewDelayedVestingAccount(bacc, origCoins, endTime.Unix()) - dva.TrackDelegation(now.Add(12*time.Hour), origCoins, origCoins) - require.Equal(t, origCoins, dva.DelegatedVesting) - require.Nil(t, dva.DelegatedFree) - - // require no modifications when delegation amount is zero or not enough funds - dva = types.NewDelayedVestingAccount(bacc, origCoins, endTime.Unix()) - - require.Panics(t, func() { - dva.TrackDelegation(endTime, origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 1000000)}) - }) - require.Nil(t, dva.DelegatedVesting) - require.Nil(t, dva.DelegatedFree) -} - -func TestTrackUndelegationDelVestingAcc(t *testing.T) { - now := tmtime.Now() - endTime := now.Add(24 * time.Hour) - - bacc, origCoins := initBaseAccount() - - // require the ability to undelegate all vesting coins - dva := types.NewDelayedVestingAccount(bacc, origCoins, endTime.Unix()) - dva.TrackDelegation(now, origCoins, origCoins) - dva.TrackUndelegation(origCoins) - require.Nil(t, dva.DelegatedFree) - require.Nil(t, dva.DelegatedVesting) - - // require the ability to undelegate all vested coins - dva = types.NewDelayedVestingAccount(bacc, origCoins, endTime.Unix()) - dva.TrackDelegation(endTime, origCoins, origCoins) - dva.TrackUndelegation(origCoins) - require.Nil(t, dva.DelegatedFree) - require.Nil(t, dva.DelegatedVesting) - - // require no modifications when the undelegation amount is zero - dva = types.NewDelayedVestingAccount(bacc, origCoins, endTime.Unix()) - - require.Panics(t, func() { - dva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 0)}) - }) - require.Nil(t, dva.DelegatedFree) - require.Nil(t, dva.DelegatedVesting) - - // vest 50% and delegate to two validators - dva = types.NewDelayedVestingAccount(bacc, origCoins, endTime.Unix()) - dva.TrackDelegation(now.Add(12*time.Hour), origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) - dva.TrackDelegation(now.Add(12*time.Hour), origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) - - // undelegate from one validator that got slashed 50% - dva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 25)}) - - require.Nil(t, dva.DelegatedFree) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 75)}, dva.DelegatedVesting) - - // undelegate from the other validator that did not get slashed - dva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) - require.Nil(t, dva.DelegatedFree) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 25)}, dva.DelegatedVesting) -} - -func TestGetVestedCoinsPeriodicVestingAcc(t *testing.T) { - now := tmtime.Now() - endTime := now.Add(24 * time.Hour) - periods := types.Periods{ - types.Period{Length: int64(12 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}}, - types.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}}, - types.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}}, - } - - bacc, origCoins := initBaseAccount() - pva := types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) - - // require no coins vested at the beginning of the vesting schedule - vestedCoins := pva.GetVestedCoins(now) - require.Nil(t, vestedCoins) - - // require all coins vested at the end of the vesting schedule - vestedCoins = pva.GetVestedCoins(endTime) - require.Equal(t, origCoins, vestedCoins) - - // require no coins vested during first vesting period - vestedCoins = pva.GetVestedCoins(now.Add(6 * time.Hour)) - require.Nil(t, vestedCoins) - - // require 50% of coins vested after period 1 - vestedCoins = pva.GetVestedCoins(now.Add(12 * time.Hour)) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}, vestedCoins) - - // require period 2 coins don't vest until period is over - vestedCoins = pva.GetVestedCoins(now.Add(15 * time.Hour)) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}, vestedCoins) - - // require 75% of coins vested after period 2 - vestedCoins = pva.GetVestedCoins(now.Add(18 * time.Hour)) - require.Equal(t, - sdk.Coins{ - sdk.NewInt64Coin(feeDenom, 750), sdk.NewInt64Coin(stakeDenom, 75), - }, vestedCoins) - - // require 100% of coins vested - vestedCoins = pva.GetVestedCoins(now.Add(48 * time.Hour)) - require.Equal(t, origCoins, vestedCoins) -} - -func TestGetVestingCoinsPeriodicVestingAcc(t *testing.T) { - now := tmtime.Now() - endTime := now.Add(24 * time.Hour) - periods := types.Periods{ - types.Period{Length: int64(12 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}}, - types.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}}, - types.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}}, - } - - bacc, origCoins := initBaseAccount() - pva := types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) - - // require all coins vesting at the beginning of the vesting schedule - vestingCoins := pva.GetVestingCoins(now) - require.Equal(t, origCoins, vestingCoins) - - // require no coins vesting at the end of the vesting schedule - vestingCoins = pva.GetVestingCoins(endTime) - require.Nil(t, vestingCoins) - - // require 50% of coins vesting - vestingCoins = pva.GetVestingCoins(now.Add(12 * time.Hour)) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}, vestingCoins) - - // require 50% of coins vesting after period 1, but before period 2 completes. - vestingCoins = pva.GetVestingCoins(now.Add(15 * time.Hour)) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}, vestingCoins) - - // require 25% of coins vesting after period 2 - vestingCoins = pva.GetVestingCoins(now.Add(18 * time.Hour)) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}, vestingCoins) - - // require 0% of coins vesting after vesting complete - vestingCoins = pva.GetVestingCoins(now.Add(48 * time.Hour)) - require.Nil(t, vestingCoins) -} - -func TestSpendableCoinsPeriodicVestingAcc(t *testing.T) { - now := tmtime.Now() - endTime := now.Add(24 * time.Hour) - periods := types.Periods{ - types.Period{Length: int64(12 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}}, - types.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}}, - types.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}}, - } - - bacc, origCoins := initBaseAccount() - pva := types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) - - // require that there exist no spendable coins at the beginning of the - // vesting schedule - lockedCoins := pva.LockedCoins(now) - require.Equal(t, origCoins, lockedCoins) - - // require that all original coins are spendable at the end of the vesting - // schedule - lockedCoins = pva.LockedCoins(endTime) - require.Equal(t, sdk.NewCoins(), lockedCoins) - - // require that all still vesting coins (50%) are locked - lockedCoins = pva.LockedCoins(now.Add(12 * time.Hour)) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}, lockedCoins) -} - -func TestTrackDelegationPeriodicVestingAcc(t *testing.T) { - now := tmtime.Now() - endTime := now.Add(24 * time.Hour) - periods := types.Periods{ - types.Period{Length: int64(12 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}}, - types.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}}, - types.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}}, - } - - bacc, origCoins := initBaseAccount() - - // require the ability to delegate all vesting coins - pva := types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) - pva.TrackDelegation(now, origCoins, origCoins) - require.Equal(t, origCoins, pva.DelegatedVesting) - require.Nil(t, pva.DelegatedFree) - - // require the ability to delegate all vested coins - pva = types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) - pva.TrackDelegation(endTime, origCoins, origCoins) - require.Nil(t, pva.DelegatedVesting) - require.Equal(t, origCoins, pva.DelegatedFree) - - // delegate half of vesting coins - pva = types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) - pva.TrackDelegation(now, origCoins, periods[0].Amount) - // require that all delegated coins are delegated vesting - require.Equal(t, pva.DelegatedVesting, periods[0].Amount) - require.Nil(t, pva.DelegatedFree) - - // delegate 75% of coins, split between vested and vesting - pva = types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) - pva.TrackDelegation(now.Add(12*time.Hour), origCoins, periods[0].Amount.Add(periods[1].Amount...)) - // require that the maximum possible amount of vesting coins are chosen for delegation. - require.Equal(t, pva.DelegatedFree, periods[1].Amount) - require.Equal(t, pva.DelegatedVesting, periods[0].Amount) - - // require the ability to delegate all vesting coins (50%) and all vested coins (50%) - pva = types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) - pva.TrackDelegation(now.Add(12*time.Hour), origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}, pva.DelegatedVesting) - require.Nil(t, pva.DelegatedFree) - - pva.TrackDelegation(now.Add(12*time.Hour), origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}, pva.DelegatedVesting) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}, pva.DelegatedFree) - - // require no modifications when delegation amount is zero or not enough funds - pva = types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) - require.Panics(t, func() { - pva.TrackDelegation(endTime, origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 1000000)}) - }) - require.Nil(t, pva.DelegatedVesting) - require.Nil(t, pva.DelegatedFree) -} - -func TestTrackUndelegationPeriodicVestingAcc(t *testing.T) { - now := tmtime.Now() - endTime := now.Add(24 * time.Hour) - periods := types.Periods{ - types.Period{Length: int64(12 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}}, - types.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}}, - types.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}}, - } - - bacc, origCoins := initBaseAccount() - - // require the ability to undelegate all vesting coins at the beginning of vesting - pva := types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) - pva.TrackDelegation(now, origCoins, origCoins) - pva.TrackUndelegation(origCoins) - require.Nil(t, pva.DelegatedFree) - require.Nil(t, pva.DelegatedVesting) - - // require the ability to undelegate all vested coins at the end of vesting - pva = types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) - - pva.TrackDelegation(endTime, origCoins, origCoins) - pva.TrackUndelegation(origCoins) - require.Nil(t, pva.DelegatedFree) - require.Nil(t, pva.DelegatedVesting) - - // require the ability to undelegate half of coins - pva = types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) - pva.TrackDelegation(endTime, origCoins, periods[0].Amount) - pva.TrackUndelegation(periods[0].Amount) - require.Nil(t, pva.DelegatedFree) - require.Nil(t, pva.DelegatedVesting) - - // require no modifications when the undelegation amount is zero - pva = types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) - - require.Panics(t, func() { - pva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 0)}) - }) - require.Nil(t, pva.DelegatedFree) - require.Nil(t, pva.DelegatedVesting) - - // vest 50% and delegate to two validators - pva = types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) - pva.TrackDelegation(now.Add(12*time.Hour), origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) - pva.TrackDelegation(now.Add(12*time.Hour), origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) - - // undelegate from one validator that got slashed 50% - pva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 25)}) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 25)}, pva.DelegatedFree) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}, pva.DelegatedVesting) - - // undelegate from the other validator that did not get slashed - pva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) - require.Nil(t, pva.DelegatedFree) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 25)}, pva.DelegatedVesting) -} - -func TestGetVestedCoinsPermLockedVestingAcc(t *testing.T) { - now := tmtime.Now() - endTime := now.Add(1000 * 24 * time.Hour) - - bacc, origCoins := initBaseAccount() - - // require no coins are vested - plva := types.NewPermanentLockedAccount(bacc, origCoins) - vestedCoins := plva.GetVestedCoins(now) - require.Nil(t, vestedCoins) - - // require no coins be vested at end time - vestedCoins = plva.GetVestedCoins(endTime) - require.Nil(t, vestedCoins) -} - -func TestGetVestingCoinsPermLockedVestingAcc(t *testing.T) { - now := tmtime.Now() - endTime := now.Add(1000 * 24 * time.Hour) - - bacc, origCoins := initBaseAccount() - - // require all coins vesting at the beginning of the schedule - plva := types.NewPermanentLockedAccount(bacc, origCoins) - vestingCoins := plva.GetVestingCoins(now) - require.Equal(t, origCoins, vestingCoins) - - // require all coins vesting at the end time - vestingCoins = plva.GetVestingCoins(endTime) - require.Equal(t, origCoins, vestingCoins) -} - -func TestSpendableCoinsPermLockedVestingAcc(t *testing.T) { - now := tmtime.Now() - endTime := now.Add(1000 * 24 * time.Hour) - - bacc, origCoins := initBaseAccount() - - // require that all coins are locked in the beginning of the vesting - // schedule - plva := types.NewPermanentLockedAccount(bacc, origCoins) - lockedCoins := plva.LockedCoins(now) - require.True(t, lockedCoins.IsEqual(origCoins)) - - // require that all coins are still locked at end time - lockedCoins = plva.LockedCoins(endTime) - require.True(t, lockedCoins.IsEqual(origCoins)) - - // delegate some locked coins - // require that locked is reduced - delegatedAmount := sdk.NewCoins(sdk.NewInt64Coin(stakeDenom, 50)) - plva.TrackDelegation(now.Add(12*time.Hour), origCoins, delegatedAmount) - lockedCoins = plva.LockedCoins(now.Add(12 * time.Hour)) - require.True(t, lockedCoins.IsEqual(origCoins.Sub(delegatedAmount...))) -} - -func TestTrackDelegationPermLockedVestingAcc(t *testing.T) { - now := tmtime.Now() - endTime := now.Add(1000 * 24 * time.Hour) - - bacc, origCoins := initBaseAccount() - - // require the ability to delegate all vesting coins - plva := types.NewPermanentLockedAccount(bacc, origCoins) - plva.TrackDelegation(now, origCoins, origCoins) - require.Equal(t, origCoins, plva.DelegatedVesting) - require.Nil(t, plva.DelegatedFree) - - // require the ability to delegate all vested coins at endTime - plva = types.NewPermanentLockedAccount(bacc, origCoins) - plva.TrackDelegation(endTime, origCoins, origCoins) - require.Equal(t, origCoins, plva.DelegatedVesting) - require.Nil(t, plva.DelegatedFree) - - // require no modifications when delegation amount is zero or not enough funds - plva = types.NewPermanentLockedAccount(bacc, origCoins) - - require.Panics(t, func() { - plva.TrackDelegation(endTime, origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 1000000)}) - }) - require.Nil(t, plva.DelegatedVesting) - require.Nil(t, plva.DelegatedFree) -} - -func TestTrackUndelegationPermLockedVestingAcc(t *testing.T) { - now := tmtime.Now() - endTime := now.Add(1000 * 24 * time.Hour) - - bacc, origCoins := initBaseAccount() - - // require the ability to undelegate all vesting coins - plva := types.NewPermanentLockedAccount(bacc, origCoins) - plva.TrackDelegation(now, origCoins, origCoins) - plva.TrackUndelegation(origCoins) - require.Nil(t, plva.DelegatedFree) - require.Nil(t, plva.DelegatedVesting) - - // require the ability to undelegate all vesting coins at endTime - plva = types.NewPermanentLockedAccount(bacc, origCoins) - plva.TrackDelegation(endTime, origCoins, origCoins) - plva.TrackUndelegation(origCoins) - require.Nil(t, plva.DelegatedFree) - require.Nil(t, plva.DelegatedVesting) - - // require no modifications when the undelegation amount is zero - plva = types.NewPermanentLockedAccount(bacc, origCoins) - require.Panics(t, func() { - plva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 0)}) - }) - require.Nil(t, plva.DelegatedFree) - require.Nil(t, plva.DelegatedVesting) - - // delegate to two validators - plva = types.NewPermanentLockedAccount(bacc, origCoins) - plva.TrackDelegation(now, origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) - plva.TrackDelegation(now, origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) - - // undelegate from one validator that got slashed 50% - plva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 25)}) - - require.Nil(t, plva.DelegatedFree) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 75)}, plva.DelegatedVesting) - - // undelegate from the other validator that did not get slashed - plva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) - require.Nil(t, plva.DelegatedFree) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 25)}, plva.DelegatedVesting) -} - -func TestGetVestedCoinsCliffVestingAcc(t *testing.T) { - now := tmtime.Now() - cliffTime := now.Add(12 * time.Hour) - endTime := now.Add(24 * time.Hour) - - bacc, origCoins := initBaseAccount() - cva := types.NewCliffVestingAccount(bacc, origCoins, now.Unix(), cliffTime.Unix(), endTime.Unix()) - - // require no coins vested in the very beginning of the vesting schedule - vestedCoins := cva.GetVestedCoins(now) - require.Nil(t, vestedCoins) - - // require no coins vested in the very beginning of the cliff schedule - vestedCoins = cva.GetVestedCoins(cliffTime) - require.Nil(t, vestedCoins) - - // require all coins vested at the end of the vesting schedule - vestedCoins = cva.GetVestedCoins(endTime) - require.Equal(t, origCoins, vestedCoins) - - // require 75% of coins vested - vestedCoins = cva.GetVestedCoins(now.Add(18 * time.Hour)) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 750), sdk.NewInt64Coin(stakeDenom, 75)}, vestedCoins) - - // require 100% of coins vested - vestedCoins = cva.GetVestedCoins(now.Add(48 * time.Hour)) - require.Equal(t, origCoins, vestedCoins) -} - -func TestGetVestingCoinsCliffVestingAcc(t *testing.T) { - now := tmtime.Now() - cliffTime := now.Add(12 * time.Hour) - endTime := now.Add(24 * time.Hour) - - bacc, origCoins := initBaseAccount() - cva := types.NewCliffVestingAccount(bacc, origCoins, now.Unix(), cliffTime.Unix(), endTime.Unix()) - - // require all coins vesting in the beginning of the vesting schedule - vestingCoins := cva.GetVestingCoins(now) - require.Equal(t, origCoins, vestingCoins) - - // require all coins vesting in the very beginning of the cliff vesting schedule - vestingCoins = cva.GetVestingCoins(cliffTime) - require.Equal(t, origCoins, vestingCoins) - - // require no coins vesting at the end of the vesting schedule - vestingCoins = cva.GetVestingCoins(endTime) - require.Nil(t, vestingCoins) - - // require 25% of coins vesting - vestingCoins = cva.GetVestingCoins(now.Add(18 * time.Hour)) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}, vestingCoins) -} - -func TestSpendableCoinsCliffVestingAcc(t *testing.T) { - now := tmtime.Now() - cliffTime := now.Add(12 * time.Hour) - endTime := now.Add(24 * time.Hour) - - bacc, origCoins := initBaseAccount() - cva := types.NewCliffVestingAccount(bacc, origCoins, now.Unix(), cliffTime.Unix(), endTime.Unix()) - - // require that all original coins are locked at the end of the vesting - // schedule - lockedCoins := cva.LockedCoins(now) - require.Equal(t, origCoins, lockedCoins) - - // require that all original coins are locked at the end of the cliff vesting - // schedule - lockedCoins = cva.LockedCoins(cliffTime) - require.Equal(t, origCoins, lockedCoins) - - // require that there exist no locked coins at the end of the vesting - lockedCoins = cva.LockedCoins(endTime) - require.Equal(t, sdk.NewCoins(), lockedCoins) - - // require that all vested coins (25%) are spendable - lockedCoins = cva.LockedCoins(now.Add(18 * time.Hour)) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}, lockedCoins) -} - -//nolint:lll -func TestGenesisAccountValidate(t *testing.T) { - pubkey := secp256k1.GenPrivKey().PubKey() - addr := sdk.AccAddress(pubkey.Address()) - baseAcc := authtypes.NewBaseAccount(addr, pubkey, 0, 0) - initialVesting := sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 50)) - baseVestingWithCoins := types.NewBaseVestingAccount(baseAcc, initialVesting, 100) - tests := []struct { - name string - acc authtypes.GenesisAccount - expErr bool - }{ - { - "valid base account", - baseAcc, - false, - }, - { - "invalid base valid account", - authtypes.NewBaseAccount(addr, secp256k1.GenPrivKey().PubKey(), 0, 0), - true, - }, - { - "valid base vesting account", - baseVestingWithCoins, - false, - }, - { - "valid continuous vesting account", - types.NewContinuousVestingAccount(baseAcc, initialVesting, 100, 200), - false, - }, - { - "invalid vesting times", - types.NewContinuousVestingAccount(baseAcc, initialVesting, 1654668078, 1554668078), - true, - }, - { - "valid periodic vesting account", - types.NewPeriodicVestingAccount(baseAcc, initialVesting, 0, types.Periods{types.Period{Length: int64(100), Amount: sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 50)}}}), - false, - }, - { - "invalid vesting period lengths", - types.NewPeriodicVestingAccountRaw( - baseVestingWithCoins, - 0, types.Periods{types.Period{Length: int64(50), Amount: sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 50)}}}), - true, - }, - { - "invalid vesting period amounts", - types.NewPeriodicVestingAccountRaw( - baseVestingWithCoins, - 0, types.Periods{types.Period{Length: int64(100), Amount: sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 25)}}}), - true, - }, - { - "valid permanent locked vesting account", - types.NewPermanentLockedAccount(baseAcc, initialVesting), - false, - }, - { - "invalid positive end time for permanently locked vest account", - &types.PermanentLockedAccount{BaseVestingAccount: baseVestingWithCoins}, - true, - }, - } - - for _, tt := range tests { - tt := tt - - t.Run(tt.name, func(t *testing.T) { - require.Equal(t, tt.expErr, tt.acc.Validate() != nil) - }) - } -} - -func initBaseAccount() (*authtypes.BaseAccount, sdk.Coins) { - _, _, addr := testdata.KeyTestPubAddr() - origCoins := sdk.Coins{sdk.NewInt64Coin(feeDenom, 1000), sdk.NewInt64Coin(stakeDenom, 100)} - bacc := authtypes.NewBaseAccountWithAddress(addr) - - return bacc, origCoins -} - -func TestVestingAccountTestSuite(t *testing.T) { - suite.Run(t, new(VestingAccountTestSuite)) -} +// +//import ( +// "testing" +// "time" +// +// cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" +// tmtime "github.com/cometbft/cometbft/types/time" +// "github.com/cosmos/cosmos-sdk/runtime" +// storetypes "github.com/cosmos/cosmos-sdk/store/types" +// "github.com/cosmos/cosmos-sdk/testutil" +// moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" +// "github.com/cosmos/cosmos-sdk/x/auth/keeper" +// "github.com/okp4/okp4d/x/vesting" +// "github.com/stretchr/testify/require" +// "github.com/stretchr/testify/suite" +// +// "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" +// "github.com/cosmos/cosmos-sdk/testutil/testdata" +// sdk "github.com/cosmos/cosmos-sdk/types" +// authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" +// "github.com/okp4/okp4d/x/vesting/types" +//) +// +//var ( +// stakeDenom = "stake" +// feeDenom = "fee" +//) +// +//type VestingAccountTestSuite struct { +// suite.Suite +// +// ctx sdk.Context +// accountKeeper keeper.AccountKeeper +//} +// +//func (s *VestingAccountTestSuite) SetupTest() { +// encCfg := moduletestutil.MakeTestEncodingConfig(vesting.AppModuleBasic{}) +// +// key := storetypes.NewKVStoreKey(authtypes.StoreKey) +// storeService := runtime.NewKVStoreService(key) +// testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) +// s.ctx = testCtx.Ctx.WithBlockHeader(cmtproto.Header{}) +// +// maccPerms := map[string][]string{ +// "fee_collector": nil, +// "mint": {"minter"}, +// "bonded_tokens_pool": {"burner", "staking"}, +// "not_bonded_tokens_pool": {"burner", "staking"}, +// "multiPerm": {"burner", "minter", "staking"}, +// "random": {"random"}, +// } +// +// s.accountKeeper = keeper.NewAccountKeeper( +// encCfg.Codec, +// storeService, +// authtypes.ProtoBaseAccount, +// maccPerms, +// "cosmos", +// authtypes.NewModuleAddress("gov").String(), +// ) +//} +// +//func TestGetVestedCoinsContVestingAcc(t *testing.T) { +// now := tmtime.Now() +// endTime := now.Add(24 * time.Hour) +// +// bacc, origCoins := initBaseAccount() +// cva := types.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) +// +// // require no coins vested in the very beginning of the vesting schedule +// vestedCoins := cva.GetVestedCoins(now) +// require.Nil(t, vestedCoins) +// +// // require all coins vested at the end of the vesting schedule +// vestedCoins = cva.GetVestedCoins(endTime) +// require.Equal(t, origCoins, vestedCoins) +// +// // require 50% of coins vested +// vestedCoins = cva.GetVestedCoins(now.Add(12 * time.Hour)) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}, vestedCoins) +// +// // require 100% of coins vested +// vestedCoins = cva.GetVestedCoins(now.Add(48 * time.Hour)) +// require.Equal(t, origCoins, vestedCoins) +//} +// +//func TestGetVestingCoinsContVestingAcc(t *testing.T) { +// now := tmtime.Now() +// endTime := now.Add(24 * time.Hour) +// +// bacc, origCoins := initBaseAccount() +// cva := types.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) +// +// // require all coins vesting in the beginning of the vesting schedule +// vestingCoins := cva.GetVestingCoins(now) +// require.Equal(t, origCoins, vestingCoins) +// +// // require no coins vesting at the end of the vesting schedule +// vestingCoins = cva.GetVestingCoins(endTime) +// require.Nil(t, vestingCoins) +// +// // require 50% of coins vesting +// vestingCoins = cva.GetVestingCoins(now.Add(12 * time.Hour)) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}, vestingCoins) +//} +// +//func TestSpendableCoinsContVestingAcc(t *testing.T) { +// now := tmtime.Now() +// endTime := now.Add(24 * time.Hour) +// +// bacc, origCoins := initBaseAccount() +// cva := types.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) +// +// // require that all original coins are locked at the end of the vesting +// // schedule +// lockedCoins := cva.LockedCoins(now) +// require.Equal(t, origCoins, lockedCoins) +// +// // require that there exist no locked coins at the end of the vesting +// lockedCoins = cva.LockedCoins(endTime) +// require.Equal(t, sdk.NewCoins(), lockedCoins) +// +// // require that all vested coins (50%) are spendable +// lockedCoins = cva.LockedCoins(now.Add(12 * time.Hour)) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}, lockedCoins) +//} +// +//func TestTrackDelegationContVestingAcc(t *testing.T) { +// now := tmtime.Now() +// endTime := now.Add(24 * time.Hour) +// +// bacc, origCoins := initBaseAccount() +// +// // require the ability to delegate all vesting coins +// cva := types.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) +// cva.TrackDelegation(now, origCoins, origCoins) +// require.Equal(t, origCoins, cva.DelegatedVesting) +// require.Nil(t, cva.DelegatedFree) +// +// // require the ability to delegate all vested coins +// cva = types.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) +// cva.TrackDelegation(endTime, origCoins, origCoins) +// require.Nil(t, cva.DelegatedVesting) +// require.Equal(t, origCoins, cva.DelegatedFree) +// +// // require the ability to delegate all vesting coins (50%) and all vested coins (50%) +// cva = types.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) +// cva.TrackDelegation(now.Add(12*time.Hour), origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}, cva.DelegatedVesting) +// require.Nil(t, cva.DelegatedFree) +// +// cva.TrackDelegation(now.Add(12*time.Hour), origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}, cva.DelegatedVesting) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}, cva.DelegatedFree) +// +// // require no modifications when delegation amount is zero or not enough funds +// cva = types.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) +// require.Panics(t, func() { +// cva.TrackDelegation(endTime, origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 1000000)}) +// }) +// require.Nil(t, cva.DelegatedVesting) +// require.Nil(t, cva.DelegatedFree) +//} +// +//func TestTrackUndelegationContVestingAcc(t *testing.T) { +// now := tmtime.Now() +// endTime := now.Add(24 * time.Hour) +// +// bacc, origCoins := initBaseAccount() +// +// // require the ability to undelegate all vesting coins +// cva := types.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) +// cva.TrackDelegation(now, origCoins, origCoins) +// cva.TrackUndelegation(origCoins) +// require.Nil(t, cva.DelegatedFree) +// require.Nil(t, cva.DelegatedVesting) +// +// // require the ability to undelegate all vested coins +// cva = types.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) +// +// cva.TrackDelegation(endTime, origCoins, origCoins) +// cva.TrackUndelegation(origCoins) +// require.Nil(t, cva.DelegatedFree) +// require.Nil(t, cva.DelegatedVesting) +// +// // require no modifications when the undelegation amount is zero +// cva = types.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) +// +// require.Panics(t, func() { +// cva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 0)}) +// }) +// require.Nil(t, cva.DelegatedFree) +// require.Nil(t, cva.DelegatedVesting) +// +// // vest 50% and delegate to two validators +// cva = types.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) +// cva.TrackDelegation(now.Add(12*time.Hour), origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) +// cva.TrackDelegation(now.Add(12*time.Hour), origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) +// +// // undelegate from one validator that got slashed 50% +// cva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 25)}) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 25)}, cva.DelegatedFree) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}, cva.DelegatedVesting) +// +// // undelegate from the other validator that did not get slashed +// cva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) +// require.Nil(t, cva.DelegatedFree) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 25)}, cva.DelegatedVesting) +//} +// +//func TestGetVestedCoinsDelVestingAcc(t *testing.T) { +// now := tmtime.Now() +// endTime := now.Add(24 * time.Hour) +// +// bacc, origCoins := initBaseAccount() +// +// // require no coins are vested until schedule maturation +// dva := types.NewDelayedVestingAccount(bacc, origCoins, endTime.Unix()) +// vestedCoins := dva.GetVestedCoins(now) +// require.Nil(t, vestedCoins) +// +// // require all coins be vested at schedule maturation +// vestedCoins = dva.GetVestedCoins(endTime) +// require.Equal(t, origCoins, vestedCoins) +//} +// +//func TestGetVestingCoinsDelVestingAcc(t *testing.T) { +// now := tmtime.Now() +// endTime := now.Add(24 * time.Hour) +// +// bacc, origCoins := initBaseAccount() +// +// // require all coins vesting at the beginning of the schedule +// dva := types.NewDelayedVestingAccount(bacc, origCoins, endTime.Unix()) +// vestingCoins := dva.GetVestingCoins(now) +// require.Equal(t, origCoins, vestingCoins) +// +// // require no coins vesting at schedule maturation +// vestingCoins = dva.GetVestingCoins(endTime) +// require.Nil(t, vestingCoins) +//} +// +//func TestSpendableCoinsDelVestingAcc(t *testing.T) { +// now := tmtime.Now() +// endTime := now.Add(24 * time.Hour) +// +// bacc, origCoins := initBaseAccount() +// +// // require that all coins are locked in the beginning of the vesting +// // schedule +// dva := types.NewDelayedVestingAccount(bacc, origCoins, endTime.Unix()) +// lockedCoins := dva.LockedCoins(now) +// require.True(t, lockedCoins.IsEqual(origCoins)) +// +// // require that all coins are spendable after the maturation of the vesting +// // schedule +// lockedCoins = dva.LockedCoins(endTime) +// require.Equal(t, sdk.NewCoins(), lockedCoins) +// +// // require that all coins are still vesting after some time +// lockedCoins = dva.LockedCoins(now.Add(12 * time.Hour)) +// require.True(t, lockedCoins.IsEqual(origCoins)) +// +// // delegate some locked coins +// // require that locked is reduced +// delegatedAmount := sdk.NewCoins(sdk.NewInt64Coin(stakeDenom, 50)) +// dva.TrackDelegation(now.Add(12*time.Hour), origCoins, delegatedAmount) +// lockedCoins = dva.LockedCoins(now.Add(12 * time.Hour)) +// require.True(t, lockedCoins.IsEqual(origCoins.Sub(delegatedAmount...))) +//} +// +//func TestTrackDelegationDelVestingAcc(t *testing.T) { +// now := tmtime.Now() +// endTime := now.Add(24 * time.Hour) +// +// bacc, origCoins := initBaseAccount() +// +// // require the ability to delegate all vesting coins +// dva := types.NewDelayedVestingAccount(bacc, origCoins, endTime.Unix()) +// dva.TrackDelegation(now, origCoins, origCoins) +// require.Equal(t, origCoins, dva.DelegatedVesting) +// require.Nil(t, dva.DelegatedFree) +// +// // require the ability to delegate all vested coins +// dva = types.NewDelayedVestingAccount(bacc, origCoins, endTime.Unix()) +// dva.TrackDelegation(endTime, origCoins, origCoins) +// require.Nil(t, dva.DelegatedVesting) +// require.Equal(t, origCoins, dva.DelegatedFree) +// +// // require the ability to delegate all coins half way through the vesting +// // schedule +// dva = types.NewDelayedVestingAccount(bacc, origCoins, endTime.Unix()) +// dva.TrackDelegation(now.Add(12*time.Hour), origCoins, origCoins) +// require.Equal(t, origCoins, dva.DelegatedVesting) +// require.Nil(t, dva.DelegatedFree) +// +// // require no modifications when delegation amount is zero or not enough funds +// dva = types.NewDelayedVestingAccount(bacc, origCoins, endTime.Unix()) +// +// require.Panics(t, func() { +// dva.TrackDelegation(endTime, origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 1000000)}) +// }) +// require.Nil(t, dva.DelegatedVesting) +// require.Nil(t, dva.DelegatedFree) +//} +// +//func TestTrackUndelegationDelVestingAcc(t *testing.T) { +// now := tmtime.Now() +// endTime := now.Add(24 * time.Hour) +// +// bacc, origCoins := initBaseAccount() +// +// // require the ability to undelegate all vesting coins +// dva := types.NewDelayedVestingAccount(bacc, origCoins, endTime.Unix()) +// dva.TrackDelegation(now, origCoins, origCoins) +// dva.TrackUndelegation(origCoins) +// require.Nil(t, dva.DelegatedFree) +// require.Nil(t, dva.DelegatedVesting) +// +// // require the ability to undelegate all vested coins +// dva = types.NewDelayedVestingAccount(bacc, origCoins, endTime.Unix()) +// dva.TrackDelegation(endTime, origCoins, origCoins) +// dva.TrackUndelegation(origCoins) +// require.Nil(t, dva.DelegatedFree) +// require.Nil(t, dva.DelegatedVesting) +// +// // require no modifications when the undelegation amount is zero +// dva = types.NewDelayedVestingAccount(bacc, origCoins, endTime.Unix()) +// +// require.Panics(t, func() { +// dva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 0)}) +// }) +// require.Nil(t, dva.DelegatedFree) +// require.Nil(t, dva.DelegatedVesting) +// +// // vest 50% and delegate to two validators +// dva = types.NewDelayedVestingAccount(bacc, origCoins, endTime.Unix()) +// dva.TrackDelegation(now.Add(12*time.Hour), origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) +// dva.TrackDelegation(now.Add(12*time.Hour), origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) +// +// // undelegate from one validator that got slashed 50% +// dva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 25)}) +// +// require.Nil(t, dva.DelegatedFree) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 75)}, dva.DelegatedVesting) +// +// // undelegate from the other validator that did not get slashed +// dva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) +// require.Nil(t, dva.DelegatedFree) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 25)}, dva.DelegatedVesting) +//} +// +//func TestGetVestedCoinsPeriodicVestingAcc(t *testing.T) { +// now := tmtime.Now() +// endTime := now.Add(24 * time.Hour) +// periods := types.Periods{ +// types.Period{Length: int64(12 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}}, +// types.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}}, +// types.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}}, +// } +// +// bacc, origCoins := initBaseAccount() +// pva := types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) +// +// // require no coins vested at the beginning of the vesting schedule +// vestedCoins := pva.GetVestedCoins(now) +// require.Nil(t, vestedCoins) +// +// // require all coins vested at the end of the vesting schedule +// vestedCoins = pva.GetVestedCoins(endTime) +// require.Equal(t, origCoins, vestedCoins) +// +// // require no coins vested during first vesting period +// vestedCoins = pva.GetVestedCoins(now.Add(6 * time.Hour)) +// require.Nil(t, vestedCoins) +// +// // require 50% of coins vested after period 1 +// vestedCoins = pva.GetVestedCoins(now.Add(12 * time.Hour)) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}, vestedCoins) +// +// // require period 2 coins don't vest until period is over +// vestedCoins = pva.GetVestedCoins(now.Add(15 * time.Hour)) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}, vestedCoins) +// +// // require 75% of coins vested after period 2 +// vestedCoins = pva.GetVestedCoins(now.Add(18 * time.Hour)) +// require.Equal(t, +// sdk.Coins{ +// sdk.NewInt64Coin(feeDenom, 750), sdk.NewInt64Coin(stakeDenom, 75), +// }, vestedCoins) +// +// // require 100% of coins vested +// vestedCoins = pva.GetVestedCoins(now.Add(48 * time.Hour)) +// require.Equal(t, origCoins, vestedCoins) +//} +// +//func TestGetVestingCoinsPeriodicVestingAcc(t *testing.T) { +// now := tmtime.Now() +// endTime := now.Add(24 * time.Hour) +// periods := types.Periods{ +// types.Period{Length: int64(12 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}}, +// types.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}}, +// types.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}}, +// } +// +// bacc, origCoins := initBaseAccount() +// pva := types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) +// +// // require all coins vesting at the beginning of the vesting schedule +// vestingCoins := pva.GetVestingCoins(now) +// require.Equal(t, origCoins, vestingCoins) +// +// // require no coins vesting at the end of the vesting schedule +// vestingCoins = pva.GetVestingCoins(endTime) +// require.Nil(t, vestingCoins) +// +// // require 50% of coins vesting +// vestingCoins = pva.GetVestingCoins(now.Add(12 * time.Hour)) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}, vestingCoins) +// +// // require 50% of coins vesting after period 1, but before period 2 completes. +// vestingCoins = pva.GetVestingCoins(now.Add(15 * time.Hour)) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}, vestingCoins) +// +// // require 25% of coins vesting after period 2 +// vestingCoins = pva.GetVestingCoins(now.Add(18 * time.Hour)) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}, vestingCoins) +// +// // require 0% of coins vesting after vesting complete +// vestingCoins = pva.GetVestingCoins(now.Add(48 * time.Hour)) +// require.Nil(t, vestingCoins) +//} +// +//func TestSpendableCoinsPeriodicVestingAcc(t *testing.T) { +// now := tmtime.Now() +// endTime := now.Add(24 * time.Hour) +// periods := types.Periods{ +// types.Period{Length: int64(12 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}}, +// types.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}}, +// types.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}}, +// } +// +// bacc, origCoins := initBaseAccount() +// pva := types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) +// +// // require that there exist no spendable coins at the beginning of the +// // vesting schedule +// lockedCoins := pva.LockedCoins(now) +// require.Equal(t, origCoins, lockedCoins) +// +// // require that all original coins are spendable at the end of the vesting +// // schedule +// lockedCoins = pva.LockedCoins(endTime) +// require.Equal(t, sdk.NewCoins(), lockedCoins) +// +// // require that all still vesting coins (50%) are locked +// lockedCoins = pva.LockedCoins(now.Add(12 * time.Hour)) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}, lockedCoins) +//} +// +//func TestTrackDelegationPeriodicVestingAcc(t *testing.T) { +// now := tmtime.Now() +// endTime := now.Add(24 * time.Hour) +// periods := types.Periods{ +// types.Period{Length: int64(12 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}}, +// types.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}}, +// types.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}}, +// } +// +// bacc, origCoins := initBaseAccount() +// +// // require the ability to delegate all vesting coins +// pva := types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) +// pva.TrackDelegation(now, origCoins, origCoins) +// require.Equal(t, origCoins, pva.DelegatedVesting) +// require.Nil(t, pva.DelegatedFree) +// +// // require the ability to delegate all vested coins +// pva = types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) +// pva.TrackDelegation(endTime, origCoins, origCoins) +// require.Nil(t, pva.DelegatedVesting) +// require.Equal(t, origCoins, pva.DelegatedFree) +// +// // delegate half of vesting coins +// pva = types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) +// pva.TrackDelegation(now, origCoins, periods[0].Amount) +// // require that all delegated coins are delegated vesting +// require.Equal(t, pva.DelegatedVesting, periods[0].Amount) +// require.Nil(t, pva.DelegatedFree) +// +// // delegate 75% of coins, split between vested and vesting +// pva = types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) +// pva.TrackDelegation(now.Add(12*time.Hour), origCoins, periods[0].Amount.Add(periods[1].Amount...)) +// // require that the maximum possible amount of vesting coins are chosen for delegation. +// require.Equal(t, pva.DelegatedFree, periods[1].Amount) +// require.Equal(t, pva.DelegatedVesting, periods[0].Amount) +// +// // require the ability to delegate all vesting coins (50%) and all vested coins (50%) +// pva = types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) +// pva.TrackDelegation(now.Add(12*time.Hour), origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}, pva.DelegatedVesting) +// require.Nil(t, pva.DelegatedFree) +// +// pva.TrackDelegation(now.Add(12*time.Hour), origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}, pva.DelegatedVesting) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}, pva.DelegatedFree) +// +// // require no modifications when delegation amount is zero or not enough funds +// pva = types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) +// require.Panics(t, func() { +// pva.TrackDelegation(endTime, origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 1000000)}) +// }) +// require.Nil(t, pva.DelegatedVesting) +// require.Nil(t, pva.DelegatedFree) +//} +// +//func TestTrackUndelegationPeriodicVestingAcc(t *testing.T) { +// now := tmtime.Now() +// endTime := now.Add(24 * time.Hour) +// periods := types.Periods{ +// types.Period{Length: int64(12 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}}, +// types.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}}, +// types.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}}, +// } +// +// bacc, origCoins := initBaseAccount() +// +// // require the ability to undelegate all vesting coins at the beginning of vesting +// pva := types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) +// pva.TrackDelegation(now, origCoins, origCoins) +// pva.TrackUndelegation(origCoins) +// require.Nil(t, pva.DelegatedFree) +// require.Nil(t, pva.DelegatedVesting) +// +// // require the ability to undelegate all vested coins at the end of vesting +// pva = types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) +// +// pva.TrackDelegation(endTime, origCoins, origCoins) +// pva.TrackUndelegation(origCoins) +// require.Nil(t, pva.DelegatedFree) +// require.Nil(t, pva.DelegatedVesting) +// +// // require the ability to undelegate half of coins +// pva = types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) +// pva.TrackDelegation(endTime, origCoins, periods[0].Amount) +// pva.TrackUndelegation(periods[0].Amount) +// require.Nil(t, pva.DelegatedFree) +// require.Nil(t, pva.DelegatedVesting) +// +// // require no modifications when the undelegation amount is zero +// pva = types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) +// +// require.Panics(t, func() { +// pva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 0)}) +// }) +// require.Nil(t, pva.DelegatedFree) +// require.Nil(t, pva.DelegatedVesting) +// +// // vest 50% and delegate to two validators +// pva = types.NewPeriodicVestingAccount(bacc, origCoins, now.Unix(), periods) +// pva.TrackDelegation(now.Add(12*time.Hour), origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) +// pva.TrackDelegation(now.Add(12*time.Hour), origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) +// +// // undelegate from one validator that got slashed 50% +// pva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 25)}) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 25)}, pva.DelegatedFree) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}, pva.DelegatedVesting) +// +// // undelegate from the other validator that did not get slashed +// pva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) +// require.Nil(t, pva.DelegatedFree) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 25)}, pva.DelegatedVesting) +//} +// +//func TestGetVestedCoinsPermLockedVestingAcc(t *testing.T) { +// now := tmtime.Now() +// endTime := now.Add(1000 * 24 * time.Hour) +// +// bacc, origCoins := initBaseAccount() +// +// // require no coins are vested +// plva := types.NewPermanentLockedAccount(bacc, origCoins) +// vestedCoins := plva.GetVestedCoins(now) +// require.Nil(t, vestedCoins) +// +// // require no coins be vested at end time +// vestedCoins = plva.GetVestedCoins(endTime) +// require.Nil(t, vestedCoins) +//} +// +//func TestGetVestingCoinsPermLockedVestingAcc(t *testing.T) { +// now := tmtime.Now() +// endTime := now.Add(1000 * 24 * time.Hour) +// +// bacc, origCoins := initBaseAccount() +// +// // require all coins vesting at the beginning of the schedule +// plva := types.NewPermanentLockedAccount(bacc, origCoins) +// vestingCoins := plva.GetVestingCoins(now) +// require.Equal(t, origCoins, vestingCoins) +// +// // require all coins vesting at the end time +// vestingCoins = plva.GetVestingCoins(endTime) +// require.Equal(t, origCoins, vestingCoins) +//} +// +//func TestSpendableCoinsPermLockedVestingAcc(t *testing.T) { +// now := tmtime.Now() +// endTime := now.Add(1000 * 24 * time.Hour) +// +// bacc, origCoins := initBaseAccount() +// +// // require that all coins are locked in the beginning of the vesting +// // schedule +// plva := types.NewPermanentLockedAccount(bacc, origCoins) +// lockedCoins := plva.LockedCoins(now) +// require.True(t, lockedCoins.IsEqual(origCoins)) +// +// // require that all coins are still locked at end time +// lockedCoins = plva.LockedCoins(endTime) +// require.True(t, lockedCoins.IsEqual(origCoins)) +// +// // delegate some locked coins +// // require that locked is reduced +// delegatedAmount := sdk.NewCoins(sdk.NewInt64Coin(stakeDenom, 50)) +// plva.TrackDelegation(now.Add(12*time.Hour), origCoins, delegatedAmount) +// lockedCoins = plva.LockedCoins(now.Add(12 * time.Hour)) +// require.True(t, lockedCoins.IsEqual(origCoins.Sub(delegatedAmount...))) +//} +// +//func TestTrackDelegationPermLockedVestingAcc(t *testing.T) { +// now := tmtime.Now() +// endTime := now.Add(1000 * 24 * time.Hour) +// +// bacc, origCoins := initBaseAccount() +// +// // require the ability to delegate all vesting coins +// plva := types.NewPermanentLockedAccount(bacc, origCoins) +// plva.TrackDelegation(now, origCoins, origCoins) +// require.Equal(t, origCoins, plva.DelegatedVesting) +// require.Nil(t, plva.DelegatedFree) +// +// // require the ability to delegate all vested coins at endTime +// plva = types.NewPermanentLockedAccount(bacc, origCoins) +// plva.TrackDelegation(endTime, origCoins, origCoins) +// require.Equal(t, origCoins, plva.DelegatedVesting) +// require.Nil(t, plva.DelegatedFree) +// +// // require no modifications when delegation amount is zero or not enough funds +// plva = types.NewPermanentLockedAccount(bacc, origCoins) +// +// require.Panics(t, func() { +// plva.TrackDelegation(endTime, origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 1000000)}) +// }) +// require.Nil(t, plva.DelegatedVesting) +// require.Nil(t, plva.DelegatedFree) +//} +// +//func TestTrackUndelegationPermLockedVestingAcc(t *testing.T) { +// now := tmtime.Now() +// endTime := now.Add(1000 * 24 * time.Hour) +// +// bacc, origCoins := initBaseAccount() +// +// // require the ability to undelegate all vesting coins +// plva := types.NewPermanentLockedAccount(bacc, origCoins) +// plva.TrackDelegation(now, origCoins, origCoins) +// plva.TrackUndelegation(origCoins) +// require.Nil(t, plva.DelegatedFree) +// require.Nil(t, plva.DelegatedVesting) +// +// // require the ability to undelegate all vesting coins at endTime +// plva = types.NewPermanentLockedAccount(bacc, origCoins) +// plva.TrackDelegation(endTime, origCoins, origCoins) +// plva.TrackUndelegation(origCoins) +// require.Nil(t, plva.DelegatedFree) +// require.Nil(t, plva.DelegatedVesting) +// +// // require no modifications when the undelegation amount is zero +// plva = types.NewPermanentLockedAccount(bacc, origCoins) +// require.Panics(t, func() { +// plva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 0)}) +// }) +// require.Nil(t, plva.DelegatedFree) +// require.Nil(t, plva.DelegatedVesting) +// +// // delegate to two validators +// plva = types.NewPermanentLockedAccount(bacc, origCoins) +// plva.TrackDelegation(now, origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) +// plva.TrackDelegation(now, origCoins, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) +// +// // undelegate from one validator that got slashed 50% +// plva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 25)}) +// +// require.Nil(t, plva.DelegatedFree) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 75)}, plva.DelegatedVesting) +// +// // undelegate from the other validator that did not get slashed +// plva.TrackUndelegation(sdk.Coins{sdk.NewInt64Coin(stakeDenom, 50)}) +// require.Nil(t, plva.DelegatedFree) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeDenom, 25)}, plva.DelegatedVesting) +//} +// +//func TestGetVestedCoinsCliffVestingAcc(t *testing.T) { +// now := tmtime.Now() +// cliffTime := now.Add(12 * time.Hour) +// endTime := now.Add(24 * time.Hour) +// +// bacc, origCoins := initBaseAccount() +// cva := types.NewCliffVestingAccount(bacc, origCoins, now.Unix(), cliffTime.Unix(), endTime.Unix()) +// +// // require no coins vested in the very beginning of the vesting schedule +// vestedCoins := cva.GetVestedCoins(now) +// require.Nil(t, vestedCoins) +// +// // require no coins vested in the very beginning of the cliff schedule +// vestedCoins = cva.GetVestedCoins(cliffTime) +// require.Nil(t, vestedCoins) +// +// // require all coins vested at the end of the vesting schedule +// vestedCoins = cva.GetVestedCoins(endTime) +// require.Equal(t, origCoins, vestedCoins) +// +// // require 75% of coins vested +// vestedCoins = cva.GetVestedCoins(now.Add(18 * time.Hour)) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 750), sdk.NewInt64Coin(stakeDenom, 75)}, vestedCoins) +// +// // require 100% of coins vested +// vestedCoins = cva.GetVestedCoins(now.Add(48 * time.Hour)) +// require.Equal(t, origCoins, vestedCoins) +//} +// +//func TestGetVestingCoinsCliffVestingAcc(t *testing.T) { +// now := tmtime.Now() +// cliffTime := now.Add(12 * time.Hour) +// endTime := now.Add(24 * time.Hour) +// +// bacc, origCoins := initBaseAccount() +// cva := types.NewCliffVestingAccount(bacc, origCoins, now.Unix(), cliffTime.Unix(), endTime.Unix()) +// +// // require all coins vesting in the beginning of the vesting schedule +// vestingCoins := cva.GetVestingCoins(now) +// require.Equal(t, origCoins, vestingCoins) +// +// // require all coins vesting in the very beginning of the cliff vesting schedule +// vestingCoins = cva.GetVestingCoins(cliffTime) +// require.Equal(t, origCoins, vestingCoins) +// +// // require no coins vesting at the end of the vesting schedule +// vestingCoins = cva.GetVestingCoins(endTime) +// require.Nil(t, vestingCoins) +// +// // require 25% of coins vesting +// vestingCoins = cva.GetVestingCoins(now.Add(18 * time.Hour)) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}, vestingCoins) +//} +// +//func TestSpendableCoinsCliffVestingAcc(t *testing.T) { +// now := tmtime.Now() +// cliffTime := now.Add(12 * time.Hour) +// endTime := now.Add(24 * time.Hour) +// +// bacc, origCoins := initBaseAccount() +// cva := types.NewCliffVestingAccount(bacc, origCoins, now.Unix(), cliffTime.Unix(), endTime.Unix()) +// +// // require that all original coins are locked at the end of the vesting +// // schedule +// lockedCoins := cva.LockedCoins(now) +// require.Equal(t, origCoins, lockedCoins) +// +// // require that all original coins are locked at the end of the cliff vesting +// // schedule +// lockedCoins = cva.LockedCoins(cliffTime) +// require.Equal(t, origCoins, lockedCoins) +// +// // require that there exist no locked coins at the end of the vesting +// lockedCoins = cva.LockedCoins(endTime) +// require.Equal(t, sdk.NewCoins(), lockedCoins) +// +// // require that all vested coins (25%) are spendable +// lockedCoins = cva.LockedCoins(now.Add(18 * time.Hour)) +// require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}, lockedCoins) +//} +// +////nolint:lll +//func TestGenesisAccountValidate(t *testing.T) { +// pubkey := secp256k1.GenPrivKey().PubKey() +// addr := sdk.AccAddress(pubkey.Address()) +// baseAcc := authtypes.NewBaseAccount(addr, pubkey, 0, 0) +// initialVesting := sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 50)) +// baseVestingWithCoins := types.NewBaseVestingAccount(baseAcc, initialVesting, 100) +// tests := []struct { +// name string +// acc authtypes.GenesisAccount +// expErr bool +// }{ +// { +// "valid base account", +// baseAcc, +// false, +// }, +// { +// "invalid base valid account", +// authtypes.NewBaseAccount(addr, secp256k1.GenPrivKey().PubKey(), 0, 0), +// true, +// }, +// { +// "valid base vesting account", +// baseVestingWithCoins, +// false, +// }, +// { +// "valid continuous vesting account", +// types.NewContinuousVestingAccount(baseAcc, initialVesting, 100, 200), +// false, +// }, +// { +// "invalid vesting times", +// types.NewContinuousVestingAccount(baseAcc, initialVesting, 1654668078, 1554668078), +// true, +// }, +// { +// "valid periodic vesting account", +// types.NewPeriodicVestingAccount(baseAcc, initialVesting, 0, types.Periods{types.Period{Length: int64(100), Amount: sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 50)}}}), +// false, +// }, +// { +// "invalid vesting period lengths", +// types.NewPeriodicVestingAccountRaw( +// baseVestingWithCoins, +// 0, types.Periods{types.Period{Length: int64(50), Amount: sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 50)}}}), +// true, +// }, +// { +// "invalid vesting period amounts", +// types.NewPeriodicVestingAccountRaw( +// baseVestingWithCoins, +// 0, types.Periods{types.Period{Length: int64(100), Amount: sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 25)}}}), +// true, +// }, +// { +// "valid permanent locked vesting account", +// types.NewPermanentLockedAccount(baseAcc, initialVesting), +// false, +// }, +// { +// "invalid positive end time for permanently locked vest account", +// &types.PermanentLockedAccount{BaseVestingAccount: baseVestingWithCoins}, +// true, +// }, +// } +// +// for _, tt := range tests { +// tt := tt +// +// t.Run(tt.name, func(t *testing.T) { +// require.Equal(t, tt.expErr, tt.acc.Validate() != nil) +// }) +// } +//} +// +//func initBaseAccount() (*authtypes.BaseAccount, sdk.Coins) { +// _, _, addr := testdata.KeyTestPubAddr() +// origCoins := sdk.Coins{sdk.NewInt64Coin(feeDenom, 1000), sdk.NewInt64Coin(stakeDenom, 100)} +// bacc := authtypes.NewBaseAccountWithAddress(addr) +// +// return bacc, origCoins +//} +// +//func TestVestingAccountTestSuite(t *testing.T) { +// suite.Run(t, new(VestingAccountTestSuite)) +//}