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
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
// +build linux darwin freebsd
package main
import (

View file

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

View file

@ -17,10 +17,12 @@
package swarm
import (
"encoding/hex"
"io/ioutil"
"math/rand"
"os"
"path"
"runtime"
"strings"
"testing"
"time"
@ -42,6 +44,13 @@ func TestNewSwarm(t *testing.T) {
// a simple rpc endpoint for testing dialing
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)
if err != nil {
t.Error(err)