-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Use parameter_types instead of thread_local for test-setup #12036
Conversation
The CI pipeline was cancelled due to failure one of the required jobs. |
The CI pipeline was cancelled due to failure one of the required jobs. |
The CI pipeline was cancelled due to failure one of the required jobs. |
The CI pipeline was cancelled due to failure one of the required jobs. |
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.
Good direction, but:
- naming needs fixing
- Please add https://github.com/paritytech/substrate/pull/12002/files#diff-31d6476b566f793c17f32f9fdefeb487988af58c61ba752d0275b91f6c8aaccaR433 to your PR and use it instead of
:get
and:set
when appropriate
Co-authored-by: Kian Paimani <[email protected]>
The CI pipeline was cancelled due to failure one of the required jobs. |
The CI pipeline was cancelled due to failure one of the required jobs. |
The CI pipeline was cancelled due to failure one of the required jobs. |
The CI pipeline was cancelled due to failure one of the required jobs. |
The CI pipeline was cancelled due to failure one of the required jobs. |
The CI pipeline was cancelled due to failure one of the required jobs. |
The CI pipeline was cancelled due to failure one of the required jobs. |
The CI pipeline was cancelled due to failure one of the required jobs. |
frame/im-online/src/tests.rs
Outdated
@@ -96,7 +97,8 @@ fn should_report_offline_validators() { | |||
advance_session(); | |||
|
|||
// then | |||
let offences = OFFENCES.with(|l| l.replace(vec![])); | |||
let offences = OFFENCES::get(); |
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.
Not applied yet?
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.
On it.
frame/im-online/src/tests.rs
Outdated
let offences = OFFENCES::get(); | ||
OFFENCES::mutate(|l| l.clear()); |
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.
let offences = OFFENCES::get(); | |
OFFENCES::mutate(|l| l.clear()); | |
let offences = Offences::take(); |
frame/offences/src/mock.rs
Outdated
pub static ON_OFFENCE_PERBILL: RefCell<Vec<Perbill>> = RefCell::new(Default::default()); | ||
pub static OFFENCE_WEIGHT: RefCell<Weight> = RefCell::new(Default::default()); | ||
parameter_types! { | ||
pub static OnOffencePerBill: Vec<Perbill> = Default::default(); |
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.
pub static OnOffencePerBill: Vec<Perbill> = Default::default(); | |
pub static OnOffencePerbill: Vec<Perbill> = Default::default(); |
frame/offences/src/mock.rs
Outdated
@@ -58,16 +57,16 @@ impl<Reporter, Offender> offence::OnOffenceHandler<Reporter, Offender, Weight> | |||
_offence_session: SessionIndex, | |||
_disable_strategy: DisableStrategy, | |||
) -> Weight { | |||
ON_OFFENCE_PERBILL.with(|f| { | |||
*f.borrow_mut() = slash_fraction.to_vec(); | |||
OnOffencePerBill::mutate(|f| { |
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.
OnOffencePerBill::mutate(|f| { | |
OnOffencePerbill::mutate(|f| { |
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.
LGTM modulo some last nits, please make sure all open comments are addressed.
/tip large |
@kianenigma A large tip was successfully submitted for tifecool (1s51dYXziQwTnSnModErKfra3TeEsVipqzY846CLCTEXtHJ on polkadot). https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frpc.polkadot.io#/treasury/tips |
Wow. Really appreciate the tip! Will round up immediately ❤️ |
@tifecool please merge master |
@athei please review |
The Let's do @bkchr's suggestion in #12036 (comment) and use Please document this in the |
Ok, let me try. |
#[derive(Default)] | ||
struct MockLoader { | ||
#[derive(Default, Clone)] | ||
pub struct MockLoader { |
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.
Why does it need to be public?
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.
parameter_types requires it
#[derive(Default, Debug, PartialEq, Eq)] | ||
struct TestExt { | ||
#[derive(Default, Debug, PartialEq, Eq, Clone)] | ||
pub struct TestExt { |
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.
Why does it need to be public?
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.
parameter_types requires it
Are we sure this closes #10479 too? |
bot merge |
Waiting for commit status. |
It still uses thread local under the hood. So I don't think so. |
…h#12036) * Edit to Assets. parameter_types * fixes * Test Fixes. WIP * Edits to pallet-aura * Camel Case Co-authored-by: Kian Paimani <[email protected]> * Implementation of mutate fn * update to pallet-aura * Update to frame-system. Fixes * Update to frame-support-test. CamelCases * Updates to frame- contracts, offences, staking, bounties, child bounties * Edit to mutate fn. Changes to frame-contracts. CamelCase pallet-aura * Edits to frame-contracts & executive * cargo +nightly fmt * unused import removed * unused import removed * cargo +nightly fmt * minor adjustment * updates * updates * cargo +nightly fmt * cargo +nightly fmt * take fn implemented * update * update * Fixes to CallFilter * cargo +nightly fmt * final fixes * Default changed to $value * Update frame/support/src/lib.rs Co-authored-by: Kian Paimani <[email protected]>
PR for: #12020
WIP
Fixes: #12020
might close: #10479
polkadot address: 1s51dYXziQwTnSnModErKfra3TeEsVipqzY846CLCTEXtHJ