Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added t.Parallel to benchmark consensus tests since they’re slow and … #77

Merged
merged 2 commits into from
Aug 10, 2018
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

func TestHandlerOfLeaderSynchronizesToFutureValidBlock(t *testing.T) {
t.Parallel()
test.WithContext(func(ctx context.Context) {
h := newLeaderHarnessWaitingForCommittedMessages(t, ctx)
aBlockFromLeader := builders.BlockPair().WithBenchmarkConsensusBlockProof(leaderPublicKey, leaderPrivateKey)
Expand All @@ -29,6 +30,7 @@ func TestHandlerOfLeaderSynchronizesToFutureValidBlock(t *testing.T) {
}

func TestHandlerOfNonLeaderSynchronizesToFutureValidBlock(t *testing.T) {
t.Parallel()
test.WithContext(func(ctx context.Context) {
h := newNonLeaderHarness(t, ctx)
aBlockFromLeader := builders.BlockPair().WithBenchmarkConsensusBlockProof(leaderPublicKey, leaderPrivateKey)
Expand All @@ -54,6 +56,7 @@ func TestHandlerOfNonLeaderSynchronizesToFutureValidBlock(t *testing.T) {
}

func TestHandlerForBlockConsensusWithBadPrevBlockHashPointer(t *testing.T) {
t.Parallel()
test.WithContext(func(ctx context.Context) {
h := newNonLeaderHarness(t, ctx)
aBlockFromLeader := builders.BlockPair().WithBenchmarkConsensusBlockProof(leaderPublicKey, leaderPrivateKey)
Expand All @@ -71,6 +74,7 @@ func TestHandlerForBlockConsensusWithBadPrevBlockHashPointer(t *testing.T) {
}

func TestHandlerForBlockConsensusWithBadSignature(t *testing.T) {
t.Parallel()
test.WithContext(func(ctx context.Context) {
h := newNonLeaderHarness(t, ctx)
aBlockFromLeader := builders.BlockPair().WithBenchmarkConsensusBlockProof(leaderPublicKey, leaderPrivateKey)
Expand All @@ -92,6 +96,7 @@ func TestHandlerForBlockConsensusWithBadSignature(t *testing.T) {
}

func TestHandlerForBlockConsensusFromNonLeader(t *testing.T) {
t.Parallel()
test.WithContext(func(ctx context.Context) {
h := newNonLeaderHarness(t, ctx)
otherNonLeaderPublicKey, otherNonLeaderPrivateKey := otherNonLeaderKeyPair()
Expand Down
8 changes: 8 additions & 0 deletions services/consensusalgo/benchmarkconsensus/test/leader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func newLeaderHarnessWaitingForCommittedMessages(t *testing.T, ctx context.Conte
}

func TestLeaderInit(t *testing.T) {
t.Parallel()
test.WithContext(func(ctx context.Context) {
h := newLeaderHarnessWaitingForCommittedMessages(t, ctx)

Expand All @@ -25,6 +26,7 @@ func TestLeaderInit(t *testing.T) {
}

func TestLeaderCommitsConsecutiveBlocksAfterEnoughConfirmations(t *testing.T) {
t.Parallel()
test.WithContext(func(ctx context.Context) {
h := newLeaderHarnessWaitingForCommittedMessages(t, ctx)

Expand All @@ -51,6 +53,7 @@ func TestLeaderCommitsConsecutiveBlocksAfterEnoughConfirmations(t *testing.T) {
}

func TestLeaderRetriesCommitOnErrorGeneratingBlock(t *testing.T) {
t.Parallel()
test.WithContext(func(ctx context.Context) {
h := newLeaderHarnessWaitingForCommittedMessages(t, ctx)

Expand All @@ -75,6 +78,7 @@ func TestLeaderRetriesCommitOnErrorGeneratingBlock(t *testing.T) {
}

func TestLeaderRetriesCommitAfterNotEnoughConfirmations(t *testing.T) {
t.Parallel()
test.WithContext(func(ctx context.Context) {
h := newLeaderHarnessWaitingForCommittedMessages(t, ctx)

Expand All @@ -101,6 +105,7 @@ func TestLeaderRetriesCommitAfterNotEnoughConfirmations(t *testing.T) {
}

func TestLeaderIgnoresBadCommittedMessageSignatures(t *testing.T) {
t.Parallel()
test.WithContext(func(ctx context.Context) {
h := newLeaderHarnessWaitingForCommittedMessages(t, ctx)

Expand All @@ -117,6 +122,7 @@ func TestLeaderIgnoresBadCommittedMessageSignatures(t *testing.T) {
}

func TestLeaderIgnoresNonFederationSigners(t *testing.T) {
t.Parallel()
test.WithContext(func(ctx context.Context) {
h := newLeaderHarnessWaitingForCommittedMessages(t, ctx)

Expand All @@ -133,6 +139,7 @@ func TestLeaderIgnoresNonFederationSigners(t *testing.T) {
}

func TestLeaderIgnoresOldConfirmations(t *testing.T) {
t.Parallel()
test.WithContext(func(ctx context.Context) {
h := newLeaderHarnessWaitingForCommittedMessages(t, ctx)

Expand All @@ -158,6 +165,7 @@ func TestLeaderIgnoresOldConfirmations(t *testing.T) {
}

func TestLeaderIgnoresFutureConfirmations(t *testing.T) {
t.Parallel()
test.WithContext(func(ctx context.Context) {
h := newLeaderHarnessWaitingForCommittedMessages(t, ctx)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func newNonLeaderHarness(t *testing.T, ctx context.Context) *harness {
}

func TestNonLeaderInit(t *testing.T) {
t.Parallel()
test.WithContext(func(ctx context.Context) {
h := newNonLeaderHarness(t, ctx)

Expand All @@ -24,6 +25,7 @@ func TestNonLeaderInit(t *testing.T) {
}

func TestNonLeaderDoesNotProposeBlocks(t *testing.T) {
t.Parallel()
test.WithContext(func(ctx context.Context) {
h := newHarness(false)
h.expectNewBlockProposalNotRequested()
Expand All @@ -34,6 +36,7 @@ func TestNonLeaderDoesNotProposeBlocks(t *testing.T) {
}

func TestNonLeaderRepliesToGenesisBlockCommit(t *testing.T) {
t.Parallel()
test.WithContext(func(ctx context.Context) {
h := newNonLeaderHarness(t, ctx)
aBlockFromLeader := builders.BlockPair().WithBenchmarkConsensusBlockProof(leaderPublicKey, leaderPrivateKey)
Expand All @@ -49,6 +52,7 @@ func TestNonLeaderRepliesToGenesisBlockCommit(t *testing.T) {
}

func TestNonLeaderSavesAndRepliesToConsecutiveBlockCommits(t *testing.T) {
t.Parallel()
test.WithContext(func(ctx context.Context) {
h := newNonLeaderHarness(t, ctx)
aBlockFromLeader := builders.BlockPair().WithBenchmarkConsensusBlockProof(leaderPublicKey, leaderPrivateKey)
Expand All @@ -72,6 +76,7 @@ func TestNonLeaderSavesAndRepliesToConsecutiveBlockCommits(t *testing.T) {
}

func TestNonLeaderSavesAndRepliesToAnOldBlockCommit(t *testing.T) {
t.Parallel()
test.WithContext(func(ctx context.Context) {
h := newNonLeaderHarness(t, ctx)
aBlockFromLeader := builders.BlockPair().WithBenchmarkConsensusBlockProof(leaderPublicKey, leaderPrivateKey)
Expand Down Expand Up @@ -102,6 +107,7 @@ func TestNonLeaderSavesAndRepliesToAnOldBlockCommit(t *testing.T) {
}

func TestNonLeaderIgnoresFutureBlockCommit(t *testing.T) {
t.Parallel()
test.WithContext(func(ctx context.Context) {
h := newNonLeaderHarness(t, ctx)
aBlockFromLeader := builders.BlockPair().WithBenchmarkConsensusBlockProof(leaderPublicKey, leaderPrivateKey)
Expand All @@ -117,6 +123,7 @@ func TestNonLeaderIgnoresFutureBlockCommit(t *testing.T) {
}

func TestNonLeaderIgnoresBadPrevBlockHashPointer(t *testing.T) {
t.Parallel()
test.WithContext(func(ctx context.Context) {
h := newNonLeaderHarness(t, ctx)
aBlockFromLeader := builders.BlockPair().WithBenchmarkConsensusBlockProof(leaderPublicKey, leaderPrivateKey)
Expand All @@ -140,6 +147,7 @@ func TestNonLeaderIgnoresBadPrevBlockHashPointer(t *testing.T) {
}

func TestNonLeaderIgnoresBadSignature(t *testing.T) {
t.Parallel()
test.WithContext(func(ctx context.Context) {
h := newNonLeaderHarness(t, ctx)

Expand All @@ -157,6 +165,7 @@ func TestNonLeaderIgnoresBadSignature(t *testing.T) {
}

func TestNonLeaderIgnoresBlocksFromNonLeader(t *testing.T) {
t.Parallel()
test.WithContext(func(ctx context.Context) {
h := newNonLeaderHarness(t, ctx)

Expand Down