Skip to content
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

Pallet Unit Tests concerning Balances: Modify mock.rs to have ED > 1, to test balances less than ED. #1852

Open
2 tasks
mattheworris opened this issue Jan 23, 2024 · 2 comments
Labels

Comments

@mattheworris
Copy link
Collaborator

As a developer, I would like to create some unit tests for situations when the account balance is less than the Existential Deposit (ED).

Currently, the mocks has ED == 1, so it is not possible to test any situations where ED < 1, which some valid edge cases do exist.

  • Modify mock.rs to have ED > 1
  • Modify unit tests that are affected by this change.
@p5150j p5150j added tech-debt good first issue Good for newcomers labels Jan 24, 2024
@Aideepakchaudhary
Copy link

@mattheworris Can you please elaborate this issue? like for which pallet you need to update. In todo, i think the condition should be ED < 1.

@mattheworris
Copy link
Collaborator Author

mattheworris commented Jun 24, 2024

@Aideepakchaudhary
Yes, this issue concerns the capacity and time-release pallets which use the fungible trait to freeze tokens. The issue was created while working on #1779, #1818, and #1873.

Here, the Existential Deposit (ED) for ‎Test::ExistentialDeposit is set to 1. mock.rs defines Test as a simplified version of the pallet used for unit testing.

On testnet/mainnet, ED is set to a larger number = 1_000_000.

Therefore, there are valid scenarios on testnet/mainnet that can result in an account balance that is below ED but greater than 0.

Currently, it is not possible to use mock.rs and Test::ExistentialDeposit to test this scenario, as the only value less than ED in mock.rs is 0.

If Test::ExistentialDeposit is changed to a larger value, e.g. 10, it would allow unit tests to create a scenario where 0 < account_balance < ED.

However, this may also break the logic for the existing tests with ED == 1 and those tests would need to be updated to use the larger ED value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants