From c7ea113626154eb902a5d8aa586a60da15b7d149 Mon Sep 17 00:00:00 2001 From: chris erway Date: Tue, 7 Mar 2023 12:35:26 -0500 Subject: [PATCH] split TestPlayerRetainsReceivedValidatedAtPP from TestPlayerRetainsReceivedValidatedAt --- agreement/player_test.go | 41 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/agreement/player_test.go b/agreement/player_test.go index 888319f6de..4f76a7bbec 100644 --- a/agreement/player_test.go +++ b/agreement/player_test.go @@ -3244,6 +3244,36 @@ func TestPlayerRetainsReceivedValidatedAt(t *testing.T) { pWhite, pM, helper := setupP(t, r-1, p, soft) pP, pV := helper.MakeRandomProposalPayload(t, r-1) + // send voteVerified message + vVote := helper.MakeVerifiedVote(t, 0, r-1, p, propose, *pV) + inMsg := messageEvent{T: voteVerified, Input: message{Vote: vVote, UnauthenticatedVote: vVote.u()}} + err, panicErr := pM.transition(inMsg) + require.NoError(t, err) + require.NoError(t, panicErr) + + // send payloadPresent message + m := message{UnauthenticatedProposal: pP.u()} + inMsg = messageEvent{T: payloadPresent, Input: m} + inMsg = inMsg.AttachReceivedAt(time.Second) + err, panicErr = pM.transition(inMsg) + require.NoError(t, err) + require.NoError(t, panicErr) + + assertCorrectReceivedAtSet(t, pWhite, pM, helper, r, p, pP, pV, m) +} + +// test that ReceivedAt and ValidateAt timing information are retained in proposalStore +// when the payloadPresent (as part of the CompoundMessage encoding used by PP messages) +// and payloadVerified events are processed, and that both timings +// are available when the ensureAction is called for the block. +func TestPlayerRetainsReceivedValidatedAtPP(t *testing.T) { + partitiontest.PartitionTest(t) + + const r = round(20239) + const p = period(1001) + pWhite, pM, helper := setupP(t, r-1, p, soft) + pP, pV := helper.MakeRandomProposalPayload(t, r-1) + // create a PP message for an arbitrary proposal/payload similar to setupCompoundMessage vVote := helper.MakeVerifiedVote(t, 0, r-1, p, propose, *pV) voteMsg := message{Vote: vVote, UnauthenticatedVote: vVote.u()} @@ -3265,15 +3295,20 @@ func TestPlayerRetainsReceivedValidatedAt(t *testing.T) { require.NoError(t, err) require.NoError(t, panicErr) + assertCorrectReceivedAtSet(t, pWhite, pM, helper, r, p, pP, pV, proposalMsg) +} + +func assertCorrectReceivedAtSet(t *testing.T, pWhite *player, pM ioAutomata, helper *voteMakerHelper, + r round, p period, pP *proposal, pV *proposalValue, proposalMsg message) { // make sure payload verify requests - verifyEvent = ev(cryptoAction{T: verifyPayload, M: proposalMsg}) + verifyEvent := ev(cryptoAction{T: verifyPayload, M: proposalMsg}) tr := pM.getTrace() require.Truef(t, tr.Contains(verifyEvent), "Player should verify payload: %s", tr.String()) // payloadVerified - inMsg = messageEvent{T: payloadVerified, Input: message{Proposal: *pP}, Proto: ConsensusVersionView{Version: protocol.ConsensusCurrentVersion}} + inMsg := messageEvent{T: payloadVerified, Input: message{Proposal: *pP}, Proto: ConsensusVersionView{Version: protocol.ConsensusCurrentVersion}} inMsg = inMsg.AttachValidatedAt(2 * time.Second) // call AttachValidatedAt like demux would - err, panicErr = pM.transition(inMsg) + err, panicErr := pM.transition(inMsg) require.NoError(t, err) require.NoError(t, panicErr)