cmd/swarm, swarm/storage, swarm: fix mingw on windows test issues

This commit is contained in:
Janos Guljas 2018-06-22 10:54:29 +02:00 committed by Anton Evangelatov
parent cf286d6bc6
commit c076cb78a3
3 changed files with 13 additions and 2 deletions

View file

@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>. // along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
// +build linux darwin freebsd
package main package main
import ( import (

View file

@ -59,12 +59,12 @@ func newTestDbStore(mock bool, trusted bool) (*testDbStore, func(), error) {
} }
cleanup := func() { cleanup := func() {
if err != nil { if db != nil {
db.Close() db.Close()
} }
err = os.RemoveAll(dir) err = os.RemoveAll(dir)
if err != nil { if err != nil {
panic("db cleanup failed") panic(fmt.Sprintf("db cleanup failed: %v", err))
} }
} }

View file

@ -17,10 +17,12 @@
package swarm package swarm
import ( import (
"encoding/hex"
"io/ioutil" "io/ioutil"
"math/rand" "math/rand"
"os" "os"
"path" "path"
"runtime"
"strings" "strings"
"testing" "testing"
"time" "time"
@ -42,6 +44,13 @@ func TestNewSwarm(t *testing.T) {
// a simple rpc endpoint for testing dialing // a simple rpc endpoint for testing dialing
ipcEndpoint := path.Join(dir, "TestSwarm.ipc") ipcEndpoint := path.Join(dir, "TestSwarm.ipc")
// windows namedpipes are not on filesystem but on NPFS
if runtime.GOOS == "windows" {
b := make([]byte, 8)
rand.Read(b)
ipcEndpoint = `\\.\pipe\TestSwarm-` + hex.EncodeToString(b)
}
_, server, err := rpc.StartIPCEndpoint(ipcEndpoint, nil) _, server, err := rpc.StartIPCEndpoint(ipcEndpoint, nil)
if err != nil { if err != nil {
t.Error(err) t.Error(err)