Skip to content

PSE upgrade integration test#40

Merged
TxCorpi0x merged 12 commits into
masterfrom
mehdi/pse-upgrade-test
Dec 2, 2025
Merged

PSE upgrade integration test#40
TxCorpi0x merged 12 commits into
masterfrom
mehdi/pse-upgrade-test

Conversation

@TxCorpi0x

@TxCorpi0x TxCorpi0x commented Nov 28, 2025

Copy link
Copy Markdown
Contributor

Description

This pull request updates the PSE initial fund allocation and distribution schedule to start one month after the v6 upgrade, rather than on the upgrade day itself. It also introduces a new integration test to verify the correctness of the initial distribution logic and updates documentation to reflect the new schedule. The most important changes are grouped below.

Core logic changes:

  • The distribution schedule now starts at 12:00 GMT one month after the upgrade date, instead of on the upgrade day. This affects both the calculation of the start timestamp and the calendar month arithmetic in app/upgrade/v6/pse_init.go.

Test updates:

  • All relevant unit tests in app/upgrade/v6/pse_init_test.go have been updated to expect the first distribution to occur one month after the upgrade, including timestamp calculations, assertions, and test descriptions.

Integration testing:

  • A new integration test integration-tests/upgrade/pse_initial_distribution.go has been added to verify initial fund allocations, distribution schedule, clearing account mappings, and balances after upgrade. This test is now included in the upgrade test suite.

Documentation updates:

  • The PSE module specification in x/pse/spec/README.md has been updated to state that distributions begin one month after the upgrade, not on the upgrade day.

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

@TxCorpi0x TxCorpi0x requested a review from a team as a code owner November 28, 2025 10:07
@TxCorpi0x TxCorpi0x requested review from masihyeganeh, miladz68 and ysv and removed request for a team November 28, 2025 10:07

@miladz68 miladz68 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.

@miladz68 reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @masihyeganeh and @ysv)


integration-tests/upgrade/pse_initial_distribution.go line 53 at r1 (raw file):

		})
		requireT.NoError(err)
		pid.clearingAccountBefore[clearingAccount] = *balanceResp.Balance

all clearing balances before must be zero, there is not point tracking it. just assert that they are zero.


integration-tests/upgrade/pse_initial_distribution.go line 207 at r1 (raw file):

		currentTime := time.Unix(int64(period.Timestamp), 0).UTC()

		requireT.Equal(1, currentTime.Day(),

this assertion will not be true anymore.

@TxCorpi0x TxCorpi0x 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: 1 of 2 files reviewed, 2 unresolved discussions (waiting on @masihyeganeh, @miladz68, and @ysv)


integration-tests/upgrade/pse_initial_distribution.go line 53 at r1 (raw file):

Previously, miladz68 (milad) wrote…

all clearing balances before must be zero, there is not point tracking it. just assert that they are zero.

The module accounts have value in the beginning, they are created by znet, and this is an integration test.


integration-tests/upgrade/pse_initial_distribution.go line 207 at r1 (raw file):

Previously, miladz68 (milad) wrote…

this assertion will not be true anymore.

NEw logic merged and Fixed.

@miladz68 miladz68 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.

@miladz68 reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @masihyeganeh, @TxCorpi0x, and @ysv)


integration-tests/upgrade/pse_initial_distribution.go line 53 at r1 (raw file):

Previously, TxCorpi0x wrote…

The module accounts have value in the beginning, they are created by znet, and this is an integration test.

before upgrade, we start with cored-v5.0.0 binary.

@TxCorpi0x TxCorpi0x 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: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @masihyeganeh, @miladz68, and @ysv)


integration-tests/upgrade/pse_initial_distribution.go line 53 at r1 (raw file):

Previously, miladz68 (milad) wrote…

before upgrade, we start with cored-v5.0.0 binary.

Done

miladz68
miladz68 previously approved these changes Dec 2, 2025

@miladz68 miladz68 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.

@miladz68 reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all 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 1 of 2 files at r1, 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @masihyeganeh and @TxCorpi0x)


integration-tests/upgrade/pse_initial_distribution.go line 148 at r3 (raw file):

		// 3. Amount already distributed
		alreadyDistributed := monthlyAmount.MulRaw(int64(processedDistributions))

but this will always be eq to 0 right after upgrade, isn't it ?

Code quote:

		// 3. Amount already distributed
		alreadyDistributed := monthlyAmount.MulRaw(int64(processedDistributions))

integration-tests/upgrade/pse_initial_distribution.go line 182 at r3 (raw file):

	t.Logf("Total actual balance: %s", totalActualBalance)

	return allocations

do we really need to return this if we never use it ?


integration-tests/upgrade/pse_initial_distribution.go line 200 at r3 (raw file):

	t.Logf("Distribution schedule created with %d periods", len(schedule))
	return schedule

do we really need to return this if we never use it ?


integration-tests/upgrade/pse_initial_distribution.go line 220 at r3 (raw file):

	// Verify all distributions are on the same day of the month at 12:00:00 GMT
	expectedDay := firstDistTime.Day()

will this will fail if we run test on 29-31 day of the month ?

@TxCorpi0x TxCorpi0x 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, 4 unresolved discussions (waiting on @masihyeganeh and @ysv)


integration-tests/upgrade/pse_initial_distribution.go line 148 at r3 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

but this will always be eq to 0 right after upgrade, isn't it ?

You are right, removed.


integration-tests/upgrade/pse_initial_distribution.go line 182 at r3 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

do we really need to return this if we never use it ?

Please check the lines 74-78 in After, it has been used there.


integration-tests/upgrade/pse_initial_distribution.go line 200 at r3 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

do we really need to return this if we never use it ?

Please check the lines 74-78 in After, it has been used there.


integration-tests/upgrade/pse_initial_distribution.go line 220 at r3 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

will this will fail if we run test on 29-31 day of the month ?

No, the pse initialization caps the days to 28, so after upgrade, event if the day is 29, 30, or 31st, it won't fail

TxCorpi0x and others added 6 commits December 2, 2025 16:16
* PSE start time on upgrade time day start UTC

* Set distribution schedules duration as 30days

* Change start time to 12:00 GMT on 28th of month

* Rename period to month in PSE init
* added some wait time to pse upgrade test

* fix a comment

* changed the wait logic

* fix linter

* Merge branch 'master' into milad/add-wait-pse-upgrade-test
* ClI Query for clearing accounts and schedule

* PSE queries integration tests

* Merge branch 'master' into mehdi/pse-query-cli

* Merge branch 'master' into mehdi/pse-query-cli

* Resolve comments

* Lint fix

* Merge branch 'master' into mehdi/pse-query-cli

* Fix conflicts

* Merge branch 'master' into mehdi/pse-query-cli
@TxCorpi0x TxCorpi0x force-pushed the mehdi/pse-upgrade-test branch from b79b9f9 to 29e09ad Compare December 2, 2025 13:16

@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 all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @masihyeganeh and @TxCorpi0x)


integration-tests/upgrade/pse_initial_distribution.go line 148 at r3 (raw file):

Previously, TxCorpi0x wrote…

You are right, removed.

still visible in the last committed version

@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 r5, 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 Author

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @masihyeganeh)


integration-tests/upgrade/pse_initial_distribution.go line 148 at r3 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

still visible in the last committed version

I was force pushed to remove an older commit, rebased with master with the other PR

@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.

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @masihyeganeh)

@miladz68 miladz68 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.

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

@TxCorpi0x TxCorpi0x merged commit 6961848 into master Dec 2, 2025
9 checks passed
@ysv ysv deleted the mehdi/pse-upgrade-test branch December 19, 2025 14:41
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