Skip to content

Commit 05b4304

Browse files
Properly run on_runtime_upgrade in tests
1 parent 7e49225 commit 05b4304

9 files changed

Lines changed: 55 additions & 19 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/pallet-balanced-currency-swap-bridges-initializer/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ sp-std = { workspace = true }
1414
[dev-dependencies]
1515
pallet-pot = { path = "../pallet-pot", default-features = false }
1616

17+
frame-executive = { workspace = true, features = ["default"] }
1718
pallet-balances = { workspace = true }
1819
sp-core = { workspace = true }
1920

2021
[features]
2122
default = ["std"]
2223
std = [
2324
"codec/std",
25+
"frame-executive/std",
2426
"frame-support/std",
2527
"frame-system/std",
2628
"pallet-balances/std",
@@ -30,6 +32,7 @@ std = [
3032
"sp-std/std",
3133
]
3234
try-runtime = [
35+
"frame-executive/try-runtime",
3336
"frame-support/try-runtime",
3437
"frame-system/try-runtime",
3538
"pallet-balances/try-runtime",

crates/pallet-balanced-currency-swap-bridges-initializer/src/mock/v1.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ use frame_support::{
1515
use sp_core::{ConstU16, H256};
1616

1717
use super::*;
18+
use crate::UpgradeInit;
1819

1920
pub(crate) const FORCE_REBALANCE_ASK_COUNTER: u16 = 0;
2021

21-
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
22-
type Block = frame_system::mocking::MockBlock<Test>;
22+
type UncheckedExtrinsic =
23+
frame_support::sp_runtime::testing::TestXt<RuntimeCall, frame_system::CheckEra<Test>>;
24+
type Block = frame_support::sp_runtime::testing::Block<UncheckedExtrinsic>;
2325

2426
frame_support::construct_runtime!(
2527
pub struct Test
@@ -144,3 +146,12 @@ impl pallet_balanced_currency_swap_bridges_initializer::Config for Test {
144146
type ForceRebalanceAskCounter = ConstU16<FORCE_REBALANCE_ASK_COUNTER>;
145147
type WeightInfo = ();
146148
}
149+
150+
pub(crate) type Executive = frame_executive::Executive<
151+
Test,
152+
Block,
153+
frame_system::ChainContext<Test>,
154+
Test,
155+
AllPalletsWithSystem,
156+
UpgradeInit<Test>,
157+
>;

crates/pallet-balanced-currency-swap-bridges-initializer/src/mock/v2.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ use sp_core::{ConstU16, H256};
1717
pub(crate) const FORCE_REBALANCE_ASK_COUNTER: u16 = 1;
1818

1919
use super::*;
20+
use crate::UpgradeInit;
2021

21-
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
22-
type Block = frame_system::mocking::MockBlock<Test>;
22+
type UncheckedExtrinsic =
23+
frame_support::sp_runtime::testing::TestXt<RuntimeCall, frame_system::CheckEra<Test>>;
24+
type Block = frame_support::sp_runtime::testing::Block<UncheckedExtrinsic>;
2325

2426
frame_support::construct_runtime!(
2527
pub struct Test
@@ -144,3 +146,12 @@ impl pallet_balanced_currency_swap_bridges_initializer::Config for Test {
144146
type ForceRebalanceAskCounter = ConstU16<FORCE_REBALANCE_ASK_COUNTER>;
145147
type WeightInfo = ();
146148
}
149+
150+
pub(crate) type Executive = frame_executive::Executive<
151+
Test,
152+
Block,
153+
frame_system::ChainContext<Test>,
154+
Test,
155+
AllPalletsWithSystem,
156+
UpgradeInit<Test>,
157+
>;

crates/pallet-balanced-currency-swap-bridges-initializer/src/tests.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
use frame_support::{
2-
assert_storage_noop,
3-
traits::{Currency, OnRuntimeUpgrade},
4-
};
1+
use frame_support::{assert_storage_noop, traits::Currency};
52

63
use crate::{
74
mock::{new_test_ext_with, v0, v1, v2, with_runtime_lock, *},
8-
swappable_balance, LastForceRebalanceAskCounter, LastInitializerVersion, UpgradeInit,
5+
swappable_balance, LastForceRebalanceAskCounter, LastInitializerVersion,
96
};
107

118
/// This test verifies that balanced bridges initialization works in case bridge pot accounts
@@ -411,7 +408,7 @@ fn runtime_upgrade() {
411408
assert_eq!(<LastForceRebalanceAskCounter<v1::Test>>::get(), 0);
412409

413410
// Do runtime upgrade hook.
414-
UpgradeInit::<v1::Test>::on_runtime_upgrade();
411+
v1::Executive::execute_on_runtime_upgrade();
415412

416413
// Verify bridges initialization result.
417414
assert_eq!(
@@ -457,7 +454,7 @@ fn runtime_upgrade() {
457454
v2::EvmBalances::total_balance(&v2::SwapBridgeEvmToNativePot::account_id());
458455

459456
// Do runtime upgrade hook.
460-
UpgradeInit::<v2::Test>::on_runtime_upgrade();
457+
v2::Executive::execute_on_runtime_upgrade();
461458

462459
// Verify result.
463460
assert_eq!(

crates/pallet-dummy-precompiles-code/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ sp-core = { workspace = true }
1414

1515
[dev-dependencies]
1616
fp-evm = { workspace = true }
17+
frame-executive = { workspace = true, features = ["default"] }
1718
hex-literal = { workspace = true }
1819
pallet-balances = { workspace = true, features = ["default"] }
1920
pallet-evm-balances = { workspace = true, features = ["default"] }
@@ -25,6 +26,7 @@ default = ["std"]
2526
std = [
2627
"codec/std",
2728
"fp-evm/std",
29+
"frame-executive/std",
2830
"frame-support/std",
2931
"frame-system/std",
3032
"pallet-balances/std",
@@ -36,6 +38,7 @@ std = [
3638
"sp-core/std",
3739
]
3840
try-runtime = [
41+
"frame-executive/try-runtime",
3942
"frame-support/try-runtime",
4043
"frame-system/try-runtime",
4144
"pallet-balances/try-runtime",

crates/pallet-dummy-precompiles-code/src/mock/v1.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ use frame_support::{
1515
use sp_core::{ConstU16, H256, U256};
1616

1717
use super::*;
18-
use crate::{self as pallet_dummy_precompiles_code};
18+
use crate::{self as pallet_dummy_precompiles_code, UpgradeInit};
1919

20-
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
21-
type Block = frame_system::mocking::MockBlock<Test>;
20+
type UncheckedExtrinsic =
21+
frame_support::sp_runtime::testing::TestXt<RuntimeCall, frame_system::CheckEra<Test>>;
22+
type Block = frame_support::sp_runtime::testing::Block<UncheckedExtrinsic>;
2223

2324
pub(crate) type AccountId = u64;
2425
pub(crate) type EvmAccountId = H160;
@@ -165,3 +166,12 @@ impl pallet_dummy_precompiles_code::Config for Test {
165166
type PrecompilesAddresses = PrecompilesAddresses;
166167
type ForceExecuteAskCounter = ConstU16<0>;
167168
}
169+
170+
pub(crate) type Executive = frame_executive::Executive<
171+
Test,
172+
Block,
173+
frame_system::ChainContext<Test>,
174+
Test,
175+
AllPalletsWithSystem,
176+
UpgradeInit<Test>,
177+
>;

crates/pallet-dummy-precompiles-code/src/tests.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use frame_support::traits::OnRuntimeUpgrade;
2-
3-
use crate::{mock::*, UpgradeInit, DUMMY_CODE};
1+
use crate::{mock::*, DUMMY_CODE};
42

53
/// This test verifies that genesis initialization properly assigns the state.
64
#[test]
@@ -46,8 +44,8 @@ fn runtime_upgrade() {
4644
0
4745
);
4846

49-
// Do runtime upgrade hook.
50-
UpgradeInit::<v1::Test>::on_runtime_upgrade();
47+
// // Do runtime upgrade hook.
48+
v1::Executive::execute_on_runtime_upgrade();
5149

5250
// Verify precompiles addresses creation.
5351
for precompile_address in &v1::PrecompilesAddresses::get() {

utils/checks/snapshots/features.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,7 @@
11091109
- rocksdb
11101110
- name: frame-executive 4.0.0-dev
11111111
features:
1112+
- default
11121113
- std
11131114
- name: frame-metadata 15.1.0
11141115
features:

0 commit comments

Comments
 (0)