mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 20:31:13 +00:00
Use parameter_types instead of thread_local for test-setup (#12036)
* Edit to Assets. parameter_types * fixes * Test Fixes. WIP * Edits to pallet-aura * Camel Case Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * 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 <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -835,12 +835,12 @@ mod tests {
|
||||
pub struct RuntimeVersion;
|
||||
impl frame_support::traits::Get<sp_version::RuntimeVersion> for RuntimeVersion {
|
||||
fn get() -> sp_version::RuntimeVersion {
|
||||
RUNTIME_VERSION.with(|v| v.borrow().clone())
|
||||
RuntimeVersionTestValues::get().clone()
|
||||
}
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
pub static RUNTIME_VERSION: std::cell::RefCell<sp_version::RuntimeVersion> =
|
||||
parameter_types! {
|
||||
pub static RuntimeVersionTestValues: sp_version::RuntimeVersion =
|
||||
Default::default();
|
||||
}
|
||||
|
||||
@@ -1239,14 +1239,13 @@ mod tests {
|
||||
#[test]
|
||||
fn runtime_upgraded_should_work() {
|
||||
new_test_ext(1).execute_with(|| {
|
||||
RUNTIME_VERSION.with(|v| *v.borrow_mut() = Default::default());
|
||||
RuntimeVersionTestValues::mutate(|v| *v = Default::default());
|
||||
// It should be added at genesis
|
||||
assert!(frame_system::LastRuntimeUpgrade::<Runtime>::exists());
|
||||
assert!(!Executive::runtime_upgraded());
|
||||
|
||||
RUNTIME_VERSION.with(|v| {
|
||||
*v.borrow_mut() =
|
||||
sp_version::RuntimeVersion { spec_version: 1, ..Default::default() }
|
||||
RuntimeVersionTestValues::mutate(|v| {
|
||||
*v = sp_version::RuntimeVersion { spec_version: 1, ..Default::default() }
|
||||
});
|
||||
assert!(Executive::runtime_upgraded());
|
||||
assert_eq!(
|
||||
@@ -1254,8 +1253,8 @@ mod tests {
|
||||
frame_system::LastRuntimeUpgrade::<Runtime>::get(),
|
||||
);
|
||||
|
||||
RUNTIME_VERSION.with(|v| {
|
||||
*v.borrow_mut() = sp_version::RuntimeVersion {
|
||||
RuntimeVersionTestValues::mutate(|v| {
|
||||
*v = sp_version::RuntimeVersion {
|
||||
spec_version: 1,
|
||||
spec_name: "test".into(),
|
||||
..Default::default()
|
||||
@@ -1267,8 +1266,8 @@ mod tests {
|
||||
frame_system::LastRuntimeUpgrade::<Runtime>::get(),
|
||||
);
|
||||
|
||||
RUNTIME_VERSION.with(|v| {
|
||||
*v.borrow_mut() = sp_version::RuntimeVersion {
|
||||
RuntimeVersionTestValues::mutate(|v| {
|
||||
*v = sp_version::RuntimeVersion {
|
||||
spec_version: 1,
|
||||
spec_name: "test".into(),
|
||||
impl_version: 2,
|
||||
@@ -1316,9 +1315,8 @@ mod tests {
|
||||
fn custom_runtime_upgrade_is_called_before_modules() {
|
||||
new_test_ext(1).execute_with(|| {
|
||||
// Make sure `on_runtime_upgrade` is called.
|
||||
RUNTIME_VERSION.with(|v| {
|
||||
*v.borrow_mut() =
|
||||
sp_version::RuntimeVersion { spec_version: 1, ..Default::default() }
|
||||
RuntimeVersionTestValues::mutate(|v| {
|
||||
*v = sp_version::RuntimeVersion { spec_version: 1, ..Default::default() }
|
||||
});
|
||||
|
||||
Executive::initialize_block(&Header::new(
|
||||
@@ -1338,9 +1336,8 @@ mod tests {
|
||||
fn event_from_runtime_upgrade_is_included() {
|
||||
new_test_ext(1).execute_with(|| {
|
||||
// Make sure `on_runtime_upgrade` is called.
|
||||
RUNTIME_VERSION.with(|v| {
|
||||
*v.borrow_mut() =
|
||||
sp_version::RuntimeVersion { spec_version: 1, ..Default::default() }
|
||||
RuntimeVersionTestValues::mutate(|v| {
|
||||
*v = sp_version::RuntimeVersion { spec_version: 1, ..Default::default() }
|
||||
});
|
||||
|
||||
// set block number to non zero so events are not excluded
|
||||
@@ -1369,9 +1366,8 @@ mod tests {
|
||||
|
||||
let header = new_test_ext(1).execute_with(|| {
|
||||
// Make sure `on_runtime_upgrade` is called.
|
||||
RUNTIME_VERSION.with(|v| {
|
||||
*v.borrow_mut() =
|
||||
sp_version::RuntimeVersion { spec_version: 1, ..Default::default() }
|
||||
RuntimeVersionTestValues::mutate(|v| {
|
||||
*v = sp_version::RuntimeVersion { spec_version: 1, ..Default::default() }
|
||||
});
|
||||
|
||||
// Let's build some fake block.
|
||||
@@ -1389,15 +1385,14 @@ mod tests {
|
||||
});
|
||||
|
||||
// Reset to get the correct new genesis below.
|
||||
RUNTIME_VERSION.with(|v| {
|
||||
*v.borrow_mut() = sp_version::RuntimeVersion { spec_version: 0, ..Default::default() }
|
||||
RuntimeVersionTestValues::mutate(|v| {
|
||||
*v = sp_version::RuntimeVersion { spec_version: 0, ..Default::default() }
|
||||
});
|
||||
|
||||
new_test_ext(1).execute_with(|| {
|
||||
// Make sure `on_runtime_upgrade` is called.
|
||||
RUNTIME_VERSION.with(|v| {
|
||||
*v.borrow_mut() =
|
||||
sp_version::RuntimeVersion { spec_version: 1, ..Default::default() }
|
||||
RuntimeVersionTestValues::mutate(|v| {
|
||||
*v = sp_version::RuntimeVersion { spec_version: 1, ..Default::default() }
|
||||
});
|
||||
|
||||
<Executive as ExecuteBlock<Block<TestXt>>>::execute_block(Block::new(header, vec![xt]));
|
||||
@@ -1411,9 +1406,8 @@ mod tests {
|
||||
fn all_weights_are_recorded_correctly() {
|
||||
new_test_ext(1).execute_with(|| {
|
||||
// Make sure `on_runtime_upgrade` is called for maximum complexity
|
||||
RUNTIME_VERSION.with(|v| {
|
||||
*v.borrow_mut() =
|
||||
sp_version::RuntimeVersion { spec_version: 1, ..Default::default() }
|
||||
RuntimeVersionTestValues::mutate(|v| {
|
||||
*v = sp_version::RuntimeVersion { spec_version: 1, ..Default::default() }
|
||||
});
|
||||
|
||||
let block_number = 1;
|
||||
|
||||
Reference in New Issue
Block a user