Skip to content

Add integration test for pse community distribution#39

Merged
miladz68 merged 14 commits into
masterfrom
milad/pse-distribution-integration-test
Dec 2, 2025
Merged

Add integration test for pse community distribution#39
miladz68 merged 14 commits into
masterfrom
milad/pse-distribution-integration-test

Conversation

@miladz68

@miladz68 miladz68 commented Nov 28, 2025

Copy link
Copy Markdown
Contributor

Description

Reviewers checklist:

  • Try to write more meaningful comments with clear actions to be taken.
  • Nit-picking should be unblocking. Focus on core issues.

Authors checklist

  • Provide a concise and meaningful description
  • Review the code yourself first, before making the PR.
  • Annotate your PR in places that require explanation.
  • Think and try to split the PR to smaller PR if it is big.

This change is Reviewable

@miladz68 miladz68 requested a review from a team as a code owner November 28, 2025 08:55
@miladz68 miladz68 requested review from TxCorpi0x, masihyeganeh and ysv and removed request for a team November 28, 2025 08:55
@miladz68 miladz68 changed the title Add integration test for pse community module Add integration test for pse community distribution Nov 28, 2025
TxCorpi0x
TxCorpi0x previously approved these changes Dec 2, 2025

@TxCorpi0x TxCorpi0x left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

It would also be good to have e description for 0.05 in the test

@TxCorpi0x reviewed 13 of 13 files at r1, 5 of 5 files at r2.
Reviewable status: 17 of 18 files reviewed, all discussions resolved (waiting on @masihyeganeh and @ysv)

@ysv ysv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ysv reviewed 12 of 13 files at r1, 5 of 5 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @masihyeganeh and @miladz68)


proto/tx/pse/v1/query.proto line 76 at r3 (raw file):

    (gogoproto.moretags) = "yaml:\"schedule_distributions\""
  ];
  

nit: whitespace


build/tx-chain/generate-proto-openapi.go line 123 at r3 (raw file):

	for _, dir := range generateDirs {
		// if _, err := os.Stat(dir); err != nil {

should we remove this code or add TODO ?


integration-tests/modules/pse_test.go line 41 at r3 (raw file):

		validator1 := validatorsResponse.Validators[0]

		delegateAmount := sdkmath.NewInt(100_000_000)

isn't it more interesting to create different delegations ?
E.g to use delegateAmount * (i+1) so we have 100, 200, 300TX delegated
Also to validatorsResponse.Validators[i % len(validatorsResponse.Validators)] to delegate to different validators

or this is going to complicate calculations a lot


integration-tests/modules/pse_test.go line 111 at r3 (raw file):

	requireT.NoError(err)
	height := header.Height
	for i := 2; i >= 0; i-- {

nit: would be better to stick to the same version in both for loops

for range 3 { or for i := 2; i >= 0; i-- {


integration-tests/modules/pse_test.go line 112 at r3 (raw file):

	height := header.Height
	for i := 2; i >= 0; i-- {
		height, err = awaitScheduledDistributionEvent(ctx, chain, height)

nit; does it make sense to also query PSE and make sure its state changed after distribution ?


integration-tests/modules/pse_test.go line 130 at r3 (raw file):

			delegatorScore := delegatorScoresBefore[delegator]
			expectedIncrease := allocationAmount.Mul(delegatorScore).Quo(totalScoreBefore)
			requireT.InEpsilon(expectedIncrease.Int64(), increasedAmount.Int64(), 0.05)

nit: our calculations are quite precise and rounding should be within 1 ucore if I'm correct.
I suggest we use InDelta assertion because InEpsilon might mean huge delta if value itself is big.

ideally InDelta(1), but up to InDelta(10-100) is okay and neglegible for me


x/pse/keeper/grpc.go line 72 at r3 (raw file):

	return &types.QueryScheduledDistributionsResponse{
		ScheduledDistributions: scheduledDistributions,
		SkipDistribution:       skipDistribution,

nit: I came up with better name here:
DistributionsDisabled

Let me know if you prefer it (can be renamed in a separate task)
Also we should probably be able to change this param to true via gov in case we find some emergency and want to disable PSE

@miladz68 miladz68 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @masihyeganeh and @ysv)


build/tx-chain/generate-proto-openapi.go line 123 at r3 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

should we remove this code or add TODO ?

Done.


integration-tests/modules/pse_test.go line 41 at r3 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

isn't it more interesting to create different delegations ?
E.g to use delegateAmount * (i+1) so we have 100, 200, 300TX delegated
Also to validatorsResponse.Validators[i % len(validatorsResponse.Validators)] to delegate to different validators

or this is going to complicate calculations a lot

Done.


integration-tests/modules/pse_test.go line 111 at r3 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

nit: would be better to stick to the same version in both for loops

for range 3 { or for i := 2; i >= 0; i-- {

changed previous loop.


integration-tests/modules/pse_test.go line 112 at r3 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

nit; does it make sense to also query PSE and make sure its state changed after distribution ?

Done.


integration-tests/modules/pse_test.go line 130 at r3 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

nit: our calculations are quite precise and rounding should be within 1 ucore if I'm correct.
I suggest we use InDelta assertion because InEpsilon might mean huge delta if value itself is big.

ideally InDelta(1), but up to InDelta(10-100) is okay and neglegible for me

our calculations in integration tests cannot be completely accurate since we only have access to scores in previous block (i.e we cannot know what the score was in the current block), that is why some calculation errors are expected.


proto/tx/pse/v1/query.proto line 76 at r3 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

nit: whitespace

Done.


x/pse/keeper/grpc.go line 72 at r3 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

nit: I came up with better name here:
DistributionsDisabled

Let me know if you prefer it (can be renamed in a separate task)
Also we should probably be able to change this param to true via gov in case we find some emergency and want to disable PSE

let's do both as part of another task. I created the task.

ysv
ysv previously approved these changes Dec 2, 2025

@ysv ysv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ysv reviewed 4 of 4 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @masihyeganeh)

TxCorpi0x
TxCorpi0x previously approved these changes Dec 2, 2025

@TxCorpi0x TxCorpi0x left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TxCorpi0x reviewed 1 of 1 files at r3, 3 of 4 files at r4, 4 of 4 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @masihyeganeh)

ysv
ysv previously approved these changes Dec 2, 2025

@ysv ysv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ysv reviewed 3 of 4 files at r5, 1 of 1 files at r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @masihyeganeh)

@TxCorpi0x TxCorpi0x left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@TxCorpi0x reviewed all commit messages.
Reviewable status: 21 of 22 files reviewed, all discussions resolved (waiting on @masihyeganeh)

@ysv ysv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ysv reviewed 1 of 1 files at r7, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @masihyeganeh)

@miladz68 miladz68 merged commit 63c9342 into master Dec 2, 2025
15 of 16 checks passed
@miladz68 miladz68 deleted the milad/pse-distribution-integration-test branch December 2, 2025 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants