diff --git a/common/countdown/countdown_test.go b/common/countdown/countdown_test.go index 1192c6e38ad5..945cfe91b773 100644 --- a/common/countdown/countdown_test.go +++ b/common/countdown/countdown_test.go @@ -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) @@ -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 { @@ -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 { @@ -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 { @@ -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) diff --git a/p2p/discover/short_mode_test.go b/p2p/discover/short_mode_test.go new file mode 100644 index 000000000000..b6792ba6ab48 --- /dev/null +++ b/p2p/discover/short_mode_test.go @@ -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") + } +} diff --git a/p2p/discover/v4_lookup_test.go b/p2p/discover/v4_lookup_test.go index 278dff9673a2..8c05273a8a09 100644 --- a/p2p/discover/v4_lookup_test.go +++ b/p2p/discover/v4_lookup_test.go @@ -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. @@ -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() diff --git a/p2p/discover/v4_udp_test.go b/p2p/discover/v4_udp_test.go index 86c665eff2d7..e624c349cbb6 100644 --- a/p2p/discover/v4_udp_test.go +++ b/p2p/discover/v4_udp_test.go @@ -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() @@ -185,6 +187,8 @@ func TestUDPv4_pingTimeout(t *testing.T) { } func TestUDPv4_resolveReturnsNilWhenUnresolved(t *testing.T) { + skipLongInShortMode(t) + test := newUDPTest(t) defer test.close() @@ -204,6 +208,8 @@ func TestUDPv4_resolveReturnsNilWhenUnresolved(t *testing.T) { } func TestUDPv4_resolveReturnsNilWhenLookupMisses(t *testing.T) { + skipLongInShortMode(t) + test := newUDPTest(t) defer test.close() @@ -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() @@ -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() @@ -369,6 +379,8 @@ func TestUDPv4_findnode(t *testing.T) { } func TestUDPv4_findnodeMultiReply(t *testing.T) { + skipLongInShortMode(t) + test := newUDPTest(t) defer test.close() @@ -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() @@ -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. diff --git a/p2p/discover/v5_udp_test.go b/p2p/discover/v5_udp_test.go index 7ad77a8db09b..1358bbb08680 100644 --- a/p2p/discover/v5_udp_test.go +++ b/p2p/discover/v5_udp_test.go @@ -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() @@ -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() @@ -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() @@ -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() @@ -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() @@ -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() @@ -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() @@ -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. @@ -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()