Add integration test for pse community distribution#39
Conversation
TxCorpi0x
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
@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
left a comment
There was a problem hiding this comment.
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 usedelegateAmount * (i+1)so we have 100, 200, 300TX delegated
Also tovalidatorsResponse.Validators[i % len(validatorsResponse.Validators)]to delegate to different validatorsor 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 {orfor 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 useInDeltaassertion becauseInEpsilonmight 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:
DistributionsDisabledLet me know if you prefer it (can be renamed in a separate task)
Also we should probably be able to change this param totruevia 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
left a comment
There was a problem hiding this comment.
@ysv reviewed 4 of 4 files at r4, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @masihyeganeh)
TxCorpi0x
left a comment
There was a problem hiding this comment.
@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:complete! all files reviewed, all discussions resolved (waiting on @masihyeganeh)
ysv
left a comment
There was a problem hiding this comment.
@ysv reviewed 3 of 4 files at r5, 1 of 1 files at r6, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @masihyeganeh)
TxCorpi0x
left a comment
There was a problem hiding this comment.
@TxCorpi0x reviewed all commit messages.
Reviewable status: 21 of 22 files reviewed, all discussions resolved (waiting on @masihyeganeh)
ysv
left a comment
There was a problem hiding this comment.
@ysv reviewed 1 of 1 files at r7, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @masihyeganeh)
Description
Reviewers checklist:
Authors checklist
This change is