Add field names to pallet Event variants (#9993)

* convert pallet-assets events to struct types

* updated events of a couple pallets

* updated pallet event field names

* update pallet event field names

* updated events in test files

* cargo fmt

* minorfixes

* fix assertion error

* minor fix

* formatting fix

* fmt
This commit is contained in:
David Salami
2021-11-16 02:56:00 +01:00
committed by GitHub
parent fb3c7326c2
commit 120894fdb7
48 changed files with 1181 additions and 681 deletions
+38 -24
View File
@@ -211,7 +211,15 @@ fn call_transfer(dest: u64, value: u64) -> Call {
fn announcement_works() {
new_test_ext().execute_with(|| {
assert_ok!(Proxy::add_proxy(Origin::signed(1), 3, ProxyType::Any, 1));
System::assert_last_event(ProxyEvent::ProxyAdded(1, 3, ProxyType::Any, 1).into());
System::assert_last_event(
ProxyEvent::ProxyAdded {
delegator: 1,
delegatee: 3,
proxy_type: ProxyType::Any,
delay: 1,
}
.into(),
);
assert_ok!(Proxy::add_proxy(Origin::signed(2), 3, ProxyType::Any, 1));
assert_eq!(Balances::reserved_balance(3), 0);
@@ -332,12 +340,12 @@ fn filtering_works() {
let call = Box::new(call_transfer(6, 1));
assert_ok!(Proxy::proxy(Origin::signed(2), 1, None, call.clone()));
System::assert_last_event(ProxyEvent::ProxyExecuted(Ok(())).into());
System::assert_last_event(ProxyEvent::ProxyExecuted { result: Ok(()) }.into());
assert_ok!(Proxy::proxy(Origin::signed(3), 1, None, call.clone()));
System::assert_last_event(ProxyEvent::ProxyExecuted(Ok(())).into());
System::assert_last_event(ProxyEvent::ProxyExecuted { result: Ok(()) }.into());
assert_ok!(Proxy::proxy(Origin::signed(4), 1, None, call.clone()));
System::assert_last_event(
ProxyEvent::ProxyExecuted(Err(SystemError::CallFiltered.into())).into(),
ProxyEvent::ProxyExecuted { result: Err(SystemError::CallFiltered.into()) }.into(),
);
let derivative_id = Utility::derivative_account_id(1, 0);
@@ -347,31 +355,31 @@ fn filtering_works() {
let call =
Box::new(Call::Utility(UtilityCall::as_derivative { index: 0, call: inner.clone() }));
assert_ok!(Proxy::proxy(Origin::signed(2), 1, None, call.clone()));
System::assert_last_event(ProxyEvent::ProxyExecuted(Ok(())).into());
System::assert_last_event(ProxyEvent::ProxyExecuted { result: Ok(()) }.into());
assert_ok!(Proxy::proxy(Origin::signed(3), 1, None, call.clone()));
System::assert_last_event(
ProxyEvent::ProxyExecuted(Err(SystemError::CallFiltered.into())).into(),
ProxyEvent::ProxyExecuted { result: Err(SystemError::CallFiltered.into()) }.into(),
);
assert_ok!(Proxy::proxy(Origin::signed(4), 1, None, call.clone()));
System::assert_last_event(
ProxyEvent::ProxyExecuted(Err(SystemError::CallFiltered.into())).into(),
ProxyEvent::ProxyExecuted { result: Err(SystemError::CallFiltered.into()) }.into(),
);
let call = Box::new(Call::Utility(UtilityCall::batch { calls: vec![*inner] }));
assert_ok!(Proxy::proxy(Origin::signed(2), 1, None, call.clone()));
expect_events(vec![
UtilityEvent::BatchCompleted.into(),
ProxyEvent::ProxyExecuted(Ok(())).into(),
ProxyEvent::ProxyExecuted { result: Ok(()) }.into(),
]);
assert_ok!(Proxy::proxy(Origin::signed(3), 1, None, call.clone()));
System::assert_last_event(
ProxyEvent::ProxyExecuted(Err(SystemError::CallFiltered.into())).into(),
ProxyEvent::ProxyExecuted { result: Err(SystemError::CallFiltered.into()) }.into(),
);
assert_ok!(Proxy::proxy(Origin::signed(4), 1, None, call.clone()));
expect_events(vec![
UtilityEvent::BatchInterrupted { index: 0, error: SystemError::CallFiltered.into() }
.into(),
ProxyEvent::ProxyExecuted(Ok(())).into(),
ProxyEvent::ProxyExecuted { result: Ok(()) }.into(),
]);
let inner =
@@ -380,32 +388,32 @@ fn filtering_works() {
assert_ok!(Proxy::proxy(Origin::signed(2), 1, None, call.clone()));
expect_events(vec![
UtilityEvent::BatchCompleted.into(),
ProxyEvent::ProxyExecuted(Ok(())).into(),
ProxyEvent::ProxyExecuted { result: Ok(()) }.into(),
]);
assert_ok!(Proxy::proxy(Origin::signed(3), 1, None, call.clone()));
System::assert_last_event(
ProxyEvent::ProxyExecuted(Err(SystemError::CallFiltered.into())).into(),
ProxyEvent::ProxyExecuted { result: Err(SystemError::CallFiltered.into()) }.into(),
);
assert_ok!(Proxy::proxy(Origin::signed(4), 1, None, call.clone()));
expect_events(vec![
UtilityEvent::BatchInterrupted { index: 0, error: SystemError::CallFiltered.into() }
.into(),
ProxyEvent::ProxyExecuted(Ok(())).into(),
ProxyEvent::ProxyExecuted { result: Ok(()) }.into(),
]);
let call = Box::new(Call::Proxy(ProxyCall::remove_proxies {}));
assert_ok!(Proxy::proxy(Origin::signed(3), 1, None, call.clone()));
System::assert_last_event(
ProxyEvent::ProxyExecuted(Err(SystemError::CallFiltered.into())).into(),
ProxyEvent::ProxyExecuted { result: Err(SystemError::CallFiltered.into()) }.into(),
);
assert_ok!(Proxy::proxy(Origin::signed(4), 1, None, call.clone()));
System::assert_last_event(
ProxyEvent::ProxyExecuted(Err(SystemError::CallFiltered.into())).into(),
ProxyEvent::ProxyExecuted { result: Err(SystemError::CallFiltered.into()) }.into(),
);
assert_ok!(Proxy::proxy(Origin::signed(2), 1, None, call.clone()));
expect_events(vec![
BalancesEvent::<Test>::Unreserved(1, 5).into(),
ProxyEvent::ProxyExecuted(Ok(())).into(),
BalancesEvent::<Test>::Unreserved { who: 1, amount: 5 }.into(),
ProxyEvent::ProxyExecuted { result: Ok(()) }.into(),
]);
});
}
@@ -476,13 +484,13 @@ fn proxying_works() {
Error::<Test>::NotProxy
);
assert_ok!(Proxy::proxy(Origin::signed(2), 1, None, call.clone()));
System::assert_last_event(ProxyEvent::ProxyExecuted(Ok(())).into());
System::assert_last_event(ProxyEvent::ProxyExecuted { result: Ok(()) }.into());
assert_eq!(Balances::free_balance(6), 1);
let call = Box::new(Call::System(SystemCall::set_code { code: vec![] }));
assert_ok!(Proxy::proxy(Origin::signed(3), 1, None, call.clone()));
System::assert_last_event(
ProxyEvent::ProxyExecuted(Err(SystemError::CallFiltered.into())).into(),
ProxyEvent::ProxyExecuted { result: Err(SystemError::CallFiltered.into()) }.into(),
);
let call =
@@ -490,10 +498,10 @@ fn proxying_works() {
assert_ok!(Call::Proxy(super::Call::new_call_variant_proxy(1, None, call.clone()))
.dispatch(Origin::signed(2)));
System::assert_last_event(
ProxyEvent::ProxyExecuted(Err(SystemError::CallFiltered.into())).into(),
ProxyEvent::ProxyExecuted { result: Err(SystemError::CallFiltered.into()) }.into(),
);
assert_ok!(Proxy::proxy(Origin::signed(3), 1, None, call.clone()));
System::assert_last_event(ProxyEvent::ProxyExecuted(Ok(())).into());
System::assert_last_event(ProxyEvent::ProxyExecuted { result: Ok(()) }.into());
assert_eq!(Balances::free_balance(6), 2);
});
}
@@ -504,7 +512,13 @@ fn anonymous_works() {
assert_ok!(Proxy::anonymous(Origin::signed(1), ProxyType::Any, 0, 0));
let anon = Proxy::anonymous_account(&1, &ProxyType::Any, 0, None);
System::assert_last_event(
ProxyEvent::AnonymousCreated(anon.clone(), 1, ProxyType::Any, 0).into(),
ProxyEvent::AnonymousCreated {
anonymous: anon.clone(),
who: 1,
proxy_type: ProxyType::Any,
disambiguation_index: 0,
}
.into(),
);
// other calls to anonymous allowed as long as they're not exactly the same.
@@ -525,7 +539,7 @@ fn anonymous_works() {
let call = Box::new(call_transfer(6, 1));
assert_ok!(Balances::transfer(Origin::signed(3), anon, 5));
assert_ok!(Proxy::proxy(Origin::signed(1), anon, None, call));
System::assert_last_event(ProxyEvent::ProxyExecuted(Ok(())).into());
System::assert_last_event(ProxyEvent::ProxyExecuted { result: Ok(()) }.into());
assert_eq!(Balances::free_balance(6), 1);
let call = Box::new(Call::Proxy(ProxyCall::new_call_variant_kill_anonymous(
@@ -537,7 +551,7 @@ fn anonymous_works() {
)));
assert_ok!(Proxy::proxy(Origin::signed(2), anon2, None, call.clone()));
let de = DispatchError::from(Error::<Test>::NoPermission).stripped();
System::assert_last_event(ProxyEvent::ProxyExecuted(Err(de)).into());
System::assert_last_event(ProxyEvent::ProxyExecuted { result: Err(de) }.into());
assert_noop!(
Proxy::kill_anonymous(Origin::signed(1), 1, ProxyType::Any, 0, 1, 0),
Error::<Test>::NoPermission