Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions common/countdown/countdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ import (
"github.com/stretchr/testify/assert"
)

func skipLongInShortMode(t *testing.T) {
t.Helper()
if testing.Short() {
t.Skip("skipping long-running test in -short mode")
}
}

func TestCountdownWillCallback(t *testing.T) {
var fakeI interface{}
called := make(chan int)
Expand All @@ -25,6 +32,8 @@ func TestCountdownWillCallback(t *testing.T) {
}

func TestCountdownShouldReset(t *testing.T) {
skipLongInShortMode(t)

var fakeI interface{}
called := make(chan int)
OnTimeoutFn := func(time.Time, interface{}) error {
Expand Down Expand Up @@ -76,6 +85,8 @@ firstReset:
}

func TestCountdownShouldResetEvenIfErrored(t *testing.T) {
skipLongInShortMode(t)

var fakeI interface{}
called := make(chan int)
OnTimeoutFn := func(time.Time, interface{}) error {
Expand Down Expand Up @@ -127,6 +138,8 @@ firstReset:
}

func TestCountdownShouldBeAbleToStop(t *testing.T) {
skipLongInShortMode(t)

var fakeI interface{}
called := make(chan int)
OnTimeoutFn := func(time.Time, interface{}) error {
Expand All @@ -150,6 +163,8 @@ func TestCountdownShouldBeAbleToStop(t *testing.T) {
}

func TestCountdownShouldAvoidDeadlock(t *testing.T) {
skipLongInShortMode(t)

var fakeI interface{}
called := make(chan int)
countdown, err := NewExpCountDown(5000*time.Millisecond, 0, 0)
Expand Down
10 changes: 10 additions & 0 deletions p2p/discover/short_mode_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package discover

import "testing"

func skipLongInShortMode(t *testing.T) {
t.Helper()
if testing.Short() {
t.Skip("skipping long-running test in -short mode")
}
}
4 changes: 4 additions & 0 deletions p2p/discover/v4_lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ import (
)

func TestUDPv4_Lookup(t *testing.T) {
skipLongInShortMode(t)
t.Parallel()

test := newUDPTest(t)

// Lookup on empty table returns no nodes.
Expand Down Expand Up @@ -65,7 +67,9 @@ func TestUDPv4_Lookup(t *testing.T) {
}

func TestUDPv4_LookupIterator(t *testing.T) {
skipLongInShortMode(t)
t.Parallel()

test := newUDPTest(t)
defer test.close()

Expand Down
15 changes: 15 additions & 0 deletions p2p/discover/v4_udp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ func TestUDP_pingPacketRejected(t *testing.T) {
}

func TestUDPv4_pingTimeout(t *testing.T) {
skipLongInShortMode(t)
t.Parallel()

test := newUDPTest(t)
defer test.close()

Expand All @@ -185,6 +187,8 @@ func TestUDPv4_pingTimeout(t *testing.T) {
}

func TestUDPv4_resolveReturnsNilWhenUnresolved(t *testing.T) {
skipLongInShortMode(t)

test := newUDPTest(t)
defer test.close()

Expand All @@ -204,6 +208,8 @@ func TestUDPv4_resolveReturnsNilWhenUnresolved(t *testing.T) {
}

func TestUDPv4_resolveReturnsNilWhenLookupMisses(t *testing.T) {
skipLongInShortMode(t)

test := newUDPTest(t)
defer test.close()

Expand All @@ -225,7 +231,9 @@ func (req testPacket) Kind() byte { return byte(req) }
func (req testPacket) Name() string { return "" }

func TestUDPv4_responseTimeouts(t *testing.T) {
skipLongInShortMode(t)
t.Parallel()

test := newUDPTest(t)
defer test.close()

Expand Down Expand Up @@ -297,7 +305,9 @@ func TestUDPv4_responseTimeouts(t *testing.T) {
}

func TestUDPv4_findnodeTimeout(t *testing.T) {
skipLongInShortMode(t)
t.Parallel()

test := newUDPTest(t)
defer test.close()

Expand Down Expand Up @@ -369,6 +379,8 @@ func TestUDPv4_findnode(t *testing.T) {
}

func TestUDPv4_findnodeMultiReply(t *testing.T) {
skipLongInShortMode(t)

test := newUDPTest(t)
defer test.close()

Expand Down Expand Up @@ -522,6 +534,8 @@ func TestUDPv4_successfulPing(t *testing.T) {

// This test checks that EIP-868 requests work.
func TestUDPv4_EIP868(t *testing.T) {
skipLongInShortMode(t)

test := newUDPTest(t)
defer test.close()

Expand Down Expand Up @@ -560,6 +574,7 @@ func TestUDPv4_EIP868(t *testing.T) {

// This test verifies that a small network of nodes can boot up into a healthy state.
func TestUDPv4_smallNetConvergence(t *testing.T) {
skipLongInShortMode(t)
t.Parallel()

// Start the network.
Expand Down
18 changes: 18 additions & 0 deletions p2p/discover/v5_udp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ func startLocalhostV5(t *testing.T, cfg Config) *UDPv5 {

// This test checks that incoming PING calls are handled correctly.
func TestUDPv5_pingHandling(t *testing.T) {
skipLongInShortMode(t)
t.Parallel()

test := newUDPV5Test(t)
defer test.close()

Expand All @@ -126,7 +128,9 @@ func TestUDPv5_pingHandling(t *testing.T) {

// This test checks that incoming 'unknown' packets trigger the handshake.
func TestUDPv5_unknownPacket(t *testing.T) {
skipLongInShortMode(t)
t.Parallel()

test := newUDPV5Test(t)
defer test.close()

Expand Down Expand Up @@ -162,7 +166,9 @@ func TestUDPv5_unknownPacket(t *testing.T) {

// This test checks that incoming FINDNODE calls are handled correctly.
func TestUDPv5_findnodeHandling(t *testing.T) {
skipLongInShortMode(t)
t.Parallel()

test := newUDPV5Test(t)
defer test.close()

Expand Down Expand Up @@ -240,7 +246,9 @@ func (test *udpV5Test) expectNodes(wantReqID []byte, wantTotal uint8, wantNodes

// This test checks that outgoing PING calls work.
func TestUDPv5_pingCall(t *testing.T) {
skipLongInShortMode(t)
t.Parallel()

test := newUDPV5Test(t)
defer test.close()

Expand Down Expand Up @@ -372,7 +380,9 @@ func TestUDPv5_callResend(t *testing.T) {

// This test ensures we don't allow multiple rounds of WHOAREYOU for a single call.
func TestUDPv5_multipleHandshakeRounds(t *testing.T) {
skipLongInShortMode(t)
t.Parallel()

test := newUDPV5Test(t)
defer test.close()

Expand All @@ -398,7 +408,9 @@ func TestUDPv5_multipleHandshakeRounds(t *testing.T) {

// This test checks that calls with n replies may take up to n * respTimeout.
func TestUDPv5_callTimeoutReset(t *testing.T) {
skipLongInShortMode(t)
t.Parallel()

test := newUDPV5Test(t)
defer test.close()

Expand Down Expand Up @@ -487,7 +499,9 @@ func TestUDPv5_talkHandling(t *testing.T) {

// This test checks that outgoing TALKREQ calls work.
func TestUDPv5_talkRequest(t *testing.T) {
skipLongInShortMode(t)
t.Parallel()

test := newUDPV5Test(t)
defer test.close()

Expand Down Expand Up @@ -528,7 +542,9 @@ func TestUDPv5_talkRequest(t *testing.T) {

// This test checks that lookup works.
func TestUDPv5_lookup(t *testing.T) {
skipLongInShortMode(t)
t.Parallel()

test := newUDPV5Test(t)

// Lookup on empty table returns no nodes.
Expand Down Expand Up @@ -605,7 +621,9 @@ func TestUDPv5_LocalNode(t *testing.T) {
}

func TestUDPv5_PingWithIPV4MappedAddress(t *testing.T) {
skipLongInShortMode(t)
t.Parallel()

test := newUDPV5Test(t)
defer test.close()

Expand Down