From 4ee92a6a15a66db8753c5da578f10e9a4934344b Mon Sep 17 00:00:00 2001 From: Mark Rushakoff Date: Fri, 22 Jul 2022 11:47:28 -0400 Subject: [PATCH] Skip long types 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 types from about 21s to about 1.9s with the race detector enabled. With the race detector disabled, the timing difference is about 1.0s to about 0.3s. --- types/part_set_test.go | 16 ++++++++++++++++ types/validator_set_test.go | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/types/part_set_test.go b/types/part_set_test.go index af65ca8db..760abe922 100644 --- a/types/part_set_test.go +++ b/types/part_set_test.go @@ -16,6 +16,10 @@ const ( ) func TestBasicPartSet(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode") + } + // Construct random data of size partSize * 100 nParts := 100 data := tmrand.Bytes(testPartSize * nParts) @@ -64,6 +68,10 @@ func TestBasicPartSet(t *testing.T) { } func TestWrongProof(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode") + } + // Construct random data of size partSize * 100 data := tmrand.Bytes(testPartSize * 100) partSet := NewPartSetFromData(data, testPartSize) @@ -89,6 +97,10 @@ func TestWrongProof(t *testing.T) { } func TestPartSetHeaderValidateBasic(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode") + } + testCases := []struct { testName string malleatePartSetHeader func(*PartSetHeader) @@ -110,6 +122,10 @@ func TestPartSetHeaderValidateBasic(t *testing.T) { } func TestPartValidateBasic(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode") + } + testCases := []struct { testName string malleatePart func(*Part) diff --git a/types/validator_set_test.go b/types/validator_set_test.go index 81e81919d..75eaad34c 100644 --- a/types/validator_set_test.go +++ b/types/validator_set_test.go @@ -1207,6 +1207,10 @@ func applyChangesToValSet(t *testing.T, expErr error, valSet *ValidatorSet, vals } func TestValSetUpdatePriorityOrderTests(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode") + } + const nMaxElections int32 = 5000 testCases := []testVSetCfg{