Skip to content

Commit

Permalink
Merge pull request #77 from orbs-network/feautre/changed-slow-test-to…
Browse files Browse the repository at this point in the history
…-parallel

Added t.Parallel to benchmark consensus tests since they’re slow and …
  • Loading branch information
electricmonk authored Aug 10, 2018
2 parents e997a2d + ccc1ba5 commit 53dddd2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
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

0 comments on commit 53dddd2

Please sign in to comment.