From 000c33342ca5a92b5f20d7ba45049b39f4600350 Mon Sep 17 00:00:00 2001 From: Gregory Hill Date: Fri, 11 Nov 2022 14:47:29 +0000 Subject: [PATCH] chore: rename outer enums in tests Signed-off-by: Gregory Hill --- crates/annuity/src/mock.rs | 2 - crates/clients-info/src/mock.rs | 2 - crates/collator-selection/src/benchmarking.rs | 4 +- crates/currency/src/mock.rs | 2 - crates/democracy/src/benchmarking.rs | 6 +-- crates/democracy/src/tests.rs | 9 ++-- crates/escrow/src/mock.rs | 1 - crates/fee/src/mock.rs | 2 - crates/fee/src/tests.rs | 2 +- crates/issue/src/mock.rs | 4 +- crates/loans/src/benchmarking.rs | 2 +- crates/loans/src/tests/lend_tokens.rs | 3 +- crates/loans/src/tests/liquidate_borrow.rs | 2 +- crates/loans/src/tests/market.rs | 3 +- crates/nomination/src/mock.rs | 3 +- crates/redeem/src/mock.rs | 2 +- crates/replace/src/mock.rs | 2 +- crates/reward/src/mock.rs | 1 - crates/staking/src/mock.rs | 1 - crates/supply/src/mock.rs | 6 --- crates/vault-registry/src/mock.rs | 2 +- .../relaychain/kusama_cross_chain_transfer.rs | 50 +++++++++++-------- .../src/relaychain/kusama_test_net.rs | 4 +- .../polkadot_cross_chain_transfer.rs | 46 ++++++++++------- .../src/relaychain/polkadot_test_net.rs | 4 +- .../runtime/tests/mock/issue_testing_utils.rs | 6 +-- standalone/runtime/tests/mock/mod.rs | 16 +++--- .../tests/mock/redeem_testing_utils.rs | 4 +- .../tests/mock/replace_testing_utils.rs | 4 +- standalone/runtime/tests/test_annuity.rs | 2 +- standalone/runtime/tests/test_governance.rs | 8 +-- standalone/runtime/tests/test_replace.rs | 2 +- 32 files changed, 102 insertions(+), 105 deletions(-) diff --git a/crates/annuity/src/mock.rs b/crates/annuity/src/mock.rs index d2fd3ac264..a95653246c 100644 --- a/crates/annuity/src/mock.rs +++ b/crates/annuity/src/mock.rs @@ -124,8 +124,6 @@ impl Config for Test { type WeightInfo = (); } -pub type TestEvent = RuntimeEvent; - pub struct ExtBuilder; impl ExtBuilder { diff --git a/crates/clients-info/src/mock.rs b/crates/clients-info/src/mock.rs index 788906919b..409ab6850b 100644 --- a/crates/clients-info/src/mock.rs +++ b/crates/clients-info/src/mock.rs @@ -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 = (); diff --git a/crates/collator-selection/src/benchmarking.rs b/crates/collator-selection/src/benchmarking.rs index cdce5a9a6b..e7e6966c55 100644 --- a/crates/collator-selection/src/benchmarking.rs +++ b/crates/collator-selection/src/benchmarking.rs @@ -41,9 +41,9 @@ macro_rules! whitelist { }; } -fn assert_last_event(generic_event: ::Event) { +fn assert_last_event(generic_event: ::RuntimeEvent) { let events = frame_system::Pallet::::events(); - let system_event: ::Event = generic_event.into(); + let system_event: ::RuntimeEvent = generic_event.into(); // compare to the last event record let EventRecord { event, .. } = &events[events.len() - 1]; assert_eq!(event, &system_event); diff --git a/crates/currency/src/mock.rs b/crates/currency/src/mock.rs index de3826a45c..f509a16c27 100644 --- a/crates/currency/src/mock.rs +++ b/crates/currency/src/mock.rs @@ -129,8 +129,6 @@ parameter_types! { pub const MinimumPeriod: Moment = 5; } -pub type TestEvent = RuntimeEvent; - pub struct ExtBuilder; impl ExtBuilder { diff --git a/crates/democracy/src/benchmarking.rs b/crates/democracy/src/benchmarking.rs index 1951115746..6deefd46a0 100644 --- a/crates/democracy/src/benchmarking.rs +++ b/crates/democracy/src/benchmarking.rs @@ -17,7 +17,7 @@ const MAX_REFERENDUMS: u32 = 99; const MAX_SECONDERS: u32 = 100; const MAX_BYTES: u32 = 16_384; -fn assert_last_event(generic_event: ::Event) { +fn assert_last_event(generic_event: ::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); } @@ -374,7 +374,7 @@ benchmarks! { let b in 0 .. MAX_BYTES; let proposer = funded_account::("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[..]); @@ -406,7 +406,7 @@ benchmarks! { _ => return Err("preimage not available".into()) } let origin = RawOrigin::Root.into(); - let call = RuntimeCall::::enact_proposal { proposal_hash, index: 0 }.encode(); + let call = Call::::enact_proposal { proposal_hash, index: 0 }.encode(); }: { assert_eq!( as Decode>::decode(&mut &*call) diff --git a/crates/democracy/src/tests.rs b/crates/democracy/src/tests.rs index 3432ae215b..d8737d46cf 100644 --- a/crates/democracy/src/tests.rs +++ b/crates/democracy/src/tests.rs @@ -44,12 +44,9 @@ frame_support::construct_runtime!( // Test that a fitlered call can be dispatched. pub struct BaseFilter; -impl Contains for BaseFilter { +impl Contains 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 { .. })) } } @@ -188,7 +185,7 @@ fn params_should_work() { } fn set_balance_proposal(value: u64) -> Vec { - RuntimeCall::Balances(pallet_balances::RuntimeCall::set_balance { + RuntimeCall::Balances(pallet_balances::Call::set_balance { who: 42, new_free: value, new_reserved: 0, diff --git a/crates/escrow/src/mock.rs b/crates/escrow/src/mock.rs index c8721c699b..063acc0658 100644 --- a/crates/escrow/src/mock.rs +++ b/crates/escrow/src/mock.rs @@ -93,7 +93,6 @@ impl Config for Test { type WeightInfo = (); } -pub type TestEvent = RuntimeEvent; pub type TestError = Error; pub const ALICE: AccountId = 1; diff --git a/crates/fee/src/mock.rs b/crates/fee/src/mock.rs index c8ea986614..da99a9616e 100644 --- a/crates/fee/src/mock.rs +++ b/crates/fee/src/mock.rs @@ -188,8 +188,6 @@ impl Config for Test { type MaxExpectedValue = MaxExpectedValue; } -pub type TestEvent = RuntimeEvent; - #[allow(dead_code)] pub type TestError = Error; diff --git a/crates/fee/src/tests.rs b/crates/fee/src/tests.rs index b41440844e..f43df5535d 100644 --- a/crates/fee/src/tests.rs +++ b/crates/fee/src/tests.rs @@ -5,7 +5,7 @@ use sp_runtime::{DispatchError, FixedPointNumber}; fn test_setter(f: F1, get_storage_value: F2) where - F1: Fn(Origin, UnsignedFixedPoint) -> DispatchResultWithPostInfo, + F1: Fn(RuntimeOrigin, UnsignedFixedPoint) -> DispatchResultWithPostInfo, F2: Fn() -> UnsignedFixedPoint, { run_test(|| { diff --git a/crates/issue/src/mock.rs b/crates/issue/src/mock.rs index 137843407b..686121a8b0 100644 --- a/crates/issue/src/mock.rs +++ b/crates/issue/src/mock.rs @@ -17,7 +17,7 @@ use sp_runtime::{ traits::{BlakeTwo256, Convert, IdentityLookup, One, Zero}, }; -type TestExtrinsic = TestXt; +type TestExtrinsic = TestXt; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; @@ -142,7 +142,7 @@ parameter_types! { impl frame_system::offchain::SendTransactionTypes for Test where - Call: From, + RuntimeCall: From, { type OverarchingCall = RuntimeCall; type Extrinsic = TestExtrinsic; diff --git a/crates/loans/src/benchmarking.rs b/crates/loans/src/benchmarking.rs index d9e9786a67..33f57a15a3 100644 --- a/crates/loans/src/benchmarking.rs +++ b/crates/loans/src/benchmarking.rs @@ -115,7 +115,7 @@ fn set_account_borrows(who: T::AccountId, asset_id: AssetIdOf, bor amount.burn_from(&who).unwrap(); } -fn assert_last_event(generic_event: ::Event) { +fn assert_last_event(generic_event: ::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); } diff --git a/crates/loans/src/tests/lend_tokens.rs b/crates/loans/src/tests/lend_tokens.rs index 904285aaea..a7edfaf4d8 100644 --- a/crates/loans/src/tests/lend_tokens.rs +++ b/crates/loans/src/tests/lend_tokens.rs @@ -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, diff --git a/crates/loans/src/tests/liquidate_borrow.rs b/crates/loans/src/tests/liquidate_borrow.rs index 698ff2633a..6e491d0880 100644 --- a/crates/loans/src/tests/liquidate_borrow.rs +++ b/crates/loans/src/tests/liquidate_borrow.rs @@ -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, }; diff --git a/crates/loans/src/tests/market.rs b/crates/loans/src/tests/market.rs index 1cd5b42be7..446fe721c7 100644 --- a/crates/loans/src/tests/market.rs +++ b/crates/loans/src/tests/market.rs @@ -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, }; diff --git a/crates/nomination/src/mock.rs b/crates/nomination/src/mock.rs index 5f4e3852ba..e7b31b9e07 100644 --- a/crates/nomination/src/mock.rs +++ b/crates/nomination/src/mock.rs @@ -18,7 +18,7 @@ use sp_runtime::{ FixedPointNumber, }; -type TestExtrinsic = TestXt; +type TestExtrinsic = TestXt; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; @@ -239,7 +239,6 @@ impl Config for Test { type WeightInfo = (); } -pub type TestEvent = RuntimeEvent; pub type TestError = Error; pub const ALICE: VaultId = VaultId { diff --git a/crates/redeem/src/mock.rs b/crates/redeem/src/mock.rs index 01922985d6..1888adee84 100644 --- a/crates/redeem/src/mock.rs +++ b/crates/redeem/src/mock.rs @@ -18,7 +18,7 @@ use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup, Zero}, }; -type TestExtrinsic = TestXt; +type TestExtrinsic = TestXt; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; diff --git a/crates/replace/src/mock.rs b/crates/replace/src/mock.rs index 026f39559d..bc705eb5f9 100644 --- a/crates/replace/src/mock.rs +++ b/crates/replace/src/mock.rs @@ -17,7 +17,7 @@ use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup, One, Zero}, }; -type TestExtrinsic = TestXt; +type TestExtrinsic = TestXt; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; diff --git a/crates/reward/src/mock.rs b/crates/reward/src/mock.rs index 938fee972d..8709cf2515 100644 --- a/crates/reward/src/mock.rs +++ b/crates/reward/src/mock.rs @@ -75,7 +75,6 @@ impl Config for Test { type GetWrappedCurrencyId = GetWrappedCurrencyId; } -pub type TestEvent = RuntimeEvent; pub type TestError = Error; pub const ALICE: AccountId = 1; diff --git a/crates/staking/src/mock.rs b/crates/staking/src/mock.rs index e7ea93a8e2..d9795771d1 100644 --- a/crates/staking/src/mock.rs +++ b/crates/staking/src/mock.rs @@ -109,7 +109,6 @@ impl orml_tokens::Config for Test { type OnKilledTokenAccount = (); } -pub type TestEvent = RuntimeEvent; pub type TestError = Error; pub const VAULT: VaultId = VaultId { diff --git a/crates/supply/src/mock.rs b/crates/supply/src/mock.rs index 4a284846fd..5b8f0f5844 100644 --- a/crates/supply/src/mock.rs +++ b/crates/supply/src/mock.rs @@ -110,12 +110,6 @@ impl Config for Test { type OnInflation = MockOnInflation; } -pub type TestEvent = RuntimeEvent; -// pub type TestError = Error; - -// pub const ALICE: AccountId = 1; -// pub const BOB: AccountId = 2; - pub struct ExtBuilder; impl ExtBuilder { diff --git a/crates/vault-registry/src/mock.rs b/crates/vault-registry/src/mock.rs index 760208c4f0..59925a4203 100644 --- a/crates/vault-registry/src/mock.rs +++ b/crates/vault-registry/src/mock.rs @@ -17,7 +17,7 @@ use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup, One, Zero}, }; -pub(crate) type Extrinsic = TestXt; +pub(crate) type Extrinsic = TestXt; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; diff --git a/parachain/runtime/runtime-tests/src/relaychain/kusama_cross_chain_transfer.rs b/parachain/runtime/runtime-tests/src/relaychain/kusama_cross_chain_transfer.rs index a14df32d83..444f09d3bb 100644 --- a/parachain/runtime/runtime-tests/src/relaychain/kusama_cross_chain_transfer.rs +++ b/parachain/runtime/runtime-tests/src/relaychain/kusama_cross_chain_transfer.rs @@ -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, @@ -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() @@ -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::::hrmp_init_open_channel { + let message = construct_xcm(hrmp::Call::::hrmp_init_open_channel { recipient: recipient.into(), proposed_max_capacity: 1000, proposed_max_message_size: 102400, @@ -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::::hrmp_accept_open_channel { + let message = construct_xcm(hrmp::Call::::hrmp_accept_open_channel { sender: sender.into(), }); assert_ok!(pallet_xcm::Pallet::::send_xcm( @@ -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), .. }) @@ -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::(vec![ + let message = Xcm::(vec![ ReserveAssetDeposited((Parent, 100).into()), BuyExecution { fees: (Parent, 100).into(), @@ -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`). - let message = Xcm::(vec![ + let message = Xcm::(vec![ ReserveAssetDeposited((Parent, xcm_fee - 1).into()), BuyExecution { fees: (Parent, xcm_fee - 1).into(), @@ -431,7 +431,7 @@ fn xcm_transfer_execution_barrier_trader_works() { }); // all situation fulfilled, execute success - let message = Xcm::(vec![ + let message = Xcm::(vec![ ReserveAssetDeposited((Parent, xcm_fee).into()), BuyExecution { fees: (Parent, xcm_fee).into(), @@ -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, @@ -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, @@ -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(_) }) ))); @@ -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: _, + } + ) ))); }); } @@ -570,20 +572,26 @@ fn trap_assets_works() { let mut trapped_assets: Option = 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::::try_from(ticket).unwrap()) } _ => panic!("event not found"), diff --git a/parachain/runtime/runtime-tests/src/relaychain/kusama_test_net.rs b/parachain/runtime/runtime-tests/src/relaychain/kusama_test_net.rs index 0d76c02ae2..c6fefc92c8 100644 --- a/parachain/runtime/runtime-tests/src/relaychain/kusama_test_net.rs +++ b/parachain/runtime/runtime-tests/src/relaychain/kusama_test_net.rs @@ -23,7 +23,7 @@ decl_test_relay_chain! { decl_test_parachain! { pub struct Kintsugi { Runtime = Runtime, - Origin = Origin, + Origin = RuntimeOrigin, XcmpMessageHandler = kintsugi_runtime_parachain::XcmpQueue, DmpMessageHandler = kintsugi_runtime_parachain::DmpQueue, new_ext = para_ext(KINTSUGI_PARA_ID), @@ -33,7 +33,7 @@ decl_test_parachain! { decl_test_parachain! { pub struct Sibling { Runtime = testnet_kintsugi_runtime_parachain::Runtime, - Origin = testnet_kintsugi_runtime_parachain::Origin, + Origin = testnet_kintsugi_runtime_parachain::RuntimeOrigin, XcmpMessageHandler = testnet_kintsugi_runtime_parachain::XcmpQueue, DmpMessageHandler = testnet_kintsugi_runtime_parachain::DmpQueue, new_ext = para_ext(SIBLING_PARA_ID), diff --git a/parachain/runtime/runtime-tests/src/relaychain/polkadot_cross_chain_transfer.rs b/parachain/runtime/runtime-tests/src/relaychain/polkadot_cross_chain_transfer.rs index 4c5eb152af..4891aa1f5c 100644 --- a/parachain/runtime/runtime-tests/src/relaychain/polkadot_cross_chain_transfer.rs +++ b/parachain/runtime/runtime-tests/src/relaychain/polkadot_cross_chain_transfer.rs @@ -49,7 +49,7 @@ mod hrmp { polkadot_runtime::System::events().iter().any(|r| { matches!( r.event, - polkadot_runtime::Event::Hrmp(hrmp::Event::OpenChannelRequested( + polkadot_runtime::RuntimeEvent::Hrmp(hrmp::Event::OpenChannelRequested( actual_sender, actual_recipient, 1000, @@ -65,7 +65,7 @@ mod hrmp { polkadot_runtime::System::events().iter().any(|r| { matches!( r.event, - polkadot_runtime::Event::Hrmp(hrmp::Event::OpenChannelAccepted( + polkadot_runtime::RuntimeEvent::Hrmp(hrmp::Event::OpenChannelAccepted( actual_sender, actual_recipient )) if actual_sender == sender.into() && actual_recipient == recipient.into() @@ -82,7 +82,7 @@ mod hrmp { assert!(!has_open_channel_requested_event(sender, recipient)); // just a sanity check T::execute_with(|| { let message = construct_xcm( - hrmp::RuntimeCall::::hrmp_init_open_channel { + hrmp::Call::::hrmp_init_open_channel { recipient: recipient.into(), proposed_max_capacity: 1000, proposed_max_message_size: 102400, @@ -105,7 +105,7 @@ mod hrmp { assert!(!has_open_channel_accepted_event(sender, recipient)); // just a sanity check T::execute_with(|| { let message = construct_xcm( - hrmp::RuntimeCall::::hrmp_accept_open_channel { sender: sender.into() }, + hrmp::Call::::hrmp_accept_open_channel { sender: sender.into() }, xcm_fee, transact_weight, ); @@ -403,7 +403,7 @@ fn xcm_transfer_execution_barrier_trader_works() { Interlay::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), .. }) @@ -451,7 +451,7 @@ fn subscribe_version_notify_works() { assert_ok!(r); }); PolkadotNet::execute_with(|| { - polkadot_runtime::System::assert_has_event(polkadot_runtime::Event::XcmPallet( + polkadot_runtime::System::assert_has_event(polkadot_runtime::RuntimeEvent::XcmPallet( pallet_xcm::Event::SupportedVersionChanged( MultiLocation { parents: 0, @@ -471,7 +471,7 @@ fn subscribe_version_notify_works() { assert_ok!(r); }); Interlay::execute_with(|| { - System::assert_has_event(interlay_runtime_parachain::Event::PolkadotXcm( + System::assert_has_event(interlay_runtime_parachain::RuntimeEvent::PolkadotXcm( pallet_xcm::Event::SupportedVersionChanged( MultiLocation { parents: 1, @@ -493,7 +493,7 @@ fn subscribe_version_notify_works() { Interlay::execute_with(|| { assert!(interlay_runtime_parachain::System::events().iter().any(|r| matches!( r.event, - interlay_runtime_parachain::Event::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { + interlay_runtime_parachain::RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { message_hash: Some(_) }) ))); @@ -503,17 +503,19 @@ fn subscribe_version_notify_works() { .iter() .any(|r| matches!( r.event, - testnet_interlay_runtime_parachain::Event::XcmpQueue( + testnet_interlay_runtime_parachain::RuntimeEvent::XcmpQueue( cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { message_hash: Some(_) } - ) | testnet_interlay_runtime_parachain::Event::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { - message_hash: Some(_), - weight: _ - }) + ) | testnet_interlay_runtime_parachain::RuntimeEvent::XcmpQueue( + cumulus_pallet_xcmp_queue::Event::Success { + message_hash: Some(_), + weight: _ + } + ) ))); }); } -fn weigh_xcm(mut message: Xcm, fee_per_second: u128) -> u128 { +fn weigh_xcm(mut message: Xcm, fee_per_second: u128) -> u128 { let trapped_xcm_message_weight = ::Weigher::weight( &mut message).unwrap(); (fee_per_second * trapped_xcm_message_weight as u128) / WEIGHT_PER_SECOND.ref_time() as u128 @@ -574,20 +576,26 @@ fn trap_assets_works() { let mut trapped_assets: Option = None; // verify that the assets got trapped (i.e. didn't get burned) Interlay::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::::try_from(ticket).unwrap()) } _ => panic!("event not found"), diff --git a/parachain/runtime/runtime-tests/src/relaychain/polkadot_test_net.rs b/parachain/runtime/runtime-tests/src/relaychain/polkadot_test_net.rs index 5e871677b9..be30ff97c6 100644 --- a/parachain/runtime/runtime-tests/src/relaychain/polkadot_test_net.rs +++ b/parachain/runtime/runtime-tests/src/relaychain/polkadot_test_net.rs @@ -23,7 +23,7 @@ decl_test_relay_chain! { decl_test_parachain! { pub struct Interlay { Runtime = Runtime, - Origin = Origin, + Origin = RuntimeOrigin, XcmpMessageHandler = interlay_runtime_parachain::XcmpQueue, DmpMessageHandler = interlay_runtime_parachain::DmpQueue, new_ext = para_ext(INTERLAY_PARA_ID), @@ -33,7 +33,7 @@ decl_test_parachain! { decl_test_parachain! { pub struct Sibling { Runtime = testnet_interlay_runtime_parachain::Runtime, - Origin = testnet_interlay_runtime_parachain::Origin, + Origin = testnet_interlay_runtime_parachain::RuntimeOrigin, XcmpMessageHandler = testnet_interlay_runtime_parachain::XcmpQueue, DmpMessageHandler = testnet_interlay_runtime_parachain::DmpQueue, new_ext = para_ext(SIBLING_PARA_ID), diff --git a/standalone/runtime/tests/mock/issue_testing_utils.rs b/standalone/runtime/tests/mock/issue_testing_utils.rs index 4c3bfd9e40..ba86b84f1d 100644 --- a/standalone/runtime/tests/mock/issue_testing_utils.rs +++ b/standalone/runtime/tests/mock/issue_testing_utils.rs @@ -176,7 +176,7 @@ pub fn assert_issue_amount_change_event( let records: Vec<_> = events .iter() .rev() - .filter(|record| matches!(&record.event, Event::Issue(x) if x == &expected_event)) + .filter(|record| matches!(&record.event, RuntimeEvent::Issue(x) if x == &expected_event)) .collect(); assert_eq!(records.len(), 1); } @@ -186,8 +186,8 @@ pub fn assert_issue_request_event() -> H256 { let record = events .iter() .rev() - .find(|record| matches!(record.event, Event::Issue(IssueEvent::RequestIssue { .. }))); - if let Event::Issue(IssueEvent::RequestIssue { issue_id, .. }) = record.unwrap().event { + .find(|record| matches!(record.event, RuntimeEvent::Issue(IssueEvent::RequestIssue { .. }))); + if let RuntimeEvent::Issue(IssueEvent::RequestIssue { issue_id, .. }) = record.unwrap().event { issue_id } else { panic!("request issue event not found") diff --git a/standalone/runtime/tests/mock/mod.rs b/standalone/runtime/tests/mock/mod.rs index 72269595c3..2b5adcc1c6 100644 --- a/standalone/runtime/tests/mock/mod.rs +++ b/standalone/runtime/tests/mock/mod.rs @@ -15,8 +15,8 @@ pub use frame_support::{ dispatch::{DispatchError, DispatchResultWithPostInfo}, }; pub use interbtc_runtime_standalone::{ - token_distribution, AccountId, Balance, BlockNumber, Call, CurrencyId, EscrowAnnuityInstance, - EscrowRewardsInstance, Event, GetNativeCurrencyId, GetRelayChainCurrencyId, GetWrappedCurrencyId, Runtime, + token_distribution, AccountId, Balance, BlockNumber, CurrencyId, EscrowAnnuityInstance, EscrowRewardsInstance, + GetNativeCurrencyId, GetRelayChainCurrencyId, GetWrappedCurrencyId, Runtime, RuntimeCall, RuntimeEvent, TechnicalCommitteeInstance, VaultAnnuityInstance, VaultRewardsInstance, YEARS, }; pub use mocktopus::mocking::*; @@ -312,11 +312,11 @@ pub fn default_redeem_request( } } -pub fn root() -> ::Origin { +pub fn root() -> ::RuntimeOrigin { ::RuntimeOrigin::root() } -pub fn origin_of(account_id: AccountId) -> ::Origin { +pub fn origin_of(account_id: AccountId) -> ::RuntimeOrigin { ::RuntimeOrigin::signed(account_id) } @@ -1083,7 +1083,7 @@ pub fn required_collateral_for_issue(issued_tokens: Amount, currency_id } pub fn assert_store_main_chain_header_event(block_height: u32, block_hash: H256Le, relayer_id: AccountId) { - let store_event = Event::BTCRelay(BTCRelayEvent::StoreMainChainHeader { + let store_event = RuntimeEvent::BTCRelay(BTCRelayEvent::StoreMainChainHeader { block_height, block_hash, relayer_id, @@ -1095,7 +1095,7 @@ pub fn assert_store_main_chain_header_event(block_height: u32, block_hash: H256L } pub fn assert_store_fork_header_event(chain_id: u32, fork_height: u32, block_hash: H256Le, relayer_id: AccountId) { - let store_event = Event::BTCRelay(BTCRelayEvent::StoreForkHeader { + let store_event = RuntimeEvent::BTCRelay(BTCRelayEvent::StoreForkHeader { chain_id, fork_height, block_hash, @@ -1108,7 +1108,7 @@ pub fn assert_store_fork_header_event(chain_id: u32, fork_height: u32, block_has } pub fn assert_fork_ahead_of_main_chain_event(main_chain_height: u32, fork_height: u32, fork_id: u32) { - let store_event = Event::BTCRelay(BTCRelayEvent::ForkAheadOfMainChain { + let store_event = RuntimeEvent::BTCRelay(BTCRelayEvent::ForkAheadOfMainChain { main_chain_height, fork_height, fork_id, @@ -1120,7 +1120,7 @@ pub fn assert_fork_ahead_of_main_chain_event(main_chain_height: u32, fork_height } pub fn assert_chain_reorg_event(new_chain_tip_hash: H256Le, new_chain_tip_height: u32, fork_depth: u32) { - let store_event = Event::BTCRelay(BTCRelayEvent::ChainReorg { + let store_event = RuntimeEvent::BTCRelay(BTCRelayEvent::ChainReorg { new_chain_tip_hash, new_chain_tip_height, fork_depth, diff --git a/standalone/runtime/tests/mock/redeem_testing_utils.rs b/standalone/runtime/tests/mock/redeem_testing_utils.rs index 91bfc084f4..989437a213 100644 --- a/standalone/runtime/tests/mock/redeem_testing_utils.rs +++ b/standalone/runtime/tests/mock/redeem_testing_utils.rs @@ -127,7 +127,7 @@ pub fn assert_redeem_request_event() -> H256 { let ids = events .iter() .filter_map(|r| match r.event { - Event::Redeem(RedeemEvent::RequestRedeem { redeem_id, .. }) => Some(redeem_id), + RuntimeEvent::Redeem(RedeemEvent::RequestRedeem { redeem_id, .. }) => Some(redeem_id), _ => None, }) .collect::>(); @@ -141,7 +141,7 @@ pub fn assert_self_redeem_event() -> (Amount, Amount) { let ids = events .iter() .filter_map(|r| match r.event { - Event::Redeem(RedeemEvent::SelfRedeem { + RuntimeEvent::Redeem(RedeemEvent::SelfRedeem { ref vault_id, amount, fee, diff --git a/standalone/runtime/tests/mock/replace_testing_utils.rs b/standalone/runtime/tests/mock/replace_testing_utils.rs index bf8bb1b93a..9bf3d0d6a7 100644 --- a/standalone/runtime/tests/mock/replace_testing_utils.rs +++ b/standalone/runtime/tests/mock/replace_testing_utils.rs @@ -44,7 +44,7 @@ pub fn assert_request_replace_event() -> Balance { .iter() .rev() .find_map(|record| match record.event { - Event::Replace(ReplaceEvent::RequestReplace { + RuntimeEvent::Replace(ReplaceEvent::RequestReplace { griefing_collateral, .. }) => Some(griefing_collateral), _ => None, @@ -57,7 +57,7 @@ pub fn assert_accept_replace_event() -> H256 { .iter() .rev() .find_map(|record| match record.event { - Event::Replace(ReplaceEvent::AcceptReplace { replace_id, .. }) => Some(replace_id), + RuntimeEvent::Replace(ReplaceEvent::AcceptReplace { replace_id, .. }) => Some(replace_id), _ => None, }) .unwrap() diff --git a/standalone/runtime/tests/test_annuity.rs b/standalone/runtime/tests/test_annuity.rs index e7aebde03d..50acdbc410 100644 --- a/standalone/runtime/tests/test_annuity.rs +++ b/standalone/runtime/tests/test_annuity.rs @@ -18,7 +18,7 @@ fn get_last_reward() -> Balance { .iter() .rev() .find_map(|record| { - if let Event::VaultAnnuity(VaultAnnuityEvent::BlockReward(reward)) = record.event { + if let RuntimeEvent::VaultAnnuity(VaultAnnuityEvent::BlockReward(reward)) = record.event { Some(reward) } else { None diff --git a/standalone/runtime/tests/test_governance.rs b/standalone/runtime/tests/test_governance.rs index 0b0e98cba7..fa8aafe03c 100644 --- a/standalone/runtime/tests/test_governance.rs +++ b/standalone/runtime/tests/test_governance.rs @@ -72,7 +72,7 @@ fn assert_democracy_proposed_event() -> PropIndex { .iter() .rev() .find_map(|record| { - if let Event::Democracy(DemocracyEvent::Proposed(index, _)) = record.event { + if let RuntimeEvent::Democracy(DemocracyEvent::Proposed(index, _)) = record.event { Some(index) } else { None @@ -86,7 +86,7 @@ fn assert_democracy_started_event() -> ReferendumIndex { .iter() .rev() .find_map(|record| { - if let Event::Democracy(DemocracyEvent::Started(index, _)) = record.event { + if let RuntimeEvent::Democracy(DemocracyEvent::Started(index, _)) = record.event { Some(index) } else { None @@ -99,7 +99,7 @@ fn assert_democracy_passed_event(index: ReferendumIndex) { SystemPallet::events() .iter() .rev() - .find(|record| matches!(record.event, Event::Democracy(DemocracyEvent::Passed(i)) if i == index)) + .find(|record| matches!(record.event, RuntimeEvent::Democracy(DemocracyEvent::Passed(i)) if i == index)) .expect("referendum was not passed"); } @@ -110,7 +110,7 @@ fn assert_technical_committee_executed_event() { .find(|record| { matches!( record.event, - Event::TechnicalCommittee(TechnicalCommitteeEvent::Executed { result: Ok(()), .. }) + RuntimeEvent::TechnicalCommittee(TechnicalCommitteeEvent::Executed { result: Ok(()), .. }) ) }) .expect("execution failed"); diff --git a/standalone/runtime/tests/test_replace.rs b/standalone/runtime/tests/test_replace.rs index 237c601a0d..3fa6771036 100644 --- a/standalone/runtime/tests/test_replace.rs +++ b/standalone/runtime/tests/test_replace.rs @@ -85,7 +85,7 @@ pub fn withdraw_replace(old_vault_id: &VaultId, amount: Amount) -> Disp pub fn assert_replace_request_event() { let events = SystemPallet::events(); let ids = events.iter().filter_map(|r| match r.event { - Event::Replace(ReplaceEvent::RequestReplace { .. }) => Some(()), + RuntimeEvent::Replace(ReplaceEvent::RequestReplace { .. }) => Some(()), _ => None, }); assert_eq!(ids.count(), 1);