swarm/network: improve tests

This commit is contained in:
Anton Evangelatov 2018-02-05 10:27:25 +01:00
parent dc0acb72a8
commit a81aa6acb6
3 changed files with 11 additions and 3 deletions

View file

@ -33,6 +33,10 @@ import (
"github.com/ethereum/go-ethereum/p2p/discover"
)
var (
ErrLinuxOnly = errors.New("DockerAdapter can only be used on Linux as it uses the current binary (which must be a Linux binary)")
)
// DockerAdapter is a NodeAdapter which runs simulation nodes inside Docker
// containers.
//
@ -52,7 +56,7 @@ func NewDockerAdapter() (*DockerAdapter, error) {
// It is reasonable to require this because the caller can just
// compile the current binary in a Docker container.
if runtime.GOOS != "linux" {
return nil, errors.New("DockerAdapter can only be used on Linux as it uses the current binary (which must be a Linux binary)")
return nil, ErrLinuxOnly
}
if err := buildDockerImage(); err != nil {

View file

@ -6,7 +6,7 @@ import (
"testing"
)
func Test(t *testing.T) {
func TestPriorityQueue(t *testing.T) {
var results []string
wg := sync.WaitGroup{}
pq := New(3, 2)

View file

@ -77,8 +77,12 @@ func TestDiscoverySimulationDockerAdapter(t *testing.T) {
func testDiscoverySimulationDockerAdapter(t *testing.T, nodes, conns int) {
adapter, err := adapters.NewDockerAdapter()
if err != nil {
if err == adapters.ErrLinuxOnly {
t.Skip(err)
} else {
t.Fatal(err)
}
}
testDiscoverySimulation(t, nodes, conns, adapter)
}