Преглед на файлове

Add support for configurable accounts_db to define_accounts_db_test (#8043)

Rory Harris преди 2 месеца
родител
ревизия
3ba6f4dbc6
променени са 2 файла, в които са добавени 25 реда и са изтрити 17 реда
  1. 17 10
      accounts-db/src/accounts_db.rs
  2. 8 7
      accounts-db/src/accounts_db/tests.rs

+ 17 - 10
accounts-db/src/accounts_db.rs

@@ -7204,24 +7204,31 @@ impl AccountsDb {
         AccountsDb::new_for_tests(Vec::new())
         AccountsDb::new_for_tests(Vec::new())
     }
     }
 
 
-    pub fn new_single_for_tests_with_provider(file_provider: AccountsFileProvider) -> Self {
-        AccountsDb::new_for_tests_with_provider(Vec::new(), file_provider)
+    pub fn new_single_for_tests_with_provider_and_config(
+        file_provider: AccountsFileProvider,
+        accounts_db_config: AccountsDbConfig,
+    ) -> Self {
+        AccountsDb::new_for_tests_with_provider_and_config(
+            Vec::new(),
+            file_provider,
+            accounts_db_config,
+        )
     }
     }
 
 
     pub fn new_for_tests(paths: Vec<PathBuf>) -> Self {
     pub fn new_for_tests(paths: Vec<PathBuf>) -> Self {
-        Self::new_for_tests_with_provider(paths, AccountsFileProvider::default())
+        Self::new_for_tests_with_provider_and_config(
+            paths,
+            AccountsFileProvider::default(),
+            ACCOUNTS_DB_CONFIG_FOR_TESTING,
+        )
     }
     }
 
 
-    fn new_for_tests_with_provider(
+    fn new_for_tests_with_provider_and_config(
         paths: Vec<PathBuf>,
         paths: Vec<PathBuf>,
         accounts_file_provider: AccountsFileProvider,
         accounts_file_provider: AccountsFileProvider,
+        accounts_db_config: AccountsDbConfig,
     ) -> Self {
     ) -> Self {
-        let mut db = AccountsDb::new_with_config(
-            paths,
-            ACCOUNTS_DB_CONFIG_FOR_TESTING,
-            None,
-            Arc::default(),
-        );
+        let mut db = AccountsDb::new_with_config(paths, accounts_db_config, None, Arc::default());
         db.accounts_file_provider = accounts_file_provider;
         db.accounts_file_provider = accounts_file_provider;
         db
         db
     }
     }

+ 8 - 7
accounts-db/src/accounts_db/tests.rs

@@ -117,13 +117,14 @@ impl AccountStorageEntry {
 ///     define_accounts_db_test!(TEST_NAME, panic = "PANIC_MSG", |accounts_db| { TEST_BODY });
 ///     define_accounts_db_test!(TEST_NAME, panic = "PANIC_MSG", |accounts_db| { TEST_BODY });
 macro_rules! define_accounts_db_test {
 macro_rules! define_accounts_db_test {
     (@testfn $name:ident, $accounts_file_provider: ident, |$accounts_db:ident| $inner: tt) => {
     (@testfn $name:ident, $accounts_file_provider: ident, |$accounts_db:ident| $inner: tt) => {
-            fn run_test($accounts_db: AccountsDb) {
-                $inner
-            }
-            let accounts_db =
-                AccountsDb::new_single_for_tests_with_provider($accounts_file_provider);
-            run_test(accounts_db);
-
+        fn run_test($accounts_db: AccountsDb) {
+            $inner
+        }
+        let accounts_db = AccountsDb::new_single_for_tests_with_provider_and_config(
+            $accounts_file_provider,
+            ACCOUNTS_DB_CONFIG_FOR_TESTING,
+        );
+        run_test(accounts_db);
     };
     };
     ($name:ident, |$accounts_db:ident| $inner: tt) => {
     ($name:ident, |$accounts_db:ident| $inner: tt) => {
         #[test_case(AccountsFileProvider::AppendVec; "append_vec")]
         #[test_case(AccountsFileProvider::AppendVec; "append_vec")]