Skip to content

Commit

Permalink
chore: rename outer enums in tests
Browse files Browse the repository at this point in the history
Signed-off-by: Gregory Hill <gregorydhill@outlook.com>
  • Loading branch information
gregdhill committed Nov 11, 2022
1 parent 484df9b commit 000c333
Show file tree
Hide file tree
Showing 32 changed files with 102 additions and 105 deletions.
2 changes: 0 additions & 2 deletions crates/annuity/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ impl Config for Test {
type WeightInfo = ();
}

pub type TestEvent = RuntimeEvent;

pub struct ExtBuilder;

impl ExtBuilder {
Expand Down
2 changes: 0 additions & 2 deletions crates/clients-info/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ impl frame_system::Config for Test {
type MaxConsumers = frame_support::traits::ConstU32<16>;
}

pub type TestEvent = RuntimeEvent;

impl Config for Test {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = ();
Expand Down
4 changes: 2 additions & 2 deletions crates/collator-selection/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ macro_rules! whitelist {
};
}

fn assert_last_event<T: Config>(generic_event: <T as Config>::Event) {
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
let events = frame_system::Pallet::<T>::events();
let system_event: <T as frame_system::Config>::Event = generic_event.into();
let system_event: <T as frame_system::Config>::RuntimeEvent = generic_event.into();
// compare to the last event record
let EventRecord { event, .. } = &events[events.len() - 1];
assert_eq!(event, &system_event);
Expand Down
2 changes: 0 additions & 2 deletions crates/currency/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ parameter_types! {
pub const MinimumPeriod: Moment = 5;
}

pub type TestEvent = RuntimeEvent;

pub struct ExtBuilder;

impl ExtBuilder {
Expand Down
6 changes: 3 additions & 3 deletions crates/democracy/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const MAX_REFERENDUMS: u32 = 99;
const MAX_SECONDERS: u32 = 100;
const MAX_BYTES: u32 = 16_384;

fn assert_last_event<T: Config>(generic_event: <T as Config>::Event) {
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
frame_system::Pallet::<T>::assert_last_event(generic_event.into());
}

Expand Down Expand Up @@ -374,7 +374,7 @@ benchmarks! {
let b in 0 .. MAX_BYTES;

let proposer = funded_account::<T>("proposer", 0);
let raw_call = RuntimeCall::note_preimage { encoded_proposal: vec![1; b as usize] };
let raw_call = Call::note_preimage { encoded_proposal: vec![1; b as usize] };
let generic_call: T::Proposal = raw_call.into();
let encoded_proposal = generic_call.encode();
let proposal_hash = T::Hashing::hash(&encoded_proposal[..]);
Expand Down Expand Up @@ -406,7 +406,7 @@ benchmarks! {
_ => return Err("preimage not available".into())
}
let origin = RawOrigin::Root.into();
let call = RuntimeCall::<T>::enact_proposal { proposal_hash, index: 0 }.encode();
let call = Call::<T>::enact_proposal { proposal_hash, index: 0 }.encode();
}: {
assert_eq!(
<Call<T> as Decode>::decode(&mut &*call)
Expand Down
9 changes: 3 additions & 6 deletions crates/democracy/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,9 @@ frame_support::construct_runtime!(

// Test that a fitlered call can be dispatched.
pub struct BaseFilter;
impl Contains<Call> for BaseFilter {
impl Contains<RuntimeCall> for BaseFilter {
fn contains(call: &RuntimeCall) -> bool {
!matches!(
call,
&RuntimeCall::Balances(pallet_balances::RuntimeCall::set_balance { .. })
)
!matches!(call, &RuntimeCall::Balances(pallet_balances::Call::set_balance { .. }))
}
}

Expand Down Expand Up @@ -188,7 +185,7 @@ fn params_should_work() {
}

fn set_balance_proposal(value: u64) -> Vec<u8> {
RuntimeCall::Balances(pallet_balances::RuntimeCall::set_balance {
RuntimeCall::Balances(pallet_balances::Call::set_balance {
who: 42,
new_free: value,
new_reserved: 0,
Expand Down
1 change: 0 additions & 1 deletion crates/escrow/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ impl Config for Test {
type WeightInfo = ();
}

pub type TestEvent = RuntimeEvent;
pub type TestError = Error<Test>;

pub const ALICE: AccountId = 1;
Expand Down
2 changes: 0 additions & 2 deletions crates/fee/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@ impl Config for Test {
type MaxExpectedValue = MaxExpectedValue;
}

pub type TestEvent = RuntimeEvent;

#[allow(dead_code)]
pub type TestError = Error<Test>;

Expand Down
2 changes: 1 addition & 1 deletion crates/fee/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use sp_runtime::{DispatchError, FixedPointNumber};

fn test_setter<F1, F2>(f: F1, get_storage_value: F2)
where
F1: Fn(Origin, UnsignedFixedPoint) -> DispatchResultWithPostInfo,
F1: Fn(RuntimeOrigin, UnsignedFixedPoint) -> DispatchResultWithPostInfo,
F2: Fn() -> UnsignedFixedPoint,
{
run_test(|| {
Expand Down
4 changes: 2 additions & 2 deletions crates/issue/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use sp_runtime::{
traits::{BlakeTwo256, Convert, IdentityLookup, One, Zero},
};

type TestExtrinsic = TestXt<Call, ()>;
type TestExtrinsic = TestXt<RuntimeCall, ()>;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;

Expand Down Expand Up @@ -142,7 +142,7 @@ parameter_types! {

impl<C> frame_system::offchain::SendTransactionTypes<C> for Test
where
Call: From<C>,
RuntimeCall: From<C>,
{
type OverarchingCall = RuntimeCall;
type Extrinsic = TestExtrinsic;
Expand Down
2 changes: 1 addition & 1 deletion crates/loans/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ fn set_account_borrows<T: Config>(who: T::AccountId, asset_id: AssetIdOf<T>, bor
amount.burn_from(&who).unwrap();
}

fn assert_last_event<T: Config>(generic_event: <T as Config>::Event) {
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
frame_system::Pallet::<T>::assert_last_event(generic_event.into());
}

Expand Down
3 changes: 2 additions & 1 deletion crates/loans/src/tests/lend_tokens.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{
mock::{
market_mock, new_test_ext, AccountId, Loans, Origin, Test, Tokens, ALICE, DAVE, LEND_KBTC, LEND_KINT, LEND_KSM,
market_mock, new_test_ext, AccountId, Loans, RuntimeOrigin, Test, Tokens, ALICE, DAVE, LEND_KBTC, LEND_KINT,
LEND_KSM,
},
tests::unit,
Error,
Expand Down
2 changes: 1 addition & 1 deletion crates/loans/src/tests/liquidate_borrow.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
mock::{new_test_ext, Loans, MockPriceFeeder, Origin, Test, Tokens, ALICE, BOB},
mock::{new_test_ext, Loans, MockPriceFeeder, RuntimeOrigin, Test, Tokens, ALICE, BOB},
tests::unit,
Error, MarketState,
};
Expand Down
3 changes: 2 additions & 1 deletion crates/loans/src/tests/market.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{
mock::{
market_mock, new_test_ext, Loans, Origin, Test, ACTIVE_MARKET_MOCK, ALICE, LEND_DOT, LEND_KBTC, MARKET_MOCK,
market_mock, new_test_ext, Loans, RuntimeOrigin, Test, ACTIVE_MARKET_MOCK, ALICE, LEND_DOT, LEND_KBTC,
MARKET_MOCK,
},
Error, InterestRateModel, MarketState,
};
Expand Down
3 changes: 1 addition & 2 deletions crates/nomination/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use sp_runtime::{
FixedPointNumber,
};

type TestExtrinsic = TestXt<Call, ()>;
type TestExtrinsic = TestXt<RuntimeCall, ()>;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;

Expand Down Expand Up @@ -239,7 +239,6 @@ impl Config for Test {
type WeightInfo = ();
}

pub type TestEvent = RuntimeEvent;
pub type TestError = Error<Test>;

pub const ALICE: VaultId<AccountId, CurrencyId> = VaultId {
Expand Down
2 changes: 1 addition & 1 deletion crates/redeem/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup, Zero},
};

type TestExtrinsic = TestXt<Call, ()>;
type TestExtrinsic = TestXt<RuntimeCall, ()>;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;

Expand Down
2 changes: 1 addition & 1 deletion crates/replace/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup, One, Zero},
};

type TestExtrinsic = TestXt<Call, ()>;
type TestExtrinsic = TestXt<RuntimeCall, ()>;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;

Expand Down
1 change: 0 additions & 1 deletion crates/reward/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ impl Config for Test {
type GetWrappedCurrencyId = GetWrappedCurrencyId;
}

pub type TestEvent = RuntimeEvent;
pub type TestError = Error<Test>;

pub const ALICE: AccountId = 1;
Expand Down
1 change: 0 additions & 1 deletion crates/staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ impl orml_tokens::Config for Test {
type OnKilledTokenAccount = ();
}

pub type TestEvent = RuntimeEvent;
pub type TestError = Error<Test>;

pub const VAULT: VaultId<AccountId, CurrencyId> = VaultId {
Expand Down
6 changes: 0 additions & 6 deletions crates/supply/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,6 @@ impl Config for Test {
type OnInflation = MockOnInflation;
}

pub type TestEvent = RuntimeEvent;
// pub type TestError = Error<Test>;

// pub const ALICE: AccountId = 1;
// pub const BOB: AccountId = 2;

pub struct ExtBuilder;

impl ExtBuilder {
Expand Down
2 changes: 1 addition & 1 deletion crates/vault-registry/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup, One, Zero},
};

pub(crate) type Extrinsic = TestXt<Call, ()>;
pub(crate) type Extrinsic = TestXt<RuntimeCall, ()>;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ mod hrmp {
kusama_runtime::System::events().iter().any(|r| {
matches!(
r.event,
kusama_runtime::Event::Hrmp(hrmp::Event::OpenChannelRequested(
kusama_runtime::RuntimeEvent::Hrmp(hrmp::Event::OpenChannelRequested(
actual_sender,
actual_recipient,
1000,
Expand All @@ -96,7 +96,7 @@ mod hrmp {
kusama_runtime::System::events().iter().any(|r| {
matches!(
r.event,
kusama_runtime::Event::Hrmp(hrmp::Event::OpenChannelAccepted(
kusama_runtime::RuntimeEvent::Hrmp(hrmp::Event::OpenChannelAccepted(
actual_sender,
actual_recipient
)) if actual_sender == sender.into() && actual_recipient == recipient.into()
Expand All @@ -112,7 +112,7 @@ mod hrmp {
// do hrmp_init_open_channel
assert!(!has_open_channel_requested_event(sender, recipient)); // just a sanity check
T::execute_with(|| {
let message = construct_xcm(hrmp::RuntimeCall::<kusama_runtime::Runtime>::hrmp_init_open_channel {
let message = construct_xcm(hrmp::Call::<kusama_runtime::Runtime>::hrmp_init_open_channel {
recipient: recipient.into(),
proposed_max_capacity: 1000,
proposed_max_message_size: 102400,
Expand All @@ -131,7 +131,7 @@ mod hrmp {
// do hrmp_accept_open_channel
assert!(!has_open_channel_accepted_event(sender, recipient)); // just a sanity check
T::execute_with(|| {
let message = construct_xcm(hrmp::RuntimeCall::<kusama_runtime::Runtime>::hrmp_accept_open_channel {
let message = construct_xcm(hrmp::Call::<kusama_runtime::Runtime>::hrmp_accept_open_channel {
sender: sender.into(),
});
assert_ok!(pallet_xcm::Pallet::<kintsugi_runtime_parachain::Runtime>::send_xcm(
Expand Down Expand Up @@ -380,7 +380,7 @@ fn xcm_transfer_execution_barrier_trader_works() {
Kintsugi::execute_with(|| {
assert!(System::events().iter().any(|r| matches!(
r.event,
Event::DmpQueue(cumulus_pallet_dmp_queue::Event::ExecutedDownward {
RuntimeEvent::DmpQueue(cumulus_pallet_dmp_queue::Event::ExecutedDownward {
outcome: Outcome::Error(XcmError::Barrier),
..
})
Expand All @@ -391,7 +391,7 @@ fn xcm_transfer_execution_barrier_trader_works() {
// para-chain use XcmExecutor `execute_xcm()` method to execute xcm.
// if `weight_limit` in BuyExecution is less than `xcm_weight(max_weight)`, then Barrier can't pass.
// other situation when `weight_limit` is `Unlimited` or large than `xcm_weight`, then it's ok.
let message = Xcm::<kintsugi_runtime_parachain::Call>(vec![
let message = Xcm::<kintsugi_runtime_parachain::RuntimeCall>(vec![
ReserveAssetDeposited((Parent, 100).into()),
BuyExecution {
fees: (Parent, 100).into(),
Expand All @@ -410,7 +410,7 @@ fn xcm_transfer_execution_barrier_trader_works() {

// trader inside BuyExecution have TooExpensive error if payment less than calculated weight amount.
// the minimum of calculated weight amount(`FixedRateOfFungible<KsmPerSecond>`).
let message = Xcm::<kintsugi_runtime_parachain::Call>(vec![
let message = Xcm::<kintsugi_runtime_parachain::RuntimeCall>(vec![
ReserveAssetDeposited((Parent, xcm_fee - 1).into()),
BuyExecution {
fees: (Parent, xcm_fee - 1).into(),
Expand All @@ -431,7 +431,7 @@ fn xcm_transfer_execution_barrier_trader_works() {
});

// all situation fulfilled, execute success
let message = Xcm::<kintsugi_runtime_parachain::Call>(vec![
let message = Xcm::<kintsugi_runtime_parachain::RuntimeCall>(vec![
ReserveAssetDeposited((Parent, xcm_fee).into()),
BuyExecution {
fees: (Parent, xcm_fee).into(),
Expand Down Expand Up @@ -460,7 +460,7 @@ fn subscribe_version_notify_works() {
assert_ok!(r);
});
KusamaNet::execute_with(|| {
kusama_runtime::System::assert_has_event(kusama_runtime::Event::XcmPallet(
kusama_runtime::System::assert_has_event(kusama_runtime::RuntimeEvent::XcmPallet(
pallet_xcm::Event::SupportedVersionChanged(
MultiLocation {
parents: 0,
Expand All @@ -480,7 +480,7 @@ fn subscribe_version_notify_works() {
assert_ok!(r);
});
Kintsugi::execute_with(|| {
System::assert_has_event(kintsugi_runtime_parachain::Event::PolkadotXcm(
System::assert_has_event(kintsugi_runtime_parachain::RuntimeEvent::PolkadotXcm(
pallet_xcm::Event::SupportedVersionChanged(
MultiLocation {
parents: 1,
Expand All @@ -502,7 +502,7 @@ fn subscribe_version_notify_works() {
Kintsugi::execute_with(|| {
assert!(kintsugi_runtime_parachain::System::events().iter().any(|r| matches!(
r.event,
kintsugi_runtime_parachain::Event::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent {
kintsugi_runtime_parachain::RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent {
message_hash: Some(_)
})
)));
Expand All @@ -512,12 +512,14 @@ fn subscribe_version_notify_works() {
.iter()
.any(|r| matches!(
r.event,
testnet_kintsugi_runtime_parachain::Event::XcmpQueue(
testnet_kintsugi_runtime_parachain::RuntimeEvent::XcmpQueue(
cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { message_hash: Some(_) }
) | testnet_kintsugi_runtime_parachain::Event::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success {
message_hash: Some(_),
weight: _,
})
) | testnet_kintsugi_runtime_parachain::RuntimeEvent::XcmpQueue(
cumulus_pallet_xcmp_queue::Event::Success {
message_hash: Some(_),
weight: _,
}
)
)));
});
}
Expand Down Expand Up @@ -570,20 +572,26 @@ fn trap_assets_works() {
let mut trapped_assets: Option<MultiAssets> = None;
// verify that the assets got trapped (i.e. didn't get burned)
Kintsugi::execute_with(|| {
assert!(System::events()
.iter()
.any(|r| matches!(r.event, Event::PolkadotXcm(pallet_xcm::Event::AssetsTrapped(_, _, _)))));
assert!(System::events().iter().any(|r| matches!(
r.event,
RuntimeEvent::PolkadotXcm(pallet_xcm::Event::AssetsTrapped(_, _, _))
)));

let event = System::events()
.iter()
.find(|r| matches!(r.event, Event::PolkadotXcm(pallet_xcm::Event::AssetsTrapped(_, _, _))))
.find(|r| {
matches!(
r.event,
RuntimeEvent::PolkadotXcm(pallet_xcm::Event::AssetsTrapped(_, _, _))
)
})
.cloned()
.unwrap();

use std::convert::TryFrom;
use xcm::VersionedMultiAssets;
trapped_assets = match event.event {
Event::PolkadotXcm(pallet_xcm::Event::AssetsTrapped(_, _, ticket)) => {
RuntimeEvent::PolkadotXcm(pallet_xcm::Event::AssetsTrapped(_, _, ticket)) => {
Some(TryFrom::<VersionedMultiAssets>::try_from(ticket).unwrap())
}
_ => panic!("event not found"),
Expand Down
Loading

0 comments on commit 000c333

Please sign in to comment.