aboutsummaryrefslogtreecommitdiffstats
path: root/node/config_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'node/config_test.go')
-rw-r--r--node/config_test.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/node/config_test.go b/node/config_test.go
index f59f3c0fe..efb864ce4 100644
--- a/node/config_test.go
+++ b/node/config_test.go
@@ -21,6 +21,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
+ "runtime"
"testing"
"github.com/ethereum/go-ethereum/crypto"
@@ -60,6 +61,37 @@ func TestDatadirCreation(t *testing.T) {
}
}
+// Tests that IPC paths are correctly resolved to valid endpoints of different
+// platforms.
+func TestIpcPathResolution(t *testing.T) {
+ var tests = []struct {
+ DataDir string
+ IpcPath string
+ Windows bool
+ Endpoint string
+ }{
+ {"", "", false, ""},
+ {"data", "", false, ""},
+ {"", "geth.ipc", false, filepath.Join(os.TempDir(), "geth.ipc")},
+ {"data", "geth.ipc", false, "data/geth.ipc"},
+ {"data", "./geth.ipc", false, "./geth.ipc"},
+ {"data", "/geth.ipc", false, "/geth.ipc"},
+ {"", "", true, ``},
+ {"data", "", true, ``},
+ {"", "geth.ipc", true, `\\.\pipe\geth.ipc`},
+ {"data", "geth.ipc", true, `\\.\pipe\geth.ipc`},
+ {"data", `\\.\pipe\geth.ipc`, true, `\\.\pipe\geth.ipc`},
+ }
+ for i, test := range tests {
+ // Only run when platform/test match
+ if (runtime.GOOS == "windows") == test.Windows {
+ if endpoint := (&Config{DataDir: test.DataDir, IpcPath: test.IpcPath}).IpcEndpoint(); endpoint != test.Endpoint {
+ t.Errorf("test %d: IPC endpoint mismatch: have %s, want %s", i, endpoint, test.Endpoint)
+ }
+ }
+ }
+}
+
// Tests that node keys can be correctly created, persisted, loaded and/or made
// ephemeral.
func TestNodeKeyPersistency(t *testing.T) {