Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Test case not working as expected: nominators_also_get_slashed #5838

Closed
maxsam4 opened this issue Apr 30, 2020 · 5 comments · Fixed by #5952
Closed

Test case not working as expected: nominators_also_get_slashed #5838

maxsam4 opened this issue Apr 30, 2020 · 5 comments · Fixed by #5952
Assignees
Labels
I5-tests Tests need fixing, improving or augmenting.

Comments

@maxsam4
Copy link

maxsam4 commented Apr 30, 2020

The intent of

fn nominators_also_get_slashed() {

is to make sure that nominators also get slashed but in the test, nominator_slash is equal to 0 and the test is checking that a slash of 0 is applied which is equivalent of no slash at all.

In addition, the others vector in the validator's exposure is an empty array which suggests that no nominators are going to be slashed.

I'm not sure if it's just some misconfigured test case or a bug in the code but in any case, I don't think the test case is verifying what it was meant to verify.

@maxsam4 maxsam4 changed the title Test case not working as expectef: nominators_also_get_slashed Test case not working as expected: nominators_also_get_slashed Apr 30, 2020
@maxsam4
Copy link
Author

maxsam4 commented Apr 30, 2020

One problem I see is that the test is nominating the controller key of the validator instead of the stash key. If I change it to nominate the stash key then the others vector in the validator's exposure is populated correctly. However, nominator_slash is still zero. If I increase the slash_fraction to 105% so that the slash is greater than the validator's exposure, even then the validator gets slashed for 100% of their exposure but the nominator's balance does not decrease (and the test starts failing).

Here are the changes that I mentioned above: maxsam4@84b756c

With 105% slashing, the validator loses 100% of their stake, and the nominator loses 0% (test fails).
At 5% slashing, the validator loses 5% of their stake and the nominator loses 0% (test passes but it shouldn't).

@bkchr
Copy link
Member

bkchr commented Apr 30, 2020

CC @kianenigma

@kianenigma
Copy link
Contributor

I haven't looked into it in detail but it could very well be the case. Many of the staking tests are

  1. old
  2. not correctly wired together
  3. don't uphold ot their standard and similar to your example, even if their pre-condition is not met, the do not panic.

I'll take a look soon, thanks for raising it.

related: #5244


In addition, the others vector in the validator's exposure is an empty array which suggests that no nominators are going to be slashed.

Yeah in this case nominators don't even exist to be slashed.

I'm not sure if it's just some misconfigured test case or a bug in the code but in any case, I don't think the test case is verifying what it was meant to verify.

Most likely just a misconfiguration.

@kianenigma kianenigma self-assigned this Apr 30, 2020
@kianenigma kianenigma added the I5-tests Tests need fixing, improving or augmenting. label Apr 30, 2020
@maxsam4
Copy link
Author

maxsam4 commented May 7, 2020

Hey @kianenigma, did you get a chance to look at it?

@kianenigma
Copy link
Contributor

kianenigma commented May 7, 2020

Done, thanks for the reminder. Much needed 👍 .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
I5-tests Tests need fixing, improving or augmenting.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants