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

time-release mock and unit tests should match runtime configuration #1861

Merged

Conversation

mattheworris
Copy link
Collaborator

@mattheworris mattheworris commented Jan 30, 2024

Goal

The goal of this PR is to update the time-release mock so the the MinReleaseTransfer matches the value in the runtime configuration.

This may cause follow on failures in some of the unit tests.

Closes #1836

Changes

  • MinReleaseTransfer updated to 0
  • Unit tests updated
  • .vscode/settings.json updated to include more targets for better feature coverage

How to Test

  • Confirm time-release unit tests pass

Checklist

  • Chain spec updated [not needed: no runtime changes]
  • Custom RPC OR Runtime API added/changed? Updated js/api-augment.
  • Design doc(s) updated
  • Tests added
  • Benchmarks added
  • Weights updated

@mattheworris mattheworris linked an issue Jan 30, 2024 that may be closed by this pull request
@@ -16,8 +16,8 @@ pub type Schedule<T> = ReleaseSchedule<BlockNumberFor<T>, BalanceOf<T>>;
const SEED: u32 = 0;

fn set_balance<T: Config>(who: &T::AccountId, balance: BalanceOf<T>) {
let actual_deposit = T::Currency::mint_into(&who, balance.saturated_into());
assert_eq!(balance, actual_deposit.unwrap());
let actual_deposit = T::Currency::set_balance(&who, balance.saturated_into());
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

mint_into fails when the account has a 0 balance.
set_balance is infallible and provided by polkadot-sdk specifically for benchmarking and testing.

@@ -15,9 +15,12 @@
],
// Set the features to use for cargo commands
"rust-analyzer.cargo.features": [
"frequency-no-relay"
"frequency-no-relay",
"runtime-benchmarks",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Adding these targets to cover more code, e.g. benchmarking.rs files do not know about any definitions if runtime-benchmarks is not defined.

@mattheworris mattheworris force-pushed the 1836-time-release-pallet-mock-and-unit-test-need-updates branch from 2672522 to a08ed4f Compare January 30, 2024 23:01
Copy link

codecov bot commented Jan 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (06c726d) 82.95% compared to head (3a12faa) 82.95%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1861   +/-   ##
=======================================
  Coverage   82.95%   82.95%           
=======================================
  Files          56       56           
  Lines        4552     4552           
=======================================
  Hits         3776     3776           
  Misses        776      776           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mattheworris mattheworris changed the title fix: Update Rust Analyzer settings and fix balance setting bug time-release mock and unit tests should match runtime configuration Jan 31, 2024
@mattheworris mattheworris self-assigned this Jan 31, 2024
Matthew Orris and others added 4 commits February 1, 2024 08:44
@mattheworris mattheworris requested a review from a team February 2, 2024 16:24
@mattheworris mattheworris force-pushed the 1836-time-release-pallet-mock-and-unit-test-need-updates branch from 3eb3dca to 3a12faa Compare February 2, 2024 16:31
@mattheworris mattheworris marked this pull request as ready for review February 2, 2024 16:33
@mattheworris mattheworris requested a review from wilwade as a code owner February 2, 2024 16:33
Copy link
Collaborator

@JoeCap08055 JoeCap08055 left a comment

Choose a reason for hiding this comment

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

Ran unit tests locally; all passed

Copy link
Collaborator

@enddynayn enddynayn left a comment

Choose a reason for hiding this comment

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

Looks great! 👍

@mattheworris mattheworris merged commit 64fcc78 into main Feb 5, 2024
30 checks passed
@mattheworris mattheworris deleted the 1836-time-release-pallet-mock-and-unit-test-need-updates branch February 5, 2024 21:33
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.

time-release pallet mock and unit test need updates
5 participants