Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: multiple coins final tests #186

Merged
merged 29 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9f5c717
chore: only charge coins which are whitelisted
troykessler May 6, 2024
9354510
chore: started implementation of multiple coins in x/bundles
troykessler May 6, 2024
fd6bf07
chore: implemented multiple coins in bundles module
troykessler May 6, 2024
426e4a9
test: fixed existing unit tests
troykessler May 6, 2024
bc9ebeb
chore: added more comments
troykessler May 7, 2024
0d18933
chore: implemented multiple coins in x/stakers and fixed existing tests
troykessler May 7, 2024
0317a06
test: added additional tests for multiple coins
troykessler May 7, 2024
3c3776b
test: fixed tests
troykessler May 7, 2024
2b58d5a
chore: refactored first tests
troykessler May 10, 2024
f9e7737
test: added tests for multiple coin funding
troykessler May 14, 2024
3766684
chore: implemented multiple coins in x/stakers and fixed existing tests
troykessler May 7, 2024
9a91dfb
test: added additional tests for multiple coins
troykessler May 7, 2024
eb482c2
test: fixed tests
troykessler May 7, 2024
6c1d8f9
Merge branch 'main' into troy/stakers-multiple-coins
troykessler May 14, 2024
78cd57b
chore: added current feature in changelog
troykessler May 14, 2024
387f018
chore: sync merge
troykessler May 14, 2024
0ecdd83
Merge branch 'troy/stakers-multiple-coins' into troy/multiple-coins-i…
troykessler May 14, 2024
63fec6d
test: partially started valid bundles test
troykessler May 14, 2024
36ed27b
test: refactored existing valid bundle tests
troykessler May 14, 2024
bc122da
test: added more tests to valid bundles tests
troykessler May 14, 2024
71b81ff
test: improved inflation splitting tets
troykessler May 15, 2024
02350af
test: assert treasury payouts
troykessler May 15, 2024
e149ea8
chore: sync merge
troykessler May 15, 2024
d73233a
Merge branch 'main' into troy/multiple-coins-integration-tests
troykessler Jun 4, 2024
8cc8516
chore: completed sync merge
troykessler Jun 4, 2024
ae4b9a1
chore: resolved coderabbit comments
troykessler Jun 4, 2024
623d0cf
chore: added helper comments
troykessler Jun 4, 2024
78deef2
chore: added helper comments
troykessler Jun 4, 2024
4fb1df1
chore: resolved comments
troykessler Jun 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ An '!' indicates a state machine breaking change.

### Features

- ! (`x/stakers`) [#185](https://github.com/KYVENetwork/chain/pull/185) Support multiple coins in stakers module.
- ! (`x/bundles`) [#184](https://github.com/KYVENetwork/chain/pull/184) Support multiple coins in bundles module.
- ! (`x/funders`) [#179](https://github.com/KYVENetwork/chain/pull/179) Support multiple coins for funding.
- ! (`x/bundles`) [#177](https://github.com/KYVENetwork/chain/pull/177) Add end-key to pool.
Expand Down
138 changes: 114 additions & 24 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -609,11 +609,26 @@ paths:

of a staker will change to the new commission
commission_rewards:
type: string
format: uint64
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and
an amount.


NOTE: The amount field is an Int which
implements the custom method

signatures required by gogoproto.
title: >-
commission_rewards are the rewards in $KYVE
earned through commission
commission_rewards are the rewards through
commission and storage cost
title: >-
StakerMetadata contains static information for a
staker
Expand Down Expand Up @@ -3928,11 +3943,26 @@ paths:

of a staker will change to the new commission
commission_rewards:
type: string
format: uint64
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and
an amount.


NOTE: The amount field is an Int which
implements the custom method

signatures required by gogoproto.
title: >-
commission_rewards are the rewards in $KYVE
earned through commission
commission_rewards are the rewards through
commission and storage cost
title: >-
StakerMetadata contains static information for a
staker
Expand Down Expand Up @@ -6290,11 +6320,26 @@ paths:
CommissionChangeEntry shows when the old commission
of a staker will change to the new commission
commission_rewards:
type: string
format: uint64
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an
amount.


NOTE: The amount field is an Int which implements
the custom method

signatures required by gogoproto.
title: >-
commission_rewards are the rewards in $KYVE earned
through commission
commission_rewards are the rewards through commission
and storage cost
title: StakerMetadata contains static information for a staker
self_delegation:
type: string
Expand Down Expand Up @@ -6733,11 +6778,26 @@ paths:
CommissionChangeEntry shows when the old commission
of a staker will change to the new commission
commission_rewards:
type: string
format: uint64
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an
amount.


NOTE: The amount field is an Int which implements
the custom method

signatures required by gogoproto.
title: >-
commission_rewards are the rewards in $KYVE earned
through commission
commission_rewards are the rewards through
commission and storage cost
title: StakerMetadata contains static information for a staker
self_delegation:
type: string
Expand Down Expand Up @@ -7282,11 +7342,26 @@ paths:

of a staker will change to the new commission
commission_rewards:
type: string
format: uint64
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and
an amount.


NOTE: The amount field is an Int which
implements the custom method

signatures required by gogoproto.
title: >-
commission_rewards are the rewards in $KYVE
earned through commission
commission_rewards are the rewards through
commission and storage cost
title: >-
StakerMetadata contains static information for a
staker
Expand Down Expand Up @@ -7774,11 +7849,26 @@ paths:
CommissionChangeEntry shows when the old commission
of a staker will change to the new commission
commission_rewards:
type: string
format: uint64
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an
amount.


NOTE: The amount field is an Int which implements
the custom method

signatures required by gogoproto.
title: >-
commission_rewards are the rewards in $KYVE earned
through commission
commission_rewards are the rewards through
commission and storage cost
title: StakerMetadata contains static information for a staker
self_delegation:
type: string
Expand Down
8 changes: 6 additions & 2 deletions proto/kyve/query/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,12 @@ message StakerMetadata {
// if they not agree with the new commission.
CommissionChangeEntry pending_commission_change = 7;

// commission_rewards are the rewards in $KYVE earned through commission
uint64 commission_rewards = 8;
// commission_rewards are the rewards through commission and storage cost
repeated cosmos.base.v1beta1.Coin commission_rewards = 8 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// CommissionChangeEntry shows when the old commission
Expand Down
10 changes: 8 additions & 2 deletions proto/kyve/stakers/v1beta1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";

package kyve.stakers.v1beta1;

import "amino/amino.proto";
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
import "kyve/stakers/v1beta1/params.proto";

Expand Down Expand Up @@ -66,8 +68,12 @@ message EventUpdateCommission {
message EventClaimCommissionRewards {
// staker is the account address of the protocol node.
string staker = 1;
// amount ...
uint64 amount = 2;
// amount is the amount of the commission rewards claimed
repeated cosmos.base.v1beta1.Coin amount = 2 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// EventJoinPool ...
Expand Down
10 changes: 8 additions & 2 deletions proto/kyve/stakers/v1beta1/stakers.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";

package kyve.stakers.v1beta1;

import "amino/amino.proto";
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";

option go_package = "github.com/KYVENetwork/chain/x/stakers/types";
Expand All @@ -26,8 +28,12 @@ message Staker {
string security_contact = 6;
// details are some additional notes the staker finds important
string details = 7;
// commission_rewards are the rewards in $KYVE earned through commission
uint64 commission_rewards = 8;
// commission_rewards are the rewards through commission and storage cost
repeated cosmos.base.v1beta1.Coin commission_rewards = 8 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// Valaccount gets authorized by a staker to
Expand Down
8 changes: 7 additions & 1 deletion proto/kyve/stakers/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";

package kyve.stakers.v1beta1;

import "amino/amino.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
Expand Down Expand Up @@ -88,7 +90,11 @@ message MsgClaimCommissionRewards {
// creator ...
string creator = 1;
// amount ...
uint64 amount = 2;
repeated cosmos.base.v1beta1.Coin amount = 2 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// MsgClaimCommissionRewardsResponse ...
Expand Down
9 changes: 4 additions & 5 deletions testutil/integration/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,16 @@ func (suite *KeeperTestSuite) VerifyPoolGenesisImportExport() {
// =====================

func (suite *KeeperTestSuite) VerifyStakersModuleAssetsIntegrity() {
expectedBalance := uint64(0)
actualBalance := uint64(0)
expectedBalance := sdk.NewCoins()

for _, staker := range suite.App().StakersKeeper.GetAllStakers(suite.Ctx()) {
expectedBalance += staker.CommissionRewards
expectedBalance = expectedBalance.Add(staker.CommissionRewards...)
}

moduleAcc := suite.App().AccountKeeper.GetModuleAccount(suite.Ctx(), stakerstypes.ModuleName).GetAddress()
actualBalance = suite.App().BankKeeper.GetBalance(suite.Ctx(), moduleAcc, globalTypes.Denom).Amount.Uint64()
actualBalance := suite.App().BankKeeper.GetAllBalances(suite.Ctx(), moduleAcc)

Expect(actualBalance).To(Equal(expectedBalance))
Expect(actualBalance.String()).To(Equal(expectedBalance.String()))
}

func (suite *KeeperTestSuite) VerifyPoolTotalStake() {
Expand Down
10 changes: 10 additions & 0 deletions testutil/integration/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

func (suite *KeeperTestSuite) GetCoinsFromCommunityPool() sdk.Coins {
pool, err := suite.App().DistributionKeeper.FeePool.Get(suite.Ctx())
if err != nil {
return sdk.NewCoins()
}

coins, _ := pool.CommunityPool.TruncateDecimal()
return coins
}

func (suite *KeeperTestSuite) GetBalanceFromAddress(address string) uint64 {
accAddress, err := sdk.AccAddressFromBech32(address)
if err != nil {
Expand Down
Loading
Loading