Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lock events to tokens pallet #883

Merged
merged 5 commits into from
Jan 30, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use correct Event type
  • Loading branch information
sea212 committed Jan 27, 2023
commit 26634165c6c20c825e6c2eddafc253ca37afb6c4
28 changes: 14 additions & 14 deletions tokens/src/tests_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::*;
use frame_support::assert_ok;
use mock::*;

fn events() -> Vec<Event> {
fn events() -> Vec<RuntimeEvent> {
let evt = System::events().into_iter().map(|evt| evt.event).collect::<Vec<_>>();
System::reset_events();
evt
Expand Down Expand Up @@ -316,23 +316,23 @@ fn pallet_change_locks_events() {

// Locks: [10/DOT]
assert_ok!(Tokens::set_lock(ID_1, DOT, &ALICE, 10));
assert!(events().contains(&Event::Tokens(crate::Event::Locked {
assert!(events().contains(&RuntimeEvent::Tokens(crate::Event::Locked {
currency_id: DOT,
who: ALICE,
amount: 10
})));

// Locks: [15/DOT]
assert_ok!(Tokens::set_lock(ID_1, DOT, &ALICE, 15));
assert!(events().contains(&Event::Tokens(crate::Event::Locked {
assert!(events().contains(&RuntimeEvent::Tokens(crate::Event::Locked {
currency_id: DOT,
who: ALICE,
amount: 5
})));

// Locks: [15/DOT, 20/BTC]
assert_ok!(Tokens::set_lock(ID_1, BTC, &ALICE, 20));
assert!(events().contains(&Event::Tokens(crate::Event::Locked {
assert!(events().contains(&RuntimeEvent::Tokens(crate::Event::Locked {
currency_id: BTC,
who: ALICE,
amount: 20
Expand All @@ -342,8 +342,8 @@ fn pallet_change_locks_events() {
assert_ok!(Tokens::set_lock(ID_2, DOT, &ALICE, 10));
for event in events() {
match event {
Event::Tokens(crate::Event::Locked { .. }) => assert!(false, "unexpected lock event"),
Event::Tokens(crate::Event::Unlocked { .. }) => assert!(false, "unexpected unlock event"),
RuntimeEvent::Tokens(crate::Event::Locked { .. }) => assert!(false, "unexpected lock event"),
RuntimeEvent::Tokens(crate::Event::Unlocked { .. }) => assert!(false, "unexpected unlock event"),
_ => continue,
}
}
Expand All @@ -352,8 +352,8 @@ fn pallet_change_locks_events() {
assert_ok!(Tokens::set_lock(ID_2, DOT, &ALICE, 12));
for event in events() {
match event {
Event::Tokens(crate::Event::Locked { .. }) => assert!(false, "unexpected lock event"),
Event::Tokens(crate::Event::Unlocked { .. }) => assert!(false, "unexpected unlock event"),
RuntimeEvent::Tokens(crate::Event::Locked { .. }) => assert!(false, "unexpected lock event"),
RuntimeEvent::Tokens(crate::Event::Unlocked { .. }) => assert!(false, "unexpected unlock event"),
_ => continue,
}
}
Expand All @@ -362,39 +362,39 @@ fn pallet_change_locks_events() {
assert_ok!(Tokens::set_lock(ID_2, DOT, &ALICE, 10));
for event in events() {
match event {
Event::Tokens(crate::Event::Locked { .. }) => assert!(false, "unexpected lock event"),
Event::Tokens(crate::Event::Unlocked { .. }) => assert!(false, "unexpected unlock event"),
RuntimeEvent::Tokens(crate::Event::Locked { .. }) => assert!(false, "unexpected lock event"),
RuntimeEvent::Tokens(crate::Event::Unlocked { .. }) => assert!(false, "unexpected unlock event"),
_ => continue,
}
}

// Locks: [15/DOT, 20/BTC, 20/DOT]
assert_ok!(Tokens::set_lock(ID_2, DOT, &ALICE, 20));
assert!(events().contains(&Event::Tokens(crate::Event::Locked {
assert!(events().contains(&RuntimeEvent::Tokens(crate::Event::Locked {
currency_id: DOT,
who: ALICE,
amount: 5
})));

// Locks: [15/DOT, 20/BTC, 16/DOT]
assert_ok!(Tokens::set_lock(ID_2, DOT, &ALICE, 16));
assert!(events().contains(&Event::Tokens(crate::Event::Unlocked {
assert!(events().contains(&RuntimeEvent::Tokens(crate::Event::Unlocked {
currency_id: DOT,
who: ALICE,
amount: 4
})));

// Locks: [15/DOT, 12/BTC, 16/DOT]
assert_ok!(Tokens::set_lock(ID_1, BTC, &ALICE, 12));
assert!(events().contains(&Event::Tokens(crate::Event::Unlocked {
assert!(events().contains(&RuntimeEvent::Tokens(crate::Event::Unlocked {
currency_id: BTC,
who: ALICE,
amount: 8
})));

// Locks: [15/DOT, 12/BTC]
assert_ok!(Tokens::remove_lock(ID_2, DOT, &ALICE));
assert!(events().contains(&Event::Tokens(crate::Event::Unlocked {
assert!(events().contains(&RuntimeEvent::Tokens(crate::Event::Unlocked {
currency_id: DOT,
who: ALICE,
amount: 1
Expand Down