aboutsummaryrefslogtreecommitdiffstats
path: root/p2p
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-08-07 03:39:29 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-08-07 03:39:29 +0800
commit698e98d9814605bfea98ba3ad2fe7fda073cb2b1 (patch)
tree729aa720f3b18b9eb901111d1d58c355bc9b744c /p2p
parenta3b8169938953a10ab57282853768c72bebaf0b4 (diff)
parent803096ca0f262be7d03081482777c3e293f5f7ac (diff)
downloadgo-tangerine-698e98d9814605bfea98ba3ad2fe7fda073cb2b1.tar.gz
go-tangerine-698e98d9814605bfea98ba3ad2fe7fda073cb2b1.tar.zst
go-tangerine-698e98d9814605bfea98ba3ad2fe7fda073cb2b1.zip
Merge pull request #1600 from ethereum/fix-tests-windows
Fix tests on windows
Diffstat (limited to 'p2p')
-rw-r--r--p2p/discover/table.go4
-rw-r--r--p2p/discover/table_test.go8
-rw-r--r--p2p/nat/natupnp_test.go5
3 files changed, 13 insertions, 4 deletions
diff --git a/p2p/discover/table.go b/p2p/discover/table.go
index 48c473475..67f7ec46f 100644
--- a/p2p/discover/table.go
+++ b/p2p/discover/table.go
@@ -164,7 +164,9 @@ func randUint(max uint32) uint32 {
// Close terminates the network listener and flushes the node database.
func (tab *Table) Close() {
- tab.net.close()
+ if tab.net != nil {
+ tab.net.close()
+ }
tab.db.close()
}
diff --git a/p2p/discover/table_test.go b/p2p/discover/table_test.go
index 310fe2b7b..d259177bf 100644
--- a/p2p/discover/table_test.go
+++ b/p2p/discover/table_test.go
@@ -35,6 +35,7 @@ func TestTable_pingReplace(t *testing.T) {
doit := func(newNodeIsResponding, lastInBucketIsResponding bool) {
transport := newPingRecorder()
tab := newTable(transport, NodeID{}, &net.UDPAddr{}, "")
+ defer tab.Close()
pingSender := newNode(MustHexID("a502af0f59b2aab7746995408c79e9ca312d2793cc997e44fc55eda62f0150bbb8c59a6f9269ba3a081518b62699ee807c7c19c20125ddfccca872608af9e370"), net.IP{}, 99, 99)
// fill up the sender's bucket.
@@ -158,9 +159,7 @@ func newPingRecorder() *pingRecorder {
func (t *pingRecorder) findnode(toid NodeID, toaddr *net.UDPAddr, target NodeID) ([]*Node, error) {
panic("findnode called on pingRecorder")
}
-func (t *pingRecorder) close() {
- panic("close called on pingRecorder")
-}
+func (t *pingRecorder) close() {}
func (t *pingRecorder) waitping(from NodeID) error {
return nil // remote always pings
}
@@ -180,6 +179,7 @@ func TestTable_closest(t *testing.T) {
// for any node table, Target and N
tab := newTable(nil, test.Self, &net.UDPAddr{}, "")
tab.add(test.All)
+ defer tab.Close()
// check that doClosest(Target, N) returns nodes
result := tab.closest(test.Target, test.N).entries
@@ -237,6 +237,7 @@ func TestTable_ReadRandomNodesGetAll(t *testing.T) {
}
test := func(buf []*Node) bool {
tab := newTable(nil, NodeID{}, &net.UDPAddr{}, "")
+ defer tab.Close()
for i := 0; i < len(buf); i++ {
ld := cfg.Rand.Intn(len(tab.buckets))
tab.add([]*Node{nodeAtDistance(tab.self.sha, ld)})
@@ -279,6 +280,7 @@ func (*closeTest) Generate(rand *rand.Rand, size int) reflect.Value {
func TestTable_Lookup(t *testing.T) {
self := nodeAtDistance(common.Hash{}, 0)
tab := newTable(lookupTestnet, self.ID, &net.UDPAddr{}, "")
+ defer tab.Close()
// lookup on empty table returns no nodes
if results := tab.Lookup(lookupTestnet.target); len(results) > 0 {
diff --git a/p2p/nat/natupnp_test.go b/p2p/nat/natupnp_test.go
index c1e322af7..79f6d25ae 100644
--- a/p2p/nat/natupnp_test.go
+++ b/p2p/nat/natupnp_test.go
@@ -21,6 +21,7 @@ import (
"io"
"net"
"net/http"
+ "runtime"
"strings"
"testing"
@@ -28,6 +29,10 @@ import (
)
func TestUPNP_DDWRT(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skipf("disabled to avoid firewall prompt")
+ }
+
dev := &fakeIGD{
t: t,
ssdpResp: "HTTP/1.1 200 OK\r\n" +