-
Notifications
You must be signed in to change notification settings - Fork 52
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
Reward block author in Dancelight #784
Open
tmpolaczyk
wants to merge
7
commits into
master
Choose a base branch
from
tomasz-reward-block-author
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
edba9ec
Reward block author in Dancelight
tmpolaczyk 8ec3aa9
Add reward test no candidates
tmpolaczyk 4397e33
Fix tests
tmpolaczyk 5932006
Merge branch 'master' into tomasz-reward-block-author
tmpolaczyk d8d1d47
Check points per block in test
tmpolaczyk a8c9529
Merge remote-tracking branch 'origin/master' into tomasz-reward-block…
tmpolaczyk 3771ec5
Merge branch 'master' into tomasz-reward-block-author
tmpolaczyk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...dev-tanssi-relay/external-validators-rewards/test_external_validator_reward_candidates.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import "@tanssi/api-augment"; | ||
import { describeSuite, customDevRpcRequest, expect, beforeAll } from "@moonwall/cli"; | ||
import { ApiPromise, Keyring } from "@polkadot/api"; | ||
import { jumpToSession } from "util/block"; | ||
|
||
describeSuite({ | ||
id: "DTR1601", | ||
title: "Paras inherent tests", | ||
foundationMethods: "dev", | ||
|
||
testCases: ({ it, context }) => { | ||
let polkadotJs: ApiPromise; | ||
|
||
beforeAll(async () => { | ||
polkadotJs = context.polkadotJs(); | ||
}); | ||
|
||
it({ | ||
id: "E01", | ||
title: "para candidates should trigger reward info", | ||
test: async function () { | ||
const keyring = new Keyring({ type: "sr25519" }); | ||
const aliceStash = keyring.addFromUri("//Alice//stash"); | ||
await context.createBlock(); | ||
// Send RPC call to enable para inherent candidate generation | ||
await customDevRpcRequest("mock_enableParaInherentCandidate", []); | ||
// Since collators are not assigned until session 2, we need to go till session 2 to actually see heads being injected | ||
await jumpToSession(context, 3); | ||
await context.createBlock(); | ||
|
||
// we are still in era 0 | ||
const validatorRewards = await context | ||
.polkadotJs() | ||
.query.externalValidatorsRewards.rewardPointsForEra(0); | ||
const totalRewards = validatorRewards.total.toBigInt(); | ||
|
||
// Validators get 20 points for creating a block, so if they included a candidate, they will get more than 20 | ||
expect(totalRewards).to.be.greaterThan(20n); | ||
// All of them come from alice as she is the only one validating candidates | ||
expect(validatorRewards.individual.toHuman()[aliceStash.address]).to.be.eq(totalRewards.toString()); | ||
}, | ||
}); | ||
|
||
it({ | ||
id: "E02", | ||
title: "Check rewards storage clears after historyDepth", | ||
test: async function () { | ||
const sessionsPerEra = await polkadotJs.consts.externalValidators.sessionsPerEra; | ||
const historyDepth = await polkadotJs.consts.externalValidatorsRewards.historyDepth; | ||
|
||
const currentIndex = await polkadotJs.query.session.currentIndex(); | ||
|
||
const targetSession = | ||
currentIndex.toNumber() + sessionsPerEra.toNumber() * (historyDepth.toNumber() + 1); | ||
|
||
await jumpToSession(context, targetSession); | ||
|
||
const validatorRewards = await context | ||
.polkadotJs() | ||
.query.externalValidatorsRewards.rewardPointsForEra(0); | ||
const totalRewards = validatorRewards.total.toBigInt(); | ||
|
||
// rewards should have expired | ||
expect(totalRewards).to.be.equal(0n); | ||
}, | ||
}); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait they get 20 per candidate and per block created. So you will always have higher than 20?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess if so, you need to check the rewards
totalRewards > num_blocks*20