Browse Source

simplified pattern matching in storage/tests/fixtures

ignazio 3 years ago
parent
commit
36524997d1
1 changed files with 7 additions and 9 deletions
  1. 7 9
      runtime-modules/storage/src/tests/fixtures.rs

+ 7 - 9
runtime-modules/storage/src/tests/fixtures.rs

@@ -1290,15 +1290,8 @@ impl CreateDynamicBagWithObjectsFixture {
             }
             Err(err) => {
                 assert_eq!(balance_pre, balance_post);
-                if let DispatchError::Module {
-                    message: Some(error_msg),
-                    ..
-                } = err
-                {
-                    match error_msg {
-                        "DynamicBagExists" => (),
-                        _ => assert!(!crate::Bags::<Test>::contains_key(&bag_id)),
-                    }
+                if into_str(err) != "DynamicBagExists" {
+                    assert!(!crate::Bags::<Test>::contains_key(&bag_id))
                 }
             }
         }
@@ -2159,3 +2152,8 @@ impl CreateStorageBucketFixture {
         bucket_ids
     }
 }
+
+// wrapper to silence compiler error
+fn into_str(err: DispatchError) -> &'static str {
+    err.into()
+}