aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/natspec/natspec_e2e_test.go2
-rw-r--r--common/path.go22
2 files changed, 17 insertions, 7 deletions
diff --git a/common/natspec/natspec_e2e_test.go b/common/natspec/natspec_e2e_test.go
index ea28b457e..57f81f652 100644
--- a/common/natspec/natspec_e2e_test.go
+++ b/common/natspec/natspec_e2e_test.go
@@ -134,7 +134,7 @@ func testEth(t *testing.T) (ethereum *eth.Ethereum, err error) {
db, _ := ethdb.NewMemDatabase()
// set up mock genesis with balance on the testAddress
- core.WriteGenesisBlockForTesting(db, common.HexToAddress(testAddress), common.String2Big(testBalance))
+ core.WriteGenesisBlockForTesting(db, core.GenesisAccount{common.HexToAddress(testAddress), common.String2Big(testBalance)})
// only use minimalistic stack with no networking
ethereum, err = eth.New(&eth.Config{
diff --git a/common/path.go b/common/path.go
index 8b3c7d14b..1253c424c 100644
--- a/common/path.go
+++ b/common/path.go
@@ -100,14 +100,24 @@ func DefaultAssetPath() string {
}
func DefaultDataDir() string {
- usr, _ := user.Current()
- if runtime.GOOS == "darwin" {
- return filepath.Join(usr.HomeDir, "Library", "Ethereum")
- } else if runtime.GOOS == "windows" {
- return filepath.Join(usr.HomeDir, "AppData", "Roaming", "Ethereum")
+ // Try to place the data folder in the user's home dir
+ var home string
+ if usr, err := user.Current(); err == nil {
+ home = usr.HomeDir
} else {
- return filepath.Join(usr.HomeDir, ".ethereum")
+ home = os.Getenv("HOME")
}
+ if home != "" {
+ if runtime.GOOS == "darwin" {
+ return filepath.Join(home, "Library", "Ethereum")
+ } else if runtime.GOOS == "windows" {
+ return filepath.Join(home, "AppData", "Roaming", "Ethereum")
+ } else {
+ return filepath.Join(home, ".ethereum")
+ }
+ }
+ // As we cannot guess a stable location, return empty and handle later
+ return ""
}
func DefaultIpcPath() string {