diff --git a/lib/grandpa/grandpa.go b/lib/grandpa/grandpa.go index 30c401822a..b81cf52891 100644 --- a/lib/grandpa/grandpa.go +++ b/lib/grandpa/grandpa.go @@ -77,6 +77,7 @@ type Service struct { // channels for communication with other services finalisedCh chan *types.FinalisationInfo + //receivedCommit chan *CommitMessage telemetry telemetry.Client } diff --git a/lib/grandpa/grandpa_integration_test.go b/lib/grandpa/grandpa_integration_test.go index a3a3afc4be..a666caadea 100644 --- a/lib/grandpa/grandpa_integration_test.go +++ b/lib/grandpa/grandpa_integration_test.go @@ -22,6 +22,8 @@ import ( ) func TestUpdateAuthorities(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -50,6 +52,8 @@ func TestUpdateAuthorities(t *testing.T) { } func TestGetDirectVotes(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -87,6 +91,8 @@ func TestGetDirectVotes(t *testing.T) { } func TestGetVotesForBlock_NoDescendantVotes(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -127,6 +133,8 @@ func TestGetVotesForBlock_NoDescendantVotes(t *testing.T) { } func TestGetVotesForBlock_DescendantVotes(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -181,6 +189,8 @@ func TestGetVotesForBlock_DescendantVotes(t *testing.T) { } func TestGetPossibleSelectedAncestors_SameAncestor(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -239,6 +249,8 @@ func TestGetPossibleSelectedAncestors_SameAncestor(t *testing.T) { } func TestGetPossibleSelectedAncestors_VaryingAncestor(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -297,6 +309,8 @@ func TestGetPossibleSelectedAncestors_VaryingAncestor(t *testing.T) { } func TestGetPossibleSelectedAncestors_VaryingAncestor_MoreBranches(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -361,6 +375,8 @@ func TestGetPossibleSelectedAncestors_VaryingAncestor_MoreBranches(t *testing.T) } func TestGetPossibleSelectedBlocks_OneBlock(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -397,6 +413,8 @@ func TestGetPossibleSelectedBlocks_OneBlock(t *testing.T) { } func TestGetPossibleSelectedBlocks_EqualVotes_SameAncestor(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -448,6 +466,8 @@ func TestGetPossibleSelectedBlocks_EqualVotes_SameAncestor(t *testing.T) { } func TestGetPossibleSelectedBlocks_EqualVotes_VaryingAncestor(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -500,6 +520,8 @@ func TestGetPossibleSelectedBlocks_EqualVotes_VaryingAncestor(t *testing.T) { } func TestGetPossibleSelectedBlocks_OneThirdEquivocating(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -545,6 +567,8 @@ func TestGetPossibleSelectedBlocks_OneThirdEquivocating(t *testing.T) { } func TestGetPossibleSelectedBlocks_MoreThanOneThirdEquivocating(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -596,6 +620,8 @@ func TestGetPossibleSelectedBlocks_MoreThanOneThirdEquivocating(t *testing.T) { } func TestGetPreVotedBlock_OneBlock(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -631,6 +657,8 @@ func TestGetPreVotedBlock_OneBlock(t *testing.T) { } func TestGetPreVotedBlock_MultipleCandidates(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -681,6 +709,8 @@ func TestGetPreVotedBlock_MultipleCandidates(t *testing.T) { } func TestGetPreVotedBlock_EvenMoreCandidates(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -753,6 +783,8 @@ func TestGetPreVotedBlock_EvenMoreCandidates(t *testing.T) { } func TestFindParentWithNumber(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -818,6 +850,8 @@ func TestGetBestFinalCandidate_OneBlock(t *testing.T) { } func TestGetBestFinalCandidate_PrecommitAncestor(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -864,6 +898,8 @@ func TestGetBestFinalCandidate_PrecommitAncestor(t *testing.T) { } func TestGetBestFinalCandidate_NoPrecommit(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -904,6 +940,8 @@ func TestGetBestFinalCandidate_NoPrecommit(t *testing.T) { } func TestGetBestFinalCandidate_PrecommitOnAnotherChain(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -950,6 +988,8 @@ func TestGetBestFinalCandidate_PrecommitOnAnotherChain(t *testing.T) { } func TestDeterminePreVote_NoPrimaryPreVote(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -966,6 +1006,8 @@ func TestDeterminePreVote_NoPrimaryPreVote(t *testing.T) { } func TestDeterminePreVote_WithPrimaryPreVote(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -991,6 +1033,8 @@ func TestDeterminePreVote_WithPrimaryPreVote(t *testing.T) { } func TestDeterminePreVote_WithInvalidPrimaryPreVote(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -1017,6 +1061,8 @@ func TestDeterminePreVote_WithInvalidPrimaryPreVote(t *testing.T) { } func TestGetGrandpaGHOST_CommonAncestor(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -1055,6 +1101,8 @@ func TestGetGrandpaGHOST_CommonAncestor(t *testing.T) { } func TestGetGrandpaGHOST_MultipleCandidates(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -1108,6 +1156,8 @@ func TestGetGrandpaGHOST_MultipleCandidates(t *testing.T) { } func TestGrandpaServiceCreateJustification_ShouldCountEquivocatoryVotes(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) diff --git a/lib/grandpa/message_handler_integration_test.go b/lib/grandpa/message_handler_integration_test.go index ed18939ed8..b4f8822755 100644 --- a/lib/grandpa/message_handler_integration_test.go +++ b/lib/grandpa/message_handler_integration_test.go @@ -40,6 +40,7 @@ func newTestDigest() scale.VaryingDataTypeSlice { func buildTestJustification(t *testing.T, qty int, round, setID uint64, kr *keystore.Ed25519Keyring, subround Subround) []SignedVote { + t.Helper() var just []SignedVote for i := 0; i < qty; i++ { j := SignedVote{ @@ -55,6 +56,7 @@ func buildTestJustification(t *testing.T, qty int, round, setID uint64, func createSignedVoteMsg(t *testing.T, number uint32, round, setID uint64, pk *ed25519.Keypair, subround Subround) [64]byte { + t.Helper() // create vote message msg, err := scale.Marshal(FullVote{ Stage: subround, @@ -72,6 +74,7 @@ func createSignedVoteMsg(t *testing.T, number uint32, } func TestDecodeMessage_VoteMessage(t *testing.T) { + t.Parallel() cm := &ConsensusMessage{ Data: common.MustHexToBytes("0x004d000000000000006300000000000000017db9db5ed9967b80143100189ba69d9e4deab85ac3570e5df25686cabe32964a7777000036e6eca85489bebbb0f687ca5404748d5aa2ffabee34e3ed272cc7b2f6d0a82c65b99bc7cd90dbc21bb528289ebf96705dbd7d96918d34d815509b4e0e2a030f34602b88f60513f1c805d87ef52896934baf6a662bc37414dbdbf69356b1a691"), //nolint:lll } @@ -101,6 +104,8 @@ func TestDecodeMessage_VoteMessage(t *testing.T) { } func TestDecodeMessage_CommitMessage(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) @@ -130,6 +135,7 @@ func TestDecodeMessage_CommitMessage(t *testing.T) { } func TestDecodeMessage_NeighbourMessage(t *testing.T) { + t.Parallel() cm := &ConsensusMessage{ Data: common.MustHexToBytes("0x020102000000000000000300000000000000ff000000"), } @@ -146,6 +152,7 @@ func TestDecodeMessage_NeighbourMessage(t *testing.T) { } func TestDecodeMessage_CatchUpRequest(t *testing.T) { + t.Parallel() cm := &ConsensusMessage{ Data: common.MustHexToBytes("0x0311000000000000002200000000000000"), } @@ -162,6 +169,8 @@ func TestDecodeMessage_CatchUpRequest(t *testing.T) { } func TestMessageHandler_VoteMessage(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -198,6 +207,8 @@ func TestMessageHandler_VoteMessage(t *testing.T) { } func TestMessageHandler_NeighbourMessage(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -246,6 +257,8 @@ func TestMessageHandler_NeighbourMessage(t *testing.T) { } func TestMessageHandler_VerifyJustification_InvalidSig(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -280,6 +293,8 @@ func TestMessageHandler_VerifyJustification_InvalidSig(t *testing.T) { } func TestMessageHandler_CommitMessage_NoCatchUpRequest_ValidSig(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -327,6 +342,8 @@ func TestMessageHandler_CommitMessage_NoCatchUpRequest_ValidSig(t *testing.T) { } func TestMessageHandler_CommitMessage_NoCatchUpRequest_MinVoteError(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -361,6 +378,8 @@ func TestMessageHandler_CommitMessage_NoCatchUpRequest_MinVoteError(t *testing.T } func TestMessageHandler_CommitMessage_WithCatchUpRequest(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -392,6 +411,8 @@ func TestMessageHandler_CommitMessage_WithCatchUpRequest(t *testing.T) { } func TestMessageHandler_CatchUpRequest_InvalidRound(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -409,6 +430,8 @@ func TestMessageHandler_CatchUpRequest_InvalidRound(t *testing.T) { } func TestMessageHandler_CatchUpRequest_InvalidSetID(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -426,6 +449,8 @@ func TestMessageHandler_CatchUpRequest_InvalidSetID(t *testing.T) { } func TestMessageHandler_CatchUpRequest_WithResponse(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -500,6 +525,8 @@ func TestMessageHandler_CatchUpRequest_WithResponse(t *testing.T) { } func TestVerifyJustification(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -523,6 +550,8 @@ func TestVerifyJustification(t *testing.T) { } func TestVerifyJustification_InvalidSignature(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -557,6 +586,8 @@ func TestVerifyJustification_InvalidSignature(t *testing.T) { } func TestVerifyJustification_InvalidAuthority(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -589,6 +620,8 @@ func TestVerifyJustification_InvalidAuthority(t *testing.T) { } func TestMessageHandler_VerifyPreVoteJustification(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -625,6 +658,8 @@ func TestMessageHandler_VerifyPreVoteJustification(t *testing.T) { } func TestMessageHandler_VerifyPreCommitJustification(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -663,6 +698,8 @@ func TestMessageHandler_VerifyPreCommitJustification(t *testing.T) { } func TestMessageHandler_HandleCatchUpResponse(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -699,6 +736,8 @@ func TestMessageHandler_HandleCatchUpResponse(t *testing.T) { } func TestMessageHandler_VerifyBlockJustification_WithEquivocatoryVotes(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -764,6 +803,8 @@ func TestMessageHandler_VerifyBlockJustification_WithEquivocatoryVotes(t *testin } func TestMessageHandler_VerifyBlockJustification(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -824,6 +865,8 @@ func TestMessageHandler_VerifyBlockJustification(t *testing.T) { } func TestMessageHandler_VerifyBlockJustification_invalid(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -1131,6 +1174,8 @@ func Test_getEquivocatoryVoters(t *testing.T) { } func Test_VerifyCommitMessageJustification_ShouldRemoveEquivocatoryVotes(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -1204,6 +1249,8 @@ func Test_VerifyCommitMessageJustification_ShouldRemoveEquivocatoryVotes(t *test } func Test_VerifyPrevoteJustification_CountEquivocatoryVoters(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -1282,6 +1329,8 @@ func Test_VerifyPrevoteJustification_CountEquivocatoryVoters(t *testing.T) { } func Test_VerifyPreCommitJustification(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -1359,6 +1408,7 @@ func signFakeFullVote( t *testing.T, auth *ed25519.Keypair, stage Subround, v types.GrandpaVote, round, setID uint64) [64]byte { + t.Helper() msg, err := scale.Marshal(FullVote{ Stage: stage, Vote: v, diff --git a/lib/grandpa/message_integration_test.go b/lib/grandpa/message_integration_test.go index 4f4f174cae..e638f1aedf 100644 --- a/lib/grandpa/message_integration_test.go +++ b/lib/grandpa/message_integration_test.go @@ -19,6 +19,8 @@ import ( ) func TestCommitMessageEncode(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -33,7 +35,6 @@ func TestCommitMessageEncode(t *testing.T) { AuthorityID: gs.publicKeyBytes(), }, } - err = st.Grandpa.SetPrecommits(77, gs.state.setID, just) require.NoError(t, err) @@ -59,6 +60,8 @@ func TestCommitMessageEncode(t *testing.T) { } func TestVoteMessageToConsensusMessage(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -110,6 +113,8 @@ func TestVoteMessageToConsensusMessage(t *testing.T) { } func TestCommitMessageToConsensusMessage(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -141,6 +146,8 @@ func TestCommitMessageToConsensusMessage(t *testing.T) { } func TestNewCatchUpResponse(t *testing.T) { + t.Parallel() + kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) aliceKeyPair := kr.Alice().(*ed25519.Keypair) @@ -215,6 +222,7 @@ func TestNewCatchUpResponse(t *testing.T) { } func TestNeighbourMessageToConsensusMessage(t *testing.T) { + t.Parallel() msg := &NeighbourPacketV1{ Round: 2, SetID: 3, diff --git a/lib/grandpa/types_test.go b/lib/grandpa/types_test.go index 18ae1b7c45..b16670a9c4 100644 --- a/lib/grandpa/types_test.go +++ b/lib/grandpa/types_test.go @@ -15,6 +15,7 @@ import ( ) func TestPubkeyToVoter(t *testing.T) { + t.Parallel() kr, err := keystore.NewEd25519Keyring() require.NoError(t, err) @@ -27,6 +28,7 @@ func TestPubkeyToVoter(t *testing.T) { } func TestSignedVoteEncoding(t *testing.T) { + t.Parallel() exp := common.MustHexToBytes("0x0a0b0c0d00000000000000000000000000000000000000000000000000000000e7030000010203040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000506070800000000000000000000000000000000000000000000000000000000") //nolint:lll just := SignedVote{ Vote: *testVote, @@ -46,6 +48,7 @@ func TestSignedVoteEncoding(t *testing.T) { } func TestSignedVoteArrayEncoding(t *testing.T) { + t.Parallel() exp := common.MustHexToBytes("0x040a0b0c0d00000000000000000000000000000000000000000000000000000000e7030000010203040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000506070800000000000000000000000000000000000000000000000000000000") //nolint:lll just := []SignedVote{ { @@ -67,6 +70,7 @@ func TestSignedVoteArrayEncoding(t *testing.T) { } func TestJustification(t *testing.T) { + t.Parallel() exp := common.MustHexToBytes("0x6300000000000000000000000000000000000000000000000000000000000000000000000000000000000000040a0b0c0d00000000000000000000000000000000000000000000000000000000e7030000010203040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000506070800000000000000000000000000000000000000000000000000000000") //nolint:lll just := SignedVote{ Vote: *testVote, @@ -92,6 +96,7 @@ func TestJustification(t *testing.T) { } func TestJustification_Decode(t *testing.T) { + t.Parallel() // data received from network data := testdata.Data3b1b0(t) fj := Justification{} diff --git a/lib/grandpa/vote_message.go b/lib/grandpa/vote_message.go index 3a67d968ce..9937cf93ad 100644 --- a/lib/grandpa/vote_message.go +++ b/lib/grandpa/vote_message.go @@ -158,6 +158,7 @@ func (s *Service) validateVoteMessage(from peer.ID, m *VoteMessage) (*Vote, erro return nil, fmt.Errorf("%w: received round %d but state round is %d", errRoundsMismatch, m.Round, s.state.round) } else if m.Round > s.state.round { + // Message round is higher by 1 than the round of our state, // we may be lagging behind, so store the message in the tracker // for processing later in the coming few milliseconds. @@ -177,7 +178,7 @@ func (s *Service) validateVoteMessage(from peer.ID, m *VoteMessage) (*Vote, erro // if the vote is from ourselves, return an error kb := [32]byte(s.publicKeyBytes()) if bytes.Equal(m.Message.AuthorityID[:], kb[:]) { - return nil, errVoteFromSelf + return nil, fmt.Errorf("%w", errVoteFromSelf) } err = s.validateVote(vote) @@ -199,7 +200,7 @@ func (s *Service) validateVoteMessage(from peer.ID, m *VoteMessage) (*Vote, erro equivocated := s.checkForEquivocation(voter, just, m.Message.Stage) if equivocated { - return nil, ErrEquivocation + return nil, fmt.Errorf("%w", ErrEquivocation) } switch m.Message.Stage { diff --git a/lib/grandpa/vote_message_integration_test.go b/lib/grandpa/vote_message_integration_test.go index 4c847ce186..3ece2d6a6b 100644 --- a/lib/grandpa/vote_message_integration_test.go +++ b/lib/grandpa/vote_message_integration_test.go @@ -17,6 +17,7 @@ import ( ) func TestCheckForEquivocation_NoEquivocation(t *testing.T) { + t.Parallel() st := newTestState(t) net := newTestNetwork(t) @@ -46,6 +47,7 @@ func TestCheckForEquivocation_NoEquivocation(t *testing.T) { } func TestCheckForEquivocation_WithEquivocation(t *testing.T) { + t.Parallel() st := newTestState(t) net := newTestNetwork(t) @@ -87,6 +89,7 @@ func TestCheckForEquivocation_WithEquivocation(t *testing.T) { } func TestCheckForEquivocation_WithExistingEquivocation(t *testing.T) { + t.Parallel() st := newTestState(t) net := newTestNetwork(t) @@ -138,6 +141,7 @@ func TestCheckForEquivocation_WithExistingEquivocation(t *testing.T) { } func TestValidateMessage_Valid(t *testing.T) { + t.Parallel() st := newTestState(t) net := newTestNetwork(t) @@ -170,6 +174,7 @@ func TestValidateMessage_Valid(t *testing.T) { } func TestValidateMessage_InvalidSignature(t *testing.T) { + t.Parallel() st := newTestState(t) net := newTestNetwork(t) @@ -204,6 +209,7 @@ func TestValidateMessage_InvalidSignature(t *testing.T) { } func TestValidateMessage_SetIDMismatch(t *testing.T) { + t.Parallel() st := newTestState(t) net := newTestNetwork(t) @@ -236,6 +242,7 @@ func TestValidateMessage_SetIDMismatch(t *testing.T) { } func TestValidateMessage_Equivocation(t *testing.T) { + t.Parallel() st := newTestState(t) net := newTestNetwork(t) @@ -280,6 +287,7 @@ func TestValidateMessage_Equivocation(t *testing.T) { } func TestValidateMessage_BlockDoesNotExist(t *testing.T) { + t.Parallel() st := newTestState(t) net := newTestNetwork(t) @@ -315,6 +323,7 @@ func TestValidateMessage_BlockDoesNotExist(t *testing.T) { } func TestValidateMessage_IsNotDescendant(t *testing.T) { + t.Parallel() st := newTestState(t) net := newTestNetwork(t)