mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-15 14:55:42 +00:00
Add execute_with to TestExternalities (#3793)
This function executes the given closure in a context where the test externalities are set. This makes the srml tests easier to write, as the test externalities need to be created anyway.
This commit is contained in:
@@ -139,7 +139,7 @@ mod tests {
|
||||
use runtime_io::TestExternalities;
|
||||
use sr_primitives::{
|
||||
testing::{Header, UintAuthorityId}, traits::{ConvertInto, IdentityLookup, OpaqueKeys},
|
||||
Perbill, set_and_run_with_externalities,
|
||||
Perbill,
|
||||
};
|
||||
use support::{impl_outer_origin, parameter_types};
|
||||
|
||||
@@ -263,7 +263,7 @@ mod tests {
|
||||
let mut externalities = TestExternalities::new(t);
|
||||
externalities.register_extension(KeystoreExt(key_store));
|
||||
|
||||
set_and_run_with_externalities(&mut externalities, || {
|
||||
externalities.execute_with(|| {
|
||||
assert_eq!(
|
||||
authority_id,
|
||||
AuthorityDiscovery::authority_id().expect("Retrieving public key.")
|
||||
@@ -300,7 +300,7 @@ mod tests {
|
||||
let mut externalities = TestExternalities::new(t);
|
||||
externalities.register_extension(KeystoreExt(key_store));
|
||||
|
||||
set_and_run_with_externalities(&mut externalities, || {
|
||||
externalities.execute_with(|| {
|
||||
assert_eq!(None, AuthorityDiscovery::authority_id());
|
||||
});
|
||||
}
|
||||
@@ -337,7 +337,7 @@ mod tests {
|
||||
let mut externalities = TestExternalities::new(t);
|
||||
externalities.register_extension(KeystoreExt(key_store));
|
||||
|
||||
set_and_run_with_externalities(&mut externalities, || {
|
||||
externalities.execute_with(|| {
|
||||
let payload = String::from("test payload").into_bytes();
|
||||
let (sig, authority_id) = AuthorityDiscovery::sign(&payload).expect("signature");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user