diff --git a/bin/node/executor/tests/basic.rs b/bin/node/executor/tests/basic.rs index da0f4e6afb319..e458b78af57a7 100644 --- a/bin/node/executor/tests/basic.rs +++ b/bin/node/executor/tests/basic.rs @@ -378,50 +378,66 @@ fn full_native_block_import_works() { let events = vec![ EventRecord { phase: Phase::ApplyExtrinsic(0), - event: Event::System(frame_system::Event::ExtrinsicSuccess { - dispatch_info: DispatchInfo { - weight: timestamp_weight, - class: DispatchClass::Mandatory, - ..Default::default() - }, - }), + event: Event::System( + frame_system::Event::ExtrinsicSuccess { + dispatch_info: DispatchInfo { + weight: timestamp_weight, + class: DispatchClass::Mandatory, + ..Default::default() + }, + } + .into(), + ), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::Balances(pallet_balances::Event::Withdraw { - who: alice().into(), - amount: fees, - }), + event: Event::Balances( + pallet_balances::Event::Withdraw { who: alice().into(), amount: fees }.into(), + ), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::Balances(pallet_balances::Event::Transfer { - from: alice().into(), - to: bob().into(), - amount: 69 * DOLLARS, - }), + event: Event::Balances( + pallet_balances::Event::Transfer { + from: alice().into(), + to: bob().into(), + amount: 69 * DOLLARS, + } + .into(), + ), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::Balances(pallet_balances::Event::Deposit { - who: pallet_treasury::Pallet::::account_id(), - amount: fees * 8 / 10, - }), + event: Event::Balances( + pallet_balances::Event::Deposit { + who: pallet_treasury::Pallet::::account_id(), + amount: fees * 8 / 10, + } + .into(), + ), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::Treasury(pallet_treasury::Event::Deposit { value: fees * 8 / 10 }), + event: Event::Treasury( + pallet_treasury::Event::Deposit { value: fees * 8 / 10 }.into(), + ), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::System(frame_system::Event::ExtrinsicSuccess { - dispatch_info: DispatchInfo { weight: transfer_weight, ..Default::default() }, - }), + event: Event::System( + frame_system::Event::ExtrinsicSuccess { + dispatch_info: DispatchInfo { + weight: transfer_weight, + ..Default::default() + }, + } + .into(), + ), topics: vec![], }, ]; @@ -449,87 +465,116 @@ fn full_native_block_import_works() { let events = vec![ EventRecord { phase: Phase::ApplyExtrinsic(0), - event: Event::System(frame_system::Event::ExtrinsicSuccess { - dispatch_info: DispatchInfo { - weight: timestamp_weight, - class: DispatchClass::Mandatory, - ..Default::default() - }, - }), + event: Event::System( + frame_system::Event::ExtrinsicSuccess { + dispatch_info: DispatchInfo { + weight: timestamp_weight, + class: DispatchClass::Mandatory, + ..Default::default() + }, + } + .into(), + ), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::Balances(pallet_balances::Event::Withdraw { - who: bob().into(), - amount: fees, - }), + event: Event::Balances( + pallet_balances::Event::Withdraw { who: bob().into(), amount: fees }.into(), + ), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::Balances(pallet_balances::Event::Transfer { - from: bob().into(), - to: alice().into(), - amount: 5 * DOLLARS, - }), + event: Event::Balances( + pallet_balances::Event::Transfer { + from: bob().into(), + to: alice().into(), + amount: 5 * DOLLARS, + } + .into(), + ), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::Balances(pallet_balances::Event::Deposit { - who: pallet_treasury::Pallet::::account_id(), - amount: fees * 8 / 10, - }), + event: Event::Balances( + pallet_balances::Event::Deposit { + who: pallet_treasury::Pallet::::account_id(), + amount: fees * 8 / 10, + } + .into(), + ), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::Treasury(pallet_treasury::Event::Deposit { value: fees * 8 / 10 }), + event: Event::Treasury( + pallet_treasury::Event::Deposit { value: fees * 8 / 10 }.into(), + ), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::System(frame_system::Event::ExtrinsicSuccess { - dispatch_info: DispatchInfo { weight: transfer_weight, ..Default::default() }, - }), + event: Event::System( + frame_system::Event::ExtrinsicSuccess { + dispatch_info: DispatchInfo { + weight: transfer_weight, + ..Default::default() + }, + } + .into(), + ), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: Event::Balances(pallet_balances::Event::Withdraw { - who: alice().into(), - amount: fees, - }), + event: Event::Balances( + pallet_balances::Event::Withdraw { who: alice().into(), amount: fees }.into(), + ), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: Event::Balances(pallet_balances::Event::Transfer { - from: alice().into(), - to: bob().into(), - amount: 15 * DOLLARS, - }), + event: Event::Balances( + pallet_balances::Event::Transfer { + from: alice().into(), + to: bob().into(), + amount: 15 * DOLLARS, + } + .into(), + ), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: Event::Balances(pallet_balances::Event::Deposit { - who: pallet_treasury::Pallet::::account_id(), - amount: fees * 8 / 10, - }), + event: Event::Balances( + pallet_balances::Event::Deposit { + who: pallet_treasury::Pallet::::account_id(), + amount: fees * 8 / 10, + } + .into(), + ), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: Event::Treasury(pallet_treasury::Event::Deposit { value: fees * 8 / 10 }), + event: Event::Treasury( + pallet_treasury::Event::Deposit { value: fees * 8 / 10 }.into(), + ), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: Event::System(frame_system::Event::ExtrinsicSuccess { - dispatch_info: DispatchInfo { weight: transfer_weight, ..Default::default() }, - }), + event: Event::System( + frame_system::Event::ExtrinsicSuccess { + dispatch_info: DispatchInfo { + weight: transfer_weight, + ..Default::default() + }, + } + .into(), + ), topics: vec![], }, ]; diff --git a/frame/assets/src/tests.rs b/frame/assets/src/tests.rs index 7430b742e7d2a..2bf332f2cdccf 100644 --- a/frame/assets/src/tests.rs +++ b/frame/assets/src/tests.rs @@ -620,12 +620,9 @@ fn transferring_less_than_one_unit_is_fine() { assert_ok!(Assets::mint(Origin::signed(1), 0, 1, 100)); assert_eq!(Assets::balance(0, 1), 100); assert_ok!(Assets::transfer(Origin::signed(1), 0, 2, 0)); - System::assert_last_event(mock::Event::Assets(crate::Event::Transferred { - asset_id: 0, - from: 1, - to: 2, - amount: 0, - })); + System::assert_last_event( + crate::Event::Transferred { asset_id: 0, from: 1, to: 2, amount: 0 }.into(), + ); }); } diff --git a/frame/balances/src/tests.rs b/frame/balances/src/tests.rs index 8f5470ae3cac2..247fa0dacd94b 100644 --- a/frame/balances/src/tests.rs +++ b/frame/balances/src/tests.rs @@ -314,7 +314,7 @@ macro_rules! decl_tests { <$ext_builder>::default().monied(true).build().execute_with(|| { assert_eq!(Balances::total_balance(&1), 10); assert_ok!(Balances::deposit_into_existing(&1, 10).map(drop)); - System::assert_last_event(Event::Balances(crate::Event::Deposit { who: 1, amount: 10 })); + System::assert_last_event(crate::Event::Deposit { who: 1, amount: 10 }.into()); assert_eq!(Balances::total_balance(&1), 20); assert_eq!(>::get(), 120); }); @@ -342,7 +342,7 @@ macro_rules! decl_tests { fn balance_works() { <$ext_builder>::default().build().execute_with(|| { let _ = Balances::deposit_creating(&1, 42); - System::assert_has_event(Event::Balances(crate::Event::Deposit { who: 1, amount: 42 })); + System::assert_has_event(crate::Event::Deposit { who: 1, amount: 42 }.into()); assert_eq!(Balances::free_balance(1), 42); assert_eq!(Balances::reserved_balance(1), 0); assert_eq!(Balances::total_balance(&1), 42); @@ -444,7 +444,7 @@ macro_rules! decl_tests { let _ = Balances::withdraw( &2, 11, WithdrawReasons::TRANSFER, ExistenceRequirement::KeepAlive ); - System::assert_last_event(Event::Balances(crate::Event::Withdraw { who: 2, amount: 11 })); + System::assert_last_event(crate::Event::Withdraw { who: 2, amount: 11 }.into()); assert_eq!(Balances::free_balance(2), 100); assert_eq!(>::get(), 100); }); @@ -505,7 +505,7 @@ macro_rules! decl_tests { assert_ok!(Balances::reserve(&1, 110)); assert_ok!(Balances::repatriate_reserved(&1, &2, 41, Status::Free), 0); System::assert_last_event( - Event::Balances(crate::Event::ReserveRepatriated { from: 1, to: 2, amount: 41, destination_status: Status::Free }) + crate::Event::ReserveRepatriated { from: 1, to: 2, amount: 41, destination_status: Status::Free }.into() ); assert_eq!(Balances::reserved_balance(1), 69); assert_eq!(Balances::free_balance(1), 0); @@ -724,18 +724,18 @@ macro_rules! decl_tests { System::set_block_number(2); assert_ok!(Balances::reserve(&1, 10)); - System::assert_last_event(Event::Balances(crate::Event::Reserved { who: 1, amount: 10 })); + System::assert_last_event(crate::Event::Reserved { who: 1, amount: 10 }.into()); System::set_block_number(3); assert!(Balances::unreserve(&1, 5).is_zero()); - System::assert_last_event(Event::Balances(crate::Event::Unreserved { who: 1, amount: 5 })); + System::assert_last_event(crate::Event::Unreserved { who: 1, amount: 5 }.into()); System::set_block_number(4); assert_eq!(Balances::unreserve(&1, 6), 1); // should only unreserve 5 - System::assert_last_event(Event::Balances(crate::Event::Unreserved { who: 1, amount: 5 })); + System::assert_last_event(crate::Event::Unreserved { who: 1, amount: 5 }.into()); }); } @@ -750,9 +750,9 @@ macro_rules! decl_tests { assert_eq!( events(), [ - Event::System(system::Event::NewAccount { account: 1 }), - Event::Balances(crate::Event::Endowed { account: 1, free_balance: 100 }), - Event::Balances(crate::Event::BalanceSet { who: 1, free: 100, reserved: 0 }), + system::Event::NewAccount { account: 1 }.into(), + crate::Event::Endowed { account: 1, free_balance: 100 }.into(), + crate::Event::BalanceSet { who: 1, free: 100, reserved: 0 }.into(), ] ); @@ -762,9 +762,9 @@ macro_rules! decl_tests { assert_eq!( events(), [ - Event::System(system::Event::KilledAccount { account: 1 }), - Event::Balances(crate::Event::DustLost { account: 1, amount: 99 }), - Event::Balances(crate::Event::Slashed { who: 1, amount: 1 }), + system::Event::KilledAccount { account: 1 }.into(), + crate::Event::DustLost { account: 1, amount: 99 }.into(), + crate::Event::Slashed { who: 1, amount: 1 }.into(), ] ); }); @@ -781,9 +781,9 @@ macro_rules! decl_tests { assert_eq!( events(), [ - Event::System(system::Event::NewAccount { account: 1 }), - Event::Balances(crate::Event::Endowed { account: 1, free_balance: 100 }), - Event::Balances(crate::Event::BalanceSet { who: 1, free: 100, reserved: 0 }), + system::Event::NewAccount { account: 1 }.into(), + crate::Event::Endowed { account: 1, free_balance: 100 }.into(), + crate::Event::BalanceSet { who: 1, free: 100, reserved: 0 }.into(), ] ); @@ -793,8 +793,8 @@ macro_rules! decl_tests { assert_eq!( events(), [ - Event::System(system::Event::KilledAccount { account: 1 }), - Event::Balances(crate::Event::Slashed { who: 1, amount: 100 }), + system::Event::KilledAccount { account: 1 }.into(), + crate::Event::Slashed { who: 1, amount: 100 }.into(), ] ); }); @@ -814,7 +814,7 @@ macro_rules! decl_tests { assert_eq!(Balances::slash(&1, 900), (NegativeImbalance::new(900), 0)); // Account is still alive assert!(System::account_exists(&1)); - System::assert_last_event(Event::Balances(crate::Event::Slashed { who: 1, amount: 900 })); + System::assert_last_event(crate::Event::Slashed { who: 1, amount: 900 }.into()); // SCENARIO: Slash will kill account because not enough balance left. assert_ok!(Balances::set_balance(Origin::root(), 1, 1_000, 0)); diff --git a/frame/balances/src/tests_local.rs b/frame/balances/src/tests_local.rs index cfc7f84ab3a38..d00d3cbfab525 100644 --- a/frame/balances/src/tests_local.rs +++ b/frame/balances/src/tests_local.rs @@ -157,9 +157,9 @@ fn emit_events_with_no_existential_deposit_suicide_with_dust() { assert_eq!( events(), [ - Event::System(system::Event::NewAccount { account: 1 }), - Event::Balances(crate::Event::Endowed { account: 1, free_balance: 100 }), - Event::Balances(crate::Event::BalanceSet { who: 1, free: 100, reserved: 0 }), + system::Event::NewAccount { account: 1 }.into(), + crate::Event::Endowed { account: 1, free_balance: 100 }.into(), + crate::Event::BalanceSet { who: 1, free: 100, reserved: 0 }.into(), ] ); @@ -167,7 +167,7 @@ fn emit_events_with_no_existential_deposit_suicide_with_dust() { assert_eq!(res, (NegativeImbalance::new(98), 0)); // no events - assert_eq!(events(), [Event::Balances(crate::Event::Slashed { who: 1, amount: 98 })]); + assert_eq!(events(), [crate::Event::Slashed { who: 1, amount: 98 }.into()]); let res = Balances::slash(&1, 1); assert_eq!(res, (NegativeImbalance::new(1), 0)); @@ -175,9 +175,9 @@ fn emit_events_with_no_existential_deposit_suicide_with_dust() { assert_eq!( events(), [ - Event::System(system::Event::KilledAccount { account: 1 }), - Event::Balances(crate::Event::DustLost { account: 1, amount: 1 }), - Event::Balances(crate::Event::Slashed { who: 1, amount: 1 }) + system::Event::KilledAccount { account: 1 }.into(), + crate::Event::DustLost { account: 1, amount: 1 }.into(), + crate::Event::Slashed { who: 1, amount: 1 }.into() ] ); }); diff --git a/frame/balances/src/tests_reentrancy.rs b/frame/balances/src/tests_reentrancy.rs index 7037e9615afd8..3d4ad95f8ed50 100644 --- a/frame/balances/src/tests_reentrancy.rs +++ b/frame/balances/src/tests_reentrancy.rs @@ -167,16 +167,9 @@ fn transfer_dust_removal_tst1_should_work() { // Verify the events assert_eq!(System::events().len(), 12); - System::assert_has_event(Event::Balances(crate::Event::Transfer { - from: 2, - to: 3, - amount: 450, - })); - System::assert_has_event(Event::Balances(crate::Event::DustLost { - account: 2, - amount: 50, - })); - System::assert_has_event(Event::Balances(crate::Event::Deposit { who: 1, amount: 50 })); + System::assert_has_event(crate::Event::Transfer { from: 2, to: 3, amount: 450 }.into()); + System::assert_has_event(crate::Event::DustLost { account: 2, amount: 50 }.into()); + System::assert_has_event(crate::Event::Deposit { who: 1, amount: 50 }.into()); }); } @@ -202,16 +195,9 @@ fn transfer_dust_removal_tst2_should_work() { // Verify the events assert_eq!(System::events().len(), 10); - System::assert_has_event(Event::Balances(crate::Event::Transfer { - from: 2, - to: 1, - amount: 450, - })); - System::assert_has_event(Event::Balances(crate::Event::DustLost { - account: 2, - amount: 50, - })); - System::assert_has_event(Event::Balances(crate::Event::Deposit { who: 1, amount: 50 })); + System::assert_has_event(crate::Event::Transfer { from: 2, to: 1, amount: 450 }.into()); + System::assert_has_event(crate::Event::DustLost { account: 2, amount: 50 }.into()); + System::assert_has_event(crate::Event::Deposit { who: 1, amount: 50 }.into()); }); } @@ -246,18 +232,18 @@ fn repatriating_reserved_balance_dust_removal_should_work() { // Verify the events assert_eq!(System::events().len(), 11); - System::assert_has_event(Event::Balances(crate::Event::ReserveRepatriated { - from: 2, - to: 1, - amount: 450, - destination_status: Status::Free, - })); + System::assert_has_event( + crate::Event::ReserveRepatriated { + from: 2, + to: 1, + amount: 450, + destination_status: Status::Free, + } + .into(), + ); - System::assert_has_event(Event::Balances(crate::Event::DustLost { - account: 2, - amount: 50, - })); + System::assert_has_event(crate::Event::DustLost { account: 2, amount: 50 }.into()); - System::assert_last_event(Event::Balances(crate::Event::Deposit { who: 1, amount: 50 })); + System::assert_last_event(crate::Event::Deposit { who: 1, amount: 50 }.into()); }); } diff --git a/frame/bounties/src/tests.rs b/frame/bounties/src/tests.rs index 9a84bd687abc1..03a31ec6bccd6 100644 --- a/frame/bounties/src/tests.rs +++ b/frame/bounties/src/tests.rs @@ -169,7 +169,7 @@ fn last_event() -> BountiesEvent { System::events() .into_iter() .map(|r| r.event) - .filter_map(|e| if let Event::Bounties(inner) = e { Some(inner) } else { None }) + .filter_map(|e| if let Event::Bounties(inner) = e { Some(*inner) } else { None }) .last() .unwrap() } diff --git a/frame/child-bounties/src/tests.rs b/frame/child-bounties/src/tests.rs index 61545561a26c3..2ac00b1e44afd 100644 --- a/frame/child-bounties/src/tests.rs +++ b/frame/child-bounties/src/tests.rs @@ -175,7 +175,7 @@ fn last_event() -> ChildBountiesEvent { System::events() .into_iter() .map(|r| r.event) - .filter_map(|e| if let Event::ChildBounties(inner) = e { Some(inner) } else { None }) + .filter_map(|e| if let Event::ChildBounties(inner) = e { Some(*inner) } else { None }) .last() .unwrap() } diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index a8abfb0c52358..b13d8b9da328a 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -216,32 +216,41 @@ fn close_works() { assert_eq!( System::events(), vec![ - record(Event::Collective(CollectiveEvent::Proposed { - account: 1, - proposal_index: 0, - proposal_hash: hash, - threshold: 3 - })), - record(Event::Collective(CollectiveEvent::Voted { - account: 1, - proposal_hash: hash, - voted: true, - yes: 1, - no: 0 - })), - record(Event::Collective(CollectiveEvent::Voted { - account: 2, - proposal_hash: hash, - voted: true, - yes: 2, - no: 0 - })), - record(Event::Collective(CollectiveEvent::Closed { - proposal_hash: hash, - yes: 2, - no: 1 - })), - record(Event::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })) + record(Event::Collective( + CollectiveEvent::Proposed { + account: 1, + proposal_index: 0, + proposal_hash: hash, + threshold: 3 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Voted { + account: 1, + proposal_hash: hash, + voted: true, + yes: 1, + no: 0 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Voted { + account: 2, + proposal_hash: hash, + voted: true, + yes: 2, + no: 0 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Closed { proposal_hash: hash, yes: 2, no: 1 }.into() + )), + record(Event::Collective( + CollectiveEvent::Disapproved { proposal_hash: hash }.into() + )) ] ); }); @@ -336,32 +345,41 @@ fn close_with_prime_works() { assert_eq!( System::events(), vec![ - record(Event::Collective(CollectiveEvent::Proposed { - account: 1, - proposal_index: 0, - proposal_hash: hash, - threshold: 3 - })), - record(Event::Collective(CollectiveEvent::Voted { - account: 1, - proposal_hash: hash, - voted: true, - yes: 1, - no: 0 - })), - record(Event::Collective(CollectiveEvent::Voted { - account: 2, - proposal_hash: hash, - voted: true, - yes: 2, - no: 0 - })), - record(Event::Collective(CollectiveEvent::Closed { - proposal_hash: hash, - yes: 2, - no: 1 - })), - record(Event::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })) + record(Event::Collective( + CollectiveEvent::Proposed { + account: 1, + proposal_index: 0, + proposal_hash: hash, + threshold: 3 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Voted { + account: 1, + proposal_hash: hash, + voted: true, + yes: 1, + no: 0 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Voted { + account: 2, + proposal_hash: hash, + voted: true, + yes: 2, + no: 0 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Closed { proposal_hash: hash, yes: 2, no: 1 }.into() + )), + record(Event::Collective( + CollectiveEvent::Disapproved { proposal_hash: hash }.into() + )) ] ); }); @@ -396,36 +414,46 @@ fn close_with_voting_prime_works() { assert_eq!( System::events(), vec![ - record(Event::Collective(CollectiveEvent::Proposed { - account: 1, - proposal_index: 0, - proposal_hash: hash, - threshold: 3 - })), - record(Event::Collective(CollectiveEvent::Voted { - account: 1, - proposal_hash: hash, - voted: true, - yes: 1, - no: 0 - })), - record(Event::Collective(CollectiveEvent::Voted { - account: 2, - proposal_hash: hash, - voted: true, - yes: 2, - no: 0 - })), - record(Event::Collective(CollectiveEvent::Closed { - proposal_hash: hash, - yes: 3, - no: 0 - })), - record(Event::Collective(CollectiveEvent::Approved { proposal_hash: hash })), - record(Event::Collective(CollectiveEvent::Executed { - proposal_hash: hash, - result: Err(DispatchError::BadOrigin) - })) + record(Event::Collective( + CollectiveEvent::Proposed { + account: 1, + proposal_index: 0, + proposal_hash: hash, + threshold: 3 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Voted { + account: 1, + proposal_hash: hash, + voted: true, + yes: 1, + no: 0 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Voted { + account: 2, + proposal_hash: hash, + voted: true, + yes: 2, + no: 0 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Closed { proposal_hash: hash, yes: 3, no: 0 }.into() + )), + record(Event::Collective(CollectiveEvent::Approved { proposal_hash: hash }.into())), + record(Event::Collective( + CollectiveEvent::Executed { + proposal_hash: hash, + result: Err(DispatchError::BadOrigin) + } + .into() + )) ] ); }); @@ -467,45 +495,58 @@ fn close_with_no_prime_but_majority_works() { assert_eq!( System::events(), vec![ - record(Event::CollectiveMajority(CollectiveEvent::Proposed { - account: 1, - proposal_index: 0, - proposal_hash: hash, - threshold: 5 - })), - record(Event::CollectiveMajority(CollectiveEvent::Voted { - account: 1, - proposal_hash: hash, - voted: true, - yes: 1, - no: 0 - })), - record(Event::CollectiveMajority(CollectiveEvent::Voted { - account: 2, - proposal_hash: hash, - voted: true, - yes: 2, - no: 0 - })), - record(Event::CollectiveMajority(CollectiveEvent::Voted { - account: 3, - proposal_hash: hash, - voted: true, - yes: 3, - no: 0 - })), - record(Event::CollectiveMajority(CollectiveEvent::Closed { - proposal_hash: hash, - yes: 5, - no: 0 - })), - record(Event::CollectiveMajority(CollectiveEvent::Approved { - proposal_hash: hash - })), - record(Event::CollectiveMajority(CollectiveEvent::Executed { - proposal_hash: hash, - result: Err(DispatchError::BadOrigin) - })) + record(Event::CollectiveMajority( + CollectiveEvent::Proposed { + account: 1, + proposal_index: 0, + proposal_hash: hash, + threshold: 5 + } + .into() + )), + record(Event::CollectiveMajority( + CollectiveEvent::Voted { + account: 1, + proposal_hash: hash, + voted: true, + yes: 1, + no: 0 + } + .into() + )), + record(Event::CollectiveMajority( + CollectiveEvent::Voted { + account: 2, + proposal_hash: hash, + voted: true, + yes: 2, + no: 0 + } + .into() + )), + record(Event::CollectiveMajority( + CollectiveEvent::Voted { + account: 3, + proposal_hash: hash, + voted: true, + yes: 3, + no: 0 + } + .into() + )), + record(Event::CollectiveMajority( + CollectiveEvent::Closed { proposal_hash: hash, yes: 5, no: 0 }.into() + )), + record(Event::CollectiveMajority( + CollectiveEvent::Approved { proposal_hash: hash }.into() + )), + record(Event::CollectiveMajority( + CollectiveEvent::Executed { + proposal_hash: hash, + result: Err(DispatchError::BadOrigin) + } + .into() + )) ] ); }); @@ -629,12 +670,15 @@ fn propose_works() { assert_eq!( System::events(), - vec![record(Event::Collective(CollectiveEvent::Proposed { - account: 1, - proposal_index: 0, - proposal_hash: hash, - threshold: 3 - }))] + vec![record(Event::Collective( + CollectiveEvent::Proposed { + account: 1, + proposal_index: 0, + proposal_hash: hash, + threshold: 3 + } + .into() + ))] ); }); } @@ -793,26 +837,35 @@ fn motions_vote_after_works() { assert_eq!( System::events(), vec![ - record(Event::Collective(CollectiveEvent::Proposed { - account: 1, - proposal_index: 0, - proposal_hash: hash, - threshold: 2 - })), - record(Event::Collective(CollectiveEvent::Voted { - account: 1, - proposal_hash: hash, - voted: true, - yes: 1, - no: 0 - })), - record(Event::Collective(CollectiveEvent::Voted { - account: 1, - proposal_hash: hash, - voted: false, - yes: 0, - no: 1 - })), + record(Event::Collective( + CollectiveEvent::Proposed { + account: 1, + proposal_index: 0, + proposal_hash: hash, + threshold: 2 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Voted { + account: 1, + proposal_hash: hash, + voted: true, + yes: 1, + no: 0 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Voted { + account: 1, + proposal_hash: hash, + voted: false, + yes: 0, + no: 1 + } + .into() + )), ] ); }); @@ -926,36 +979,46 @@ fn motions_approval_with_enough_votes_and_lower_voting_threshold_works() { assert_eq!( System::events(), vec![ - record(Event::Collective(CollectiveEvent::Proposed { - account: 1, - proposal_index: 0, - proposal_hash: hash, - threshold: 2 - })), - record(Event::Collective(CollectiveEvent::Voted { - account: 1, - proposal_hash: hash, - voted: true, - yes: 1, - no: 0 - })), - record(Event::Collective(CollectiveEvent::Voted { - account: 2, - proposal_hash: hash, - voted: true, - yes: 2, - no: 0 - })), - record(Event::Collective(CollectiveEvent::Closed { - proposal_hash: hash, - yes: 2, - no: 0 - })), - record(Event::Collective(CollectiveEvent::Approved { proposal_hash: hash })), - record(Event::Collective(CollectiveEvent::Executed { - proposal_hash: hash, - result: Err(DispatchError::BadOrigin) - })), + record(Event::Collective( + CollectiveEvent::Proposed { + account: 1, + proposal_index: 0, + proposal_hash: hash, + threshold: 2 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Voted { + account: 1, + proposal_hash: hash, + voted: true, + yes: 1, + no: 0 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Voted { + account: 2, + proposal_hash: hash, + voted: true, + yes: 2, + no: 0 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Closed { proposal_hash: hash, yes: 2, no: 0 }.into() + )), + record(Event::Collective(CollectiveEvent::Approved { proposal_hash: hash }.into())), + record(Event::Collective( + CollectiveEvent::Executed { + proposal_hash: hash, + result: Err(DispatchError::BadOrigin) + } + .into() + )), ] ); @@ -975,44 +1038,55 @@ fn motions_approval_with_enough_votes_and_lower_voting_threshold_works() { assert_eq!( System::events(), vec![ - record(Event::Collective(CollectiveEvent::Proposed { - account: 1, - proposal_index: 1, - proposal_hash: hash, - threshold: 2 - })), - record(Event::Collective(CollectiveEvent::Voted { - account: 1, - proposal_hash: hash, - voted: true, - yes: 1, - no: 0 - })), - record(Event::Collective(CollectiveEvent::Voted { - account: 2, - proposal_hash: hash, - voted: true, - yes: 2, - no: 0 - })), - record(Event::Collective(CollectiveEvent::Voted { - account: 3, - proposal_hash: hash, - voted: true, - yes: 3, - no: 0 - })), - record(Event::Collective(CollectiveEvent::Closed { - proposal_hash: hash, - yes: 3, - no: 0 - })), - record(Event::Collective(CollectiveEvent::Approved { proposal_hash: hash })), - record(Event::Democracy(mock_democracy::pallet::Event::::ExternalProposed)), - record(Event::Collective(CollectiveEvent::Executed { - proposal_hash: hash, - result: Ok(()) - })), + record(Event::Collective( + CollectiveEvent::Proposed { + account: 1, + proposal_index: 1, + proposal_hash: hash, + threshold: 2 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Voted { + account: 1, + proposal_hash: hash, + voted: true, + yes: 1, + no: 0 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Voted { + account: 2, + proposal_hash: hash, + voted: true, + yes: 2, + no: 0 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Voted { + account: 3, + proposal_hash: hash, + voted: true, + yes: 3, + no: 0 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Closed { proposal_hash: hash, yes: 3, no: 0 }.into() + )), + record(Event::Collective(CollectiveEvent::Approved { proposal_hash: hash }.into())), + record(Event::Democracy( + mock_democracy::pallet::Event::::ExternalProposed.into() + )), + record(Event::Collective( + CollectiveEvent::Executed { proposal_hash: hash, result: Ok(()) }.into() + )), ] ); }); @@ -1038,32 +1112,41 @@ fn motions_disapproval_works() { assert_eq!( System::events(), vec![ - record(Event::Collective(CollectiveEvent::Proposed { - account: 1, - proposal_index: 0, - proposal_hash: hash, - threshold: 3 - })), - record(Event::Collective(CollectiveEvent::Voted { - account: 1, - proposal_hash: hash, - voted: true, - yes: 1, - no: 0 - })), - record(Event::Collective(CollectiveEvent::Voted { - account: 2, - proposal_hash: hash, - voted: false, - yes: 1, - no: 1 - })), - record(Event::Collective(CollectiveEvent::Closed { - proposal_hash: hash, - yes: 1, - no: 1 - })), - record(Event::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })), + record(Event::Collective( + CollectiveEvent::Proposed { + account: 1, + proposal_index: 0, + proposal_hash: hash, + threshold: 3 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Voted { + account: 1, + proposal_hash: hash, + voted: true, + yes: 1, + no: 0 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Voted { + account: 2, + proposal_hash: hash, + voted: false, + yes: 1, + no: 1 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Closed { proposal_hash: hash, yes: 1, no: 1 }.into() + )), + record(Event::Collective( + CollectiveEvent::Disapproved { proposal_hash: hash }.into() + )), ] ); }); @@ -1089,36 +1172,46 @@ fn motions_approval_works() { assert_eq!( System::events(), vec![ - record(Event::Collective(CollectiveEvent::Proposed { - account: 1, - proposal_index: 0, - proposal_hash: hash, - threshold: 2 - })), - record(Event::Collective(CollectiveEvent::Voted { - account: 1, - proposal_hash: hash, - voted: true, - yes: 1, - no: 0 - })), - record(Event::Collective(CollectiveEvent::Voted { - account: 2, - proposal_hash: hash, - voted: true, - yes: 2, - no: 0 - })), - record(Event::Collective(CollectiveEvent::Closed { - proposal_hash: hash, - yes: 2, - no: 0 - })), - record(Event::Collective(CollectiveEvent::Approved { proposal_hash: hash })), - record(Event::Collective(CollectiveEvent::Executed { - proposal_hash: hash, - result: Err(DispatchError::BadOrigin) - })), + record(Event::Collective( + CollectiveEvent::Proposed { + account: 1, + proposal_index: 0, + proposal_hash: hash, + threshold: 2 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Voted { + account: 1, + proposal_hash: hash, + voted: true, + yes: 1, + no: 0 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Voted { + account: 2, + proposal_hash: hash, + voted: true, + yes: 2, + no: 0 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Closed { proposal_hash: hash, yes: 2, no: 0 }.into() + )), + record(Event::Collective(CollectiveEvent::Approved { proposal_hash: hash }.into())), + record(Event::Collective( + CollectiveEvent::Executed { + proposal_hash: hash, + result: Err(DispatchError::BadOrigin) + } + .into() + )), ] ); }); @@ -1139,12 +1232,15 @@ fn motion_with_no_votes_closes_with_disapproval() { )); assert_eq!( System::events()[0], - record(Event::Collective(CollectiveEvent::Proposed { - account: 1, - proposal_index: 0, - proposal_hash: hash, - threshold: 3 - })) + record(Event::Collective( + CollectiveEvent::Proposed { + account: 1, + proposal_index: 0, + proposal_hash: hash, + threshold: 3 + } + .into() + )) ); // Closing the motion too early is not possible because it has neither @@ -1163,15 +1259,13 @@ fn motion_with_no_votes_closes_with_disapproval() { // Events show that the close ended in a disapproval. assert_eq!( System::events()[1], - record(Event::Collective(CollectiveEvent::Closed { - proposal_hash: hash, - yes: 0, - no: 3 - })) + record(Event::Collective( + CollectiveEvent::Closed { proposal_hash: hash, yes: 0, no: 3 }.into() + )) ); assert_eq!( System::events()[2], - record(Event::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })) + record(Event::Collective(CollectiveEvent::Disapproved { proposal_hash: hash }.into())) ); }) } @@ -1231,27 +1325,38 @@ fn disapprove_proposal_works() { assert_eq!( System::events(), vec![ - record(Event::Collective(CollectiveEvent::Proposed { - account: 1, - proposal_index: 0, - proposal_hash: hash, - threshold: 2 - })), - record(Event::Collective(CollectiveEvent::Voted { - account: 1, - proposal_hash: hash, - voted: true, - yes: 1, - no: 0 - })), - record(Event::Collective(CollectiveEvent::Voted { - account: 2, - proposal_hash: hash, - voted: true, - yes: 2, - no: 0 - })), - record(Event::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })), + record(Event::Collective( + CollectiveEvent::Proposed { + account: 1, + proposal_index: 0, + proposal_hash: hash, + threshold: 2 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Voted { + account: 1, + proposal_hash: hash, + voted: true, + yes: 1, + no: 0 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Voted { + account: 2, + proposal_hash: hash, + voted: true, + yes: 2, + no: 0 + } + .into() + )), + record(Event::Collective( + CollectiveEvent::Disapproved { proposal_hash: hash }.into() + )), ] ); }) diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 7aa5c0b731fad..26ca2e4bb446d 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -1289,7 +1289,7 @@ mod tests { System::events() .into_iter() .filter_map(|meta| match meta.event { - MetaEvent::Contracts(contract_event) => Some(contract_event), + MetaEvent::Contracts(contract_event) => Some(*contract_event), _ => None, }) .collect() @@ -2434,10 +2434,9 @@ mod tests { System::events(), vec![EventRecord { phase: Phase::Initialization, - event: MetaEvent::System(frame_system::Event::Remarked { - sender: BOB, - hash: remark_hash - }), + event: MetaEvent::System( + frame_system::Event::Remarked { sender: BOB, hash: remark_hash }.into() + ), topics: vec![], },] ); @@ -2506,23 +2505,25 @@ mod tests { vec![ EventRecord { phase: Phase::Initialization, - event: MetaEvent::System(frame_system::Event::Remarked { - sender: BOB, - hash: remark_hash - }), + event: MetaEvent::System( + frame_system::Event::Remarked { sender: BOB, hash: remark_hash }.into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: MetaEvent::Utility(pallet_utility::Event::ItemCompleted), + event: MetaEvent::Utility(pallet_utility::Event::ItemCompleted.into()), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: MetaEvent::Utility(pallet_utility::Event::BatchInterrupted { - index: 1, - error: frame_system::Error::::CallFiltered.into() - },), + event: MetaEvent::Utility( + pallet_utility::Event::BatchInterrupted { + index: 1, + error: frame_system::Error::::CallFiltered.into() + } + .into(), + ), topics: vec![], }, ] diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index ce59f5bb858ac..bf909a81c5fd1 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -407,57 +407,71 @@ fn instantiate_and_call_and_deposit_event() { vec![ EventRecord { phase: Phase::Initialization, - event: Event::System(frame_system::Event::NewAccount { account: addr.clone() }), + event: Event::System( + frame_system::Event::NewAccount { account: addr.clone() }.into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Endowed { - account: addr.clone(), - free_balance: min_balance, - }), + event: Event::Balances( + pallet_balances::Event::Endowed { + account: addr.clone(), + free_balance: min_balance, + } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { - from: ALICE, - to: addr.clone(), - amount: min_balance, - }), + event: Event::Balances( + pallet_balances::Event::Transfer { + from: ALICE, + to: addr.clone(), + amount: min_balance, + } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Reserved { - who: addr.clone(), - amount: min_balance, - }), + event: Event::Balances( + pallet_balances::Event::Reserved { who: addr.clone(), amount: min_balance } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { - from: ALICE, - to: addr.clone(), - amount: value, - }), + event: Event::Balances( + pallet_balances::Event::Transfer { + from: ALICE, + to: addr.clone(), + amount: value, + } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::ContractEmitted { - contract: addr.clone(), - data: vec![1, 2, 3, 4] - }), + event: Event::Contracts( + crate::Event::ContractEmitted { + contract: addr.clone(), + data: vec![1, 2, 3, 4] + } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::Instantiated { - deployer: ALICE, - contract: addr.clone() - }), + event: Event::Contracts( + crate::Event::Instantiated { deployer: ALICE, contract: addr.clone() } + .into() + ), topics: vec![], }, ] @@ -699,60 +713,78 @@ fn deploy_and_call_other_contract() { vec![ EventRecord { phase: Phase::Initialization, - event: Event::System(frame_system::Event::NewAccount { - account: callee_addr.clone() - }), + event: Event::System( + frame_system::Event::NewAccount { account: callee_addr.clone() }.into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Endowed { - account: callee_addr.clone(), - free_balance: min_balance, - }), + event: Event::Balances( + pallet_balances::Event::Endowed { + account: callee_addr.clone(), + free_balance: min_balance, + } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { - from: ALICE, - to: callee_addr.clone(), - amount: min_balance, - }), + event: Event::Balances( + pallet_balances::Event::Transfer { + from: ALICE, + to: callee_addr.clone(), + amount: min_balance, + } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Reserved { - who: callee_addr.clone(), - amount: min_balance, - }), + event: Event::Balances( + pallet_balances::Event::Reserved { + who: callee_addr.clone(), + amount: min_balance, + } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { - from: caller_addr.clone(), - to: callee_addr.clone(), - amount: 32768, // hard coded in wasm - }), + event: Event::Balances( + pallet_balances::Event::Transfer { + from: caller_addr.clone(), + to: callee_addr.clone(), + amount: 32768, // hard coded in wasm + } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::Instantiated { - deployer: caller_addr.clone(), - contract: callee_addr.clone(), - }), + event: Event::Contracts( + crate::Event::Instantiated { + deployer: caller_addr.clone(), + contract: callee_addr.clone(), + } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { - from: caller_addr.clone(), - to: callee_addr.clone(), - amount: 32768, - }), + event: Event::Balances( + pallet_balances::Event::Transfer { + from: caller_addr.clone(), + to: callee_addr.clone(), + amount: 32768, + } + .into() + ), topics: vec![], }, ] @@ -948,20 +980,22 @@ fn cannot_self_destruct_by_refund_after_slash() { vec![ EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Slashed { - who: addr.clone(), - amount: 90, - }), + event: Event::Balances( + pallet_balances::Event::Slashed { who: addr.clone(), amount: 90 }.into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::ReserveRepatriated { - from: addr.clone(), - to: ALICE, - amount: 10, - destination_status: BalanceStatus::Free, - }), + event: Event::Balances( + pallet_balances::Event::ReserveRepatriated { + from: addr.clone(), + to: ALICE, + amount: 10, + destination_status: BalanceStatus::Free, + } + .into() + ), topics: vec![], }, ] @@ -1048,36 +1082,42 @@ fn self_destruct_works() { vec![ EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { - from: addr.clone(), - to: DJANGO, - amount: 100_000, - }), + event: Event::Balances( + pallet_balances::Event::Transfer { + from: addr.clone(), + to: DJANGO, + amount: 100_000, + } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::Terminated { - contract: addr.clone(), - beneficiary: DJANGO - }), + event: Event::Contracts( + crate::Event::Terminated { contract: addr.clone(), beneficiary: DJANGO } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::System(frame_system::Event::KilledAccount { - account: addr.clone() - }), + event: Event::System( + frame_system::Event::KilledAccount { account: addr.clone() }.into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::ReserveRepatriated { - from: addr.clone(), - to: ALICE, - amount: 1_000, - destination_status: BalanceStatus::Free, - }), + event: Event::Balances( + pallet_balances::Event::ReserveRepatriated { + from: addr.clone(), + to: ALICE, + amount: 1_000, + destination_status: BalanceStatus::Free, + } + .into() + ), topics: vec![], }, ], @@ -2352,15 +2392,14 @@ fn upload_code_works() { vec![ EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Reserved { - who: ALICE, - amount: 240, - }), + event: Event::Balances( + pallet_balances::Event::Reserved { who: ALICE, amount: 240 }.into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::CodeStored { code_hash }), + event: Event::Contracts(crate::Event::CodeStored { code_hash }.into()), topics: vec![], }, ] @@ -2431,28 +2470,26 @@ fn remove_code_works() { vec![ EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Reserved { - who: ALICE, - amount: 240, - }), + event: Event::Balances( + pallet_balances::Event::Reserved { who: ALICE, amount: 240 }.into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::CodeStored { code_hash }), + event: Event::Contracts(crate::Event::CodeStored { code_hash }.into()), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Unreserved { - who: ALICE, - amount: 240, - }), + event: Event::Balances( + pallet_balances::Event::Unreserved { who: ALICE, amount: 240 }.into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::CodeRemoved { code_hash }), + event: Event::Contracts(crate::Event::CodeRemoved { code_hash }.into()), topics: vec![], }, ] @@ -2486,15 +2523,14 @@ fn remove_code_wrong_origin() { vec![ EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Reserved { - who: ALICE, - amount: 240, - }), + event: Event::Balances( + pallet_balances::Event::Reserved { who: ALICE, amount: 240 }.into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::CodeStored { code_hash }), + event: Event::Contracts(crate::Event::CodeStored { code_hash }.into()), topics: vec![], }, ] @@ -2587,53 +2623,60 @@ fn instantiate_with_zero_balance_works() { vec![ EventRecord { phase: Phase::Initialization, - event: Event::System(frame_system::Event::NewAccount { account: addr.clone() }), + event: Event::System( + frame_system::Event::NewAccount { account: addr.clone() }.into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Endowed { - account: addr.clone(), - free_balance: min_balance, - }), + event: Event::Balances( + pallet_balances::Event::Endowed { + account: addr.clone(), + free_balance: min_balance, + } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { - from: ALICE, - to: addr.clone(), - amount: min_balance, - }), + event: Event::Balances( + pallet_balances::Event::Transfer { + from: ALICE, + to: addr.clone(), + amount: min_balance, + } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Reserved { - who: addr.clone(), - amount: min_balance, - }), + event: Event::Balances( + pallet_balances::Event::Reserved { who: addr.clone(), amount: min_balance } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Reserved { - who: ALICE, - amount: 240, - }), + event: Event::Balances( + pallet_balances::Event::Reserved { who: ALICE, amount: 240 }.into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::CodeStored { code_hash }), + event: Event::Contracts(crate::Event::CodeStored { code_hash }.into()), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::Instantiated { - deployer: ALICE, - contract: addr.clone(), - }), + event: Event::Contracts( + crate::Event::Instantiated { deployer: ALICE, contract: addr.clone() } + .into() + ), topics: vec![], }, ] @@ -2678,62 +2721,72 @@ fn instantiate_with_below_existential_deposit_works() { vec![ EventRecord { phase: Phase::Initialization, - event: Event::System(frame_system::Event::NewAccount { account: addr.clone() }), + event: Event::System( + frame_system::Event::NewAccount { account: addr.clone() }.into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Endowed { - account: addr.clone(), - free_balance: min_balance, - }), + event: Event::Balances( + pallet_balances::Event::Endowed { + account: addr.clone(), + free_balance: min_balance, + } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { - from: ALICE, - to: addr.clone(), - amount: min_balance, - }), + event: Event::Balances( + pallet_balances::Event::Transfer { + from: ALICE, + to: addr.clone(), + amount: min_balance, + } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Reserved { - who: addr.clone(), - amount: min_balance, - }), + event: Event::Balances( + pallet_balances::Event::Reserved { who: addr.clone(), amount: min_balance } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { - from: ALICE, - to: addr.clone(), - amount: 50, - }), + event: Event::Balances( + pallet_balances::Event::Transfer { + from: ALICE, + to: addr.clone(), + amount: 50, + } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Reserved { - who: ALICE, - amount: 240, - }), + event: Event::Balances( + pallet_balances::Event::Reserved { who: ALICE, amount: 240 }.into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::CodeStored { code_hash }), + event: Event::Contracts(crate::Event::CodeStored { code_hash }.into()), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::Instantiated { - deployer: ALICE, - contract: addr.clone(), - }), + event: Event::Contracts( + crate::Event::Instantiated { deployer: ALICE, contract: addr.clone() } + .into() + ), topics: vec![], }, ] @@ -2807,55 +2860,67 @@ fn storage_deposit_works() { vec![ EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { - from: ALICE, - to: addr.clone(), - amount: 42, - }), + event: Event::Balances( + pallet_balances::Event::Transfer { + from: ALICE, + to: addr.clone(), + amount: 42, + } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { - from: ALICE, - to: addr.clone(), - amount: charged0, - }), + event: Event::Balances( + pallet_balances::Event::Transfer { + from: ALICE, + to: addr.clone(), + amount: charged0, + } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Reserved { - who: addr.clone(), - amount: charged0, - }), + event: Event::Balances( + pallet_balances::Event::Reserved { who: addr.clone(), amount: charged0 } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { - from: ALICE, - to: addr.clone(), - amount: charged1, - }), + event: Event::Balances( + pallet_balances::Event::Transfer { + from: ALICE, + to: addr.clone(), + amount: charged1, + } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Reserved { - who: addr.clone(), - amount: charged1, - }), + event: Event::Balances( + pallet_balances::Event::Reserved { who: addr.clone(), amount: charged1 } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::ReserveRepatriated { - from: addr.clone(), - to: ALICE, - amount: refunded0, - destination_status: BalanceStatus::Free, - }), + event: Event::Balances( + pallet_balances::Event::ReserveRepatriated { + from: addr.clone(), + to: ALICE, + amount: refunded0, + destination_status: BalanceStatus::Free, + } + .into() + ), topics: vec![], }, ] @@ -2931,39 +2996,50 @@ fn call_after_killed_account_needs_funding() { vec![ EventRecord { phase: Phase::Initialization, - event: Event::System(frame_system::Event::KilledAccount { - account: addr.clone() - }), + event: Event::System( + frame_system::Event::KilledAccount { account: addr.clone() }.into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Slashed { - who: addr.clone(), - amount: min_balance + 700 - }), + event: Event::Balances( + pallet_balances::Event::Slashed { + who: addr.clone(), + amount: min_balance + 700 + } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::System(frame_system::Event::NewAccount { account: addr.clone() }), + event: Event::System( + frame_system::Event::NewAccount { account: addr.clone() }.into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Endowed { - account: addr.clone(), - free_balance: min_balance - }), + event: Event::Balances( + pallet_balances::Event::Endowed { + account: addr.clone(), + free_balance: min_balance + } + .into() + ), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { - from: ALICE, - to: addr.clone(), - amount: min_balance - }), + event: Event::Balances( + pallet_balances::Event::Transfer { + from: ALICE, + to: addr.clone(), + amount: min_balance + } + .into() + ), topics: vec![], }, ] @@ -3141,11 +3217,14 @@ fn set_code_hash() { System::events().pop().unwrap(), EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::ContractCodeUpdated { - contract: contract_addr.clone(), - new_code_hash: new_code_hash.clone(), - old_code_hash: code_hash.clone(), - }), + event: Event::Contracts( + crate::Event::ContractCodeUpdated { + contract: contract_addr.clone(), + new_code_hash: new_code_hash.clone(), + old_code_hash: code_hash.clone(), + } + .into() + ), topics: vec![], }, ); diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index d6f040363dba0..0499390135a30 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -83,7 +83,7 @@ pub(crate) fn multi_phase_events() -> Vec> { System::events() .into_iter() .map(|r| r.event) - .filter_map(|e| if let Event::MultiPhase(inner) = e { Some(inner) } else { None }) + .filter_map(|e| if let Event::MultiPhase(inner) = e { Some(*inner) } else { None }) .collect::>() } diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 4758c793cfefd..7189545ca419a 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -2163,7 +2163,7 @@ mod tests { System::set_block_number(5); Elections::on_initialize(System::block_number()); - System::assert_last_event(Event::Elections(super::Event::EmptyTerm)); + System::assert_last_event(super::Event::EmptyTerm.into()); }) } @@ -2179,9 +2179,9 @@ mod tests { System::set_block_number(5); Elections::on_initialize(System::block_number()); - System::assert_last_event(Event::Elections(super::Event::NewTerm { - new_members: vec![(4, 35), (5, 45)], - })); + System::assert_last_event( + super::Event::NewTerm { new_members: vec![(4, 35), (5, 45)] }.into(), + ); assert_eq!(members_and_stake(), vec![(4, 35), (5, 45)]); assert_eq!(runners_up_and_stake(), vec![]); @@ -2192,9 +2192,7 @@ mod tests { System::set_block_number(10); Elections::on_initialize(System::block_number()); - System::assert_last_event(Event::Elections(super::Event::NewTerm { - new_members: vec![], - })); + System::assert_last_event(super::Event::NewTerm { new_members: vec![] }.into()); // outgoing have lost their bond. assert_eq!(balances(&4), (37, 0)); @@ -2264,9 +2262,7 @@ mod tests { assert_eq!(Elections::election_rounds(), 1); assert!(members_ids().is_empty()); - System::assert_last_event(Event::Elections(super::Event::NewTerm { - new_members: vec![], - })); + System::assert_last_event(super::Event::NewTerm { new_members: vec![] }.into()); }); } @@ -2618,9 +2614,9 @@ mod tests { // 5 is an outgoing loser. will also get slashed. assert_eq!(balances(&5), (45, 2)); - System::assert_has_event(Event::Elections(super::Event::NewTerm { - new_members: vec![(4, 35), (5, 45)], - })); + System::assert_has_event( + super::Event::NewTerm { new_members: vec![(4, 35), (5, 45)] }.into(), + ); }) } diff --git a/frame/offences/src/tests.rs b/frame/offences/src/tests.rs index 49bd2fb5a6923..1c071adabc3ef 100644 --- a/frame/offences/src/tests.rs +++ b/frame/offences/src/tests.rs @@ -21,8 +21,8 @@ use super::*; use crate::mock::{ - new_test_ext, offence_reports, report_id, with_on_offence_fractions, Event, Offence, Offences, - System, KIND, + new_test_ext, offence_reports, report_id, with_on_offence_fractions, Offence, Offences, System, + KIND, }; use frame_system::{EventRecord, Phase}; use sp_runtime::Perbill; @@ -114,10 +114,7 @@ fn should_deposit_event() { System::events(), vec![EventRecord { phase: Phase::Initialization, - event: Event::Offences(crate::Event::Offence { - kind: KIND, - timeslot: time_slot.encode() - }), + event: crate::Event::Offence { kind: KIND, timeslot: time_slot.encode() }.into(), topics: vec![], }] ); @@ -148,10 +145,7 @@ fn doesnt_deposit_event_for_dups() { System::events(), vec![EventRecord { phase: Phase::Initialization, - event: Event::Offences(crate::Event::Offence { - kind: KIND, - timeslot: time_slot.encode() - }), + event: crate::Event::Offence { kind: KIND, timeslot: time_slot.encode() }.into(), topics: vec![], }] ); diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index bb90aded852ee..92325df67bea5 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -857,7 +857,7 @@ pub(crate) fn staking_events() -> Vec> { System::events() .into_iter() .map(|r| r.event) - .filter_map(|e| if let Event::Staking(inner) = e { Some(inner) } else { None }) + .filter_map(|e| if let Event::Staking(inner) = e { Some(*inner) } else { None }) .collect() } diff --git a/frame/sudo/src/tests.rs b/frame/sudo/src/tests.rs index 84c8e0c5c254e..77d7893c59248 100644 --- a/frame/sudo/src/tests.rs +++ b/frame/sudo/src/tests.rs @@ -19,10 +19,7 @@ use super::*; use frame_support::{assert_noop, assert_ok}; -use mock::{ - new_test_ext, Call, Event as TestEvent, Logger, LoggerCall, Origin, Sudo, SudoCall, System, - Test, -}; +use mock::{new_test_ext, Call, Logger, LoggerCall, Origin, Sudo, SudoCall, System, Test}; #[test] fn test_setup_works() { @@ -58,7 +55,7 @@ fn sudo_emits_events_correctly() { // Should emit event to indicate success when called with the root `key` and `call` is `Ok`. let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1 })); assert_ok!(Sudo::sudo(Origin::signed(1), call)); - System::assert_has_event(TestEvent::Sudo(Event::Sudid { sudo_result: Ok(()) })); + System::assert_has_event(Event::Sudid { sudo_result: Ok(()) }.into()); }) } @@ -96,7 +93,7 @@ fn sudo_unchecked_weight_emits_events_correctly() { // Should emit event to indicate success when called with the root `key` and `call` is `Ok`. let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1 })); assert_ok!(Sudo::sudo_unchecked_weight(Origin::signed(1), call, 1_000)); - System::assert_has_event(TestEvent::Sudo(Event::Sudid { sudo_result: Ok(()) })); + System::assert_has_event(Event::Sudid { sudo_result: Ok(()) }.into()); }) } @@ -123,10 +120,10 @@ fn set_key_emits_events_correctly() { // A root `key` can change the root `key`. assert_ok!(Sudo::set_key(Origin::signed(1), 2)); - System::assert_has_event(TestEvent::Sudo(Event::KeyChanged { old_sudoer: Some(1) })); + System::assert_has_event(Event::KeyChanged { old_sudoer: Some(1) }.into()); // Double check. assert_ok!(Sudo::set_key(Origin::signed(2), 4)); - System::assert_has_event(TestEvent::Sudo(Event::KeyChanged { old_sudoer: Some(2) })); + System::assert_has_event(Event::KeyChanged { old_sudoer: Some(2) }.into()); }); } @@ -161,6 +158,6 @@ fn sudo_as_emits_events_correctly() { // A non-privileged function will work when passed to `sudo_as` with the root `key`. let call = Box::new(Call::Logger(LoggerCall::non_privileged_log { i: 42, weight: 1 })); assert_ok!(Sudo::sudo_as(Origin::signed(1), 2, call)); - System::assert_has_event(TestEvent::Sudo(Event::SudoAsDone { sudo_result: Ok(()) })); + System::assert_has_event(Event::SudoAsDone { sudo_result: Ok(()) }.into()); }); } diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index 83f6a722f93aa..c17364cee8b63 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -628,7 +628,7 @@ fn transactional_works() { .iter() .map(|e| &e.event) .collect::>(), - vec![&Event::Example(pallet::Event::Something(0))], + vec![&Event::Example(pallet::Event::Something(0).into())], ); }) } @@ -884,7 +884,7 @@ fn pallet_expand_deposit_event() { .unwrap(); assert_eq!( frame_system::Pallet::::events()[0].event, - Event::Example(pallet::Event::Something(3)), + Event::Example(pallet::Event::Something(3).into()), ); }) } @@ -991,27 +991,27 @@ fn pallet_hooks_expand() { assert_eq!( frame_system::Pallet::::events()[0].event, - Event::Example(pallet::Event::Something(10)), + Event::Example(pallet::Event::Something(10).into()), ); assert_eq!( frame_system::Pallet::::events()[1].event, - Event::Example2(pallet2::Event::Something(11)), + Event::Example2(pallet2::Event::Something(11).into()), ); assert_eq!( frame_system::Pallet::::events()[2].event, - Event::Example(pallet::Event::Something(20)), + Event::Example(pallet::Event::Something(20).into()), ); assert_eq!( frame_system::Pallet::::events()[3].event, - Event::Example2(pallet2::Event::Something(21)), + Event::Example2(pallet2::Event::Something(21).into()), ); assert_eq!( frame_system::Pallet::::events()[4].event, - Event::Example(pallet::Event::Something(30)), + Event::Example(pallet::Event::Something(30).into()), ); assert_eq!( frame_system::Pallet::::events()[5].event, - Event::Example2(pallet2::Event::Something(31)), + Event::Example2(pallet2::Event::Something(31).into()), ); }) } @@ -1031,27 +1031,27 @@ fn all_pallets_type_reversed_order_is_correct() { assert_eq!( frame_system::Pallet::::events()[0].event, - Event::Example2(pallet2::Event::Something(11)), + Event::Example2(pallet2::Event::Something(11).into()), ); assert_eq!( frame_system::Pallet::::events()[1].event, - Event::Example(pallet::Event::Something(10)), + Event::Example(pallet::Event::Something(10).into()), ); assert_eq!( frame_system::Pallet::::events()[2].event, - Event::Example2(pallet2::Event::Something(21)), + Event::Example2(pallet2::Event::Something(21).into()), ); assert_eq!( frame_system::Pallet::::events()[3].event, - Event::Example(pallet::Event::Something(20)), + Event::Example(pallet::Event::Something(20).into()), ); assert_eq!( frame_system::Pallet::::events()[4].event, - Event::Example2(pallet2::Event::Something(31)), + Event::Example2(pallet2::Event::Something(31).into()), ); assert_eq!( frame_system::Pallet::::events()[5].event, - Event::Example(pallet::Event::Something(30)), + Event::Example(pallet::Event::Something(30).into()), ); }) } diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index 118794e2fa20a..d69b52a0f6d7c 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -385,7 +385,7 @@ fn pallet_expand_deposit_event() { .unwrap(); assert_eq!( frame_system::Pallet::::events()[0].event, - Event::Example(pallet::Event::Something(3)), + Event::Example(pallet::Event::Something(3).into()), ); }); @@ -396,7 +396,7 @@ fn pallet_expand_deposit_event() { .unwrap(); assert_eq!( frame_system::Pallet::::events()[0].event, - Event::Instance1Example(pallet::Event::Something(3)), + Event::Instance1Example(pallet::Event::Something(3).into()), ); }); } @@ -562,27 +562,27 @@ fn pallet_hooks_expand() { assert_eq!( frame_system::Pallet::::events()[0].event, - Event::Example(pallet::Event::Something(10)), + Event::Example(pallet::Event::Something(10).into()), ); assert_eq!( frame_system::Pallet::::events()[1].event, - Event::Instance1Example(pallet::Event::Something(11)), + Event::Instance1Example(pallet::Event::Something(11).into()), ); assert_eq!( frame_system::Pallet::::events()[2].event, - Event::Example(pallet::Event::Something(20)), + Event::Example(pallet::Event::Something(20).into()), ); assert_eq!( frame_system::Pallet::::events()[3].event, - Event::Instance1Example(pallet::Event::Something(21)), + Event::Instance1Example(pallet::Event::Something(21).into()), ); assert_eq!( frame_system::Pallet::::events()[4].event, - Event::Example(pallet::Event::Something(30)), + Event::Example(pallet::Event::Something(30).into()), ); assert_eq!( frame_system::Pallet::::events()[5].event, - Event::Instance1Example(pallet::Event::Something(31)), + Event::Instance1Example(pallet::Event::Something(31).into()), ); }) } diff --git a/frame/tips/src/tests.rs b/frame/tips/src/tests.rs index 0c58a949958fe..a01d867112504 100644 --- a/frame/tips/src/tests.rs +++ b/frame/tips/src/tests.rs @@ -175,7 +175,7 @@ fn last_event() -> TipEvent { System::events() .into_iter() .map(|r| r.event) - .filter_map(|e| if let Event::Tips(inner) = e { Some(inner) } else { None }) + .filter_map(|e| if let Event::Tips(inner) = e { Some(*inner) } else { None }) .last() .unwrap() } diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index 1462faaa07062..112527447f3f9 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -1374,15 +1374,11 @@ mod tests { )); assert_eq!(Balances::free_balance(2), 0); // Transfer Event - System::assert_has_event(Event::Balances(pallet_balances::Event::Transfer { - from: 2, - to: 3, - amount: 80, - })); + System::assert_has_event( + pallet_balances::Event::Transfer { from: 2, to: 3, amount: 80 }.into(), + ); // Killed Event - System::assert_has_event(Event::System(system::Event::KilledAccount { - account: 2, - })); + System::assert_has_event(system::Event::KilledAccount { account: 2 }.into()); }); }