Skip long internal/statesync tests in -short mode

I added checks against testing.Short for tests that took longer than
about one second on my machine. Running with -short reduces the test
time of internal/statesync from about 54s to about 1.5s.
This commit is contained in:
Mark Rushakoff
2022-07-22 10:53:34 -04:00
parent d074a59bb5
commit af1f81072d
3 changed files with 24 additions and 0 deletions

View File

@@ -126,6 +126,10 @@ func TestBlockQueueWithFailures(t *testing.T) {
// Test that when all the blocks are retrieved that the queue still holds on to
// it's workers and in the event of failure can still fetch the failed block
func TestBlockQueueBlocks(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode")
}
peerID, err := types.NewNodeID("0011223344556677889900112233445566778899")
require.NoError(t, err)
queue := newBlockQueue(startHeight, stopHeight, 1, stopTime, 2)
@@ -176,6 +180,10 @@ loop:
}
func TestBlockQueueAcceptsNoMoreBlocks(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode")
}
peerID, err := types.NewNodeID("0011223344556677889900112233445566778899")
require.NoError(t, err)
queue := newBlockQueue(startHeight, stopHeight, 1, stopTime, 1)

View File

@@ -197,6 +197,10 @@ func setup(
}
func TestReactor_Sync(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode")
}
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
defer cancel()
@@ -618,6 +622,10 @@ func TestReactor_StateProviderP2P(t *testing.T) {
}
func TestReactor_Backfill(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode")
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
@@ -626,6 +634,10 @@ func TestReactor_Backfill(t *testing.T) {
for _, failureRate := range failureRates {
failureRate := failureRate
t.Run(fmt.Sprintf("failure rate: %d", failureRate), func(t *testing.T) {
if testing.Short() && failureRate > 0 {
t.Skip("skipping test in short mode")
}
ctx, cancel := context.WithCancel(ctx)
defer cancel()

View File

@@ -22,6 +22,10 @@ import (
)
func TestSyncer_SyncAny(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode")
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()