Allow Root to assume SourceAccount. (#1011)

* Allow Root to assume SourceAccount.

* fmt code
This commit is contained in:
kaichao
2021-06-22 15:20:00 +08:00
committed by Bastian Köcher
parent 6ff79e9959
commit 010588e95a
4 changed files with 7 additions and 10 deletions
+3 -6
View File
@@ -355,7 +355,7 @@ where
}
CallOrigin::SourceAccount(ref source_account_id) => {
ensure!(
sender_origin == &RawOrigin::Signed(source_account_id.clone()),
sender_origin == &RawOrigin::Signed(source_account_id.clone()) || sender_origin == &RawOrigin::Root,
BadOrigin
);
Ok(Some(source_account_id.clone()))
@@ -964,10 +964,7 @@ mod tests {
Err(BadOrigin)
));
// If we try and send the message from Root, it is also rejected
assert!(matches!(
verify_message_origin(&RawOrigin::Root, &message),
Err(BadOrigin)
));
// The Root account is allowed to assume any expected origin account
assert!(matches!(verify_message_origin(&RawOrigin::Root, &message), Ok(Some(1))));
}
}