From 5e93b1664e4a57aa997b77c6e4a8a90b4c90dd98 Mon Sep 17 00:00:00 2001 From: Marco Peereboom Date: Mon, 12 Sep 2016 02:21:37 -0500 Subject: [PATCH 1/3] config: Replace log outputs with fmt.Fprintln. This corrects the case where any errors that might have happened when creating the config file were not being displayed due to the logging system not being initialized yet. While here, consistently use fmt.Fprint{f,ln} throughout the loadConfig function even after the logging system is initialized since it will help prevent copy/paste errors such as the one that induced this change to begin with. --- config.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/config.go b/config.go index fe8bab2c..5a04d8c1 100644 --- a/config.go +++ b/config.go @@ -404,7 +404,8 @@ func loadConfig() (*config, []string, error) { if _, err := os.Stat(preCfg.ConfigFile); os.IsNotExist(err) { err := createDefaultConfigFile(preCfg.ConfigFile) if err != nil { - btcdLog.Warnf("Error creating a default config file: %v", err) + fmt.Fprintf(os.Stderr, "Error creating a "+ + "default config file: %v\n", err) } } @@ -833,8 +834,8 @@ func loadConfig() (*config, []string, error) { if cfg.TorIsolation && (cfg.ProxyUser != "" || cfg.ProxyPass != "") { - btcdLog.Warn("Tor isolation set -- overriding " + - "specified proxy user credentials") + fmt.Fprintln(os.Stderr, "Tor isolation set -- "+ + "overriding specified proxy user credentials") } proxy := &socks.Proxy{ @@ -871,8 +872,9 @@ func loadConfig() (*config, []string, error) { if cfg.TorIsolation && (cfg.OnionProxyUser != "" || cfg.OnionProxyPass != "") { - btcdLog.Warn("Tor isolation set -- overriding " + - "specified onionproxy user credentials ") + fmt.Fprintln(os.Stderr, "Tor isolation set -- "+ + "overriding specified onionproxy user "+ + "credentials ") } cfg.oniondial = func(a, b string) (net.Conn, error) { From 0ddd10add60683ce24cafcc1d9b38832ad1920ef Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Tue, 13 Sep 2016 15:10:19 -0400 Subject: [PATCH 2/3] Remove extra backtick in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7aac8890..88fdf7ca 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ Launch btcd from your Start menu. ```bash $ ./btcd -```` +``` ## IRC From fb90c334dffc6c91843d8d36ac31e7f7eb6c7594 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Tue, 13 Sep 2016 16:16:51 -0500 Subject: [PATCH 3/3] rpctest: Cleanup resources on failed setup. This modifies the rpctest harness to call the TearDown function in the SetUp error path. This ensures any resources, such as temp directories, that were created during setup before whatever the failure that caused the error are properly cleaned up. --- rpcserver_test.go | 7 +++++++ rpctest/rpc_harness_test.go | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/rpcserver_test.go b/rpcserver_test.go index 49e86342..10422927 100644 --- a/rpcserver_test.go +++ b/rpcserver_test.go @@ -117,6 +117,13 @@ func TestMain(m *testing.M) { // purposes. if err := primaryHarness.SetUp(true, 25); err != nil { fmt.Println("unable to setup test chain: ", err) + + // Even though the harness was not fully setup, it still needs + // to be torn down to ensure all resources such as temp + // directories are cleaned up. The error is intentionally + // ignored since this is already an error path and nothing else + // could be done about it anyways. + _ = primaryHarness.TearDown() os.Exit(1) } diff --git a/rpctest/rpc_harness_test.go b/rpctest/rpc_harness_test.go index f6856f82..042744a1 100644 --- a/rpctest/rpc_harness_test.go +++ b/rpctest/rpc_harness_test.go @@ -501,6 +501,13 @@ func TestMain(m *testing.M) { // purposes. if err = mainHarness.SetUp(true, numMatureOutputs); err != nil { fmt.Println("unable to setup test chain: ", err) + + // Even though the harness was not fully setup, it still needs + // to be torn down to ensure all resources such as temp + // directories are cleaned up. The error is intentionally + // ignored since this is already an error path and nothing else + // could be done about it anyways. + _ = mainHarness.TearDown() os.Exit(1) }