diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/compiler/solidity_test.go | 5 | ||||
-rw-r--r-- | common/docserver/docserver.go | 1 | ||||
-rw-r--r-- | common/docserver/docserver_test.go | 19 | ||||
-rw-r--r-- | common/path.go | 11 | ||||
-rw-r--r-- | common/path_test.go | 52 | ||||
-rw-r--r-- | common/size_test.go | 2 |
6 files changed, 17 insertions, 73 deletions
diff --git a/common/compiler/solidity_test.go b/common/compiler/solidity_test.go index 8255e8e2d..3303bc15a 100644 --- a/common/compiler/solidity_test.go +++ b/common/compiler/solidity_test.go @@ -20,6 +20,7 @@ import ( "encoding/json" "io/ioutil" "os" + "path" "testing" "github.com/ethereum/go-ethereum/common" @@ -94,7 +95,7 @@ func TestSaveInfo(t *testing.T) { if err != nil { t.Errorf("%v", err) } - filename := "/tmp/solctest.info.json" + filename := path.Join(os.TempDir(), "solctest.info.json") os.Remove(filename) cinfohash, err := SaveInfo(&cinfo, filename) if err != nil { @@ -110,4 +111,4 @@ func TestSaveInfo(t *testing.T) { if cinfohash != infohash { t.Errorf("content hash for info is incorrect. expected %v, got %v", infohash.Hex(), cinfohash.Hex()) } -} +}
\ No newline at end of file diff --git a/common/docserver/docserver.go b/common/docserver/docserver.go index fa120fb38..dac542ba7 100644 --- a/common/docserver/docserver.go +++ b/common/docserver/docserver.go @@ -38,7 +38,6 @@ func New(docRoot string) (self *DocServer) { DocRoot: docRoot, schemes: []string{"file"}, } - self.DocRoot = "/tmp/" self.RegisterProtocol("file", http.NewFileTransport(http.Dir(self.DocRoot))) return } diff --git a/common/docserver/docserver_test.go b/common/docserver/docserver_test.go index 92e39d167..632603add 100644 --- a/common/docserver/docserver_test.go +++ b/common/docserver/docserver_test.go @@ -20,6 +20,7 @@ import ( "io/ioutil" "net/http" "os" + "path" "testing" "github.com/ethereum/go-ethereum/common" @@ -27,12 +28,18 @@ import ( ) func TestGetAuthContent(t *testing.T) { - text := "test" - hash := common.Hash{} - copy(hash[:], crypto.Sha3([]byte(text))) - ioutil.WriteFile("/tmp/test.content", []byte(text), os.ModePerm) + dir, err := ioutil.TempDir("", "docserver-test") + if err != nil { + t.Fatal("cannot create temporary directory:", err) + } + defer os.RemoveAll(dir) + ds := New(dir) - ds := New("/tmp/") + text := "test" + hash := crypto.Sha3Hash([]byte(text)) + if err := ioutil.WriteFile(path.Join(dir, "test.content"), []byte(text), os.ModePerm); err != nil { + t.Fatal("could not write test file", err) + } content, err := ds.GetAuthContent("file:///test.content", hash) if err != nil { t.Errorf("no error expected, got %v", err) @@ -67,4 +74,4 @@ func TestRegisterScheme(t *testing.T) { if !ds.HasScheme("scheme") { t.Errorf("expected scheme to be registered") } -} +}
\ No newline at end of file diff --git a/common/path.go b/common/path.go index 0d7adb961..8b3c7d14b 100644 --- a/common/path.go +++ b/common/path.go @@ -116,14 +116,3 @@ func DefaultIpcPath() string { } return filepath.Join(DefaultDataDir(), "geth.ipc") } - -func IsWindows() bool { - return runtime.GOOS == "windows" -} - -func WindonizePath(path string) string { - if string(path[0]) == "/" && IsWindows() { - path = path[1:] - } - return path -} diff --git a/common/path_test.go b/common/path_test.go deleted file mode 100644 index 71ffd5fe1..000000000 --- a/common/path_test.go +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2014 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. - -package common - -import ( - "os" - // "testing" - - checker "gopkg.in/check.v1" -) - -type CommonSuite struct{} - -var _ = checker.Suite(&CommonSuite{}) - -func (s *CommonSuite) TestOS(c *checker.C) { - expwin := (os.PathSeparator == '\\' && os.PathListSeparator == ';') - res := IsWindows() - - if !expwin { - c.Assert(res, checker.Equals, expwin, checker.Commentf("IsWindows is", res, "but path is", os.PathSeparator)) - } else { - c.Assert(res, checker.Not(checker.Equals), expwin, checker.Commentf("IsWindows is", res, "but path is", os.PathSeparator)) - } -} - -func (s *CommonSuite) TestWindonziePath(c *checker.C) { - iswindowspath := os.PathSeparator == '\\' - path := "/opt/eth/test/file.ext" - res := WindonizePath(path) - ressep := string(res[0]) - - if !iswindowspath { - c.Assert(ressep, checker.Equals, "/") - } else { - c.Assert(ressep, checker.Not(checker.Equals), "/") - } -} diff --git a/common/size_test.go b/common/size_test.go index 8709a0237..ce19cab69 100644 --- a/common/size_test.go +++ b/common/size_test.go @@ -40,7 +40,7 @@ func (s *SizeSuite) TestStorageSizeString(c *checker.C) { c.Assert(StorageSize(data3).String(), checker.Equals, exp3) } -func (s *CommonSuite) TestCommon(c *checker.C) { +func (s *SizeSuite) TestCommon(c *checker.C) { ether := CurrencyToString(BigPow(10, 19)) finney := CurrencyToString(BigPow(10, 16)) szabo := CurrencyToString(BigPow(10, 13)) |