File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -59,13 +59,19 @@ pub(crate) fn cache_path() -> String {
5959
6060pub ( crate ) fn db_connection_config ( ) -> Config {
6161 let mut config = Config :: new ( ) ;
62- let host = env:: var ( "RAPID_GOSSIP_SYNC_SERVER_DB_HOST" ) . unwrap_or ( "localhost" . to_string ( ) ) ;
63- let user = env:: var ( "RAPID_GOSSIP_SYNC_SERVER_DB_USER" ) . unwrap_or ( "alice" . to_string ( ) ) ;
64- let db = env:: var ( "RAPID_GOSSIP_SYNC_SERVER_DB_NAME" ) . unwrap_or ( "ln_graph_sync" . to_string ( ) ) ;
62+ let env_name_prefix = if cfg ! ( test) {
63+ "RAPID_GOSSIP_TEST_DB"
64+ } else {
65+ "RAPID_GOSSIP_SYNC_SERVER_DB"
66+ } ;
67+
68+ let host = env:: var ( format ! ( "{}{}" , env_name_prefix, "_HOST" ) ) . unwrap_or ( "localhost" . to_string ( ) ) ;
69+ let user = env:: var ( format ! ( "{}{}" , env_name_prefix, "_USER" ) ) . unwrap_or ( "alice" . to_string ( ) ) ;
70+ let db = env:: var ( format ! ( "{}{}" , env_name_prefix, "_NAME" ) ) . unwrap_or ( "ln_graph_sync" . to_string ( ) ) ;
6571 config. host ( & host) ;
6672 config. user ( & user) ;
6773 config. dbname ( & db) ;
68- if let Ok ( password) = env:: var ( "RAPID_GOSSIP_SYNC_SERVER_DB_PASSWORD" ) {
74+ if let Ok ( password) = env:: var ( format ! ( "{}{}" , env_name_prefix , "_PASSWORD" ) ) {
6975 config. password ( & password) ;
7076 }
7177 config
You can’t perform that action at this time.
0 commit comments