Skip to content

Commit

Permalink
clean up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanschalm committed Jul 8, 2024
1 parent 62c5d69 commit 66f6e7f
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions consensus/hotstuff/committees/consensus_committee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ func (suite *ConsensusSuite) SetupTest() {
suite.snapshot = new(protocolmock.Snapshot)
suite.epochs = mocks.NewEpochQuery(suite.T(), suite.currentEpochCounter)

// TODO: temporary to make tests pass. Should replace instances of ByBlockID with this in tests and remove here
suite.state.On("AtHeight", mock.Anything).Return(suite.snapshot)

suite.state.On("Final").Return(suite.snapshot)
suite.snapshot.On("EpochPhase").Return(
func() flow.EpochPhase { return suite.phase },
Expand Down Expand Up @@ -90,7 +87,7 @@ func (suite *ConsensusSuite) CreateAndStartCommittee() {
// behaviour when committing an epoch, by sending the protocol event to the committee.
func (suite *ConsensusSuite) CommitEpoch(epoch protocol.Epoch) {
firstBlockOfCommittedPhase := unittest.BlockHeaderFixture()
suite.state.On("AtBlockID", firstBlockOfCommittedPhase.ID()).Return(suite.snapshot)
suite.state.On("AtHeight", firstBlockOfCommittedPhase.Height).Return(suite.snapshot)
suite.epochs.Add(epoch)
suite.committee.EpochCommittedPhaseStarted(1, firstBlockOfCommittedPhase)

Expand Down Expand Up @@ -189,7 +186,7 @@ func (suite *ConsensusSuite) TestProtocolEvents_CommittedEpoch() {
nextEpoch := newMockEpoch(suite.currentEpochCounter+1, unittest.IdentityListFixture(10), 201, 300, true)

firstBlockOfCommittedPhase := unittest.BlockHeaderFixture()
suite.state.On("AtBlockID", firstBlockOfCommittedPhase.ID()).Return(suite.snapshot)
suite.state.On("AtHeight", firstBlockOfCommittedPhase.Height).Return(suite.snapshot)
suite.epochs.Add(nextEpoch)
suite.committee.EpochCommittedPhaseStarted(suite.currentEpochCounter, firstBlockOfCommittedPhase)
// wait for the protocol event to be processed (async)
Expand Down Expand Up @@ -226,7 +223,7 @@ func (suite *ConsensusSuite) TestProtocolEvents_EpochExtended() {
}
refBlock := unittest.BlockHeaderFixture()
addExtension(curEpoch, extension)
suite.state.On("AtBlockID", refBlock.ID()).Return(suite.snapshot)
suite.state.On("AtHeight", refBlock.Height).Return(suite.snapshot)

suite.committee.EpochExtended(suite.currentEpochCounter, refBlock, extension)
// wait for the protocol event to be processed (async)
Expand Down Expand Up @@ -270,7 +267,7 @@ func (suite *ConsensusSuite) TestProtocolEvents_EpochExtendedMultiple() {
}
refBlock := unittest.BlockHeaderFixture()
addExtension(curEpoch, extension)
suite.state.On("AtBlockID", refBlock.ID()).Return(suite.snapshot)
suite.state.On("AtHeight", refBlock.Height).Return(suite.snapshot)

suite.committee.EpochExtended(suite.currentEpochCounter, refBlock, extension)
// wait for the protocol event to be processed (async)
Expand Down Expand Up @@ -683,8 +680,7 @@ func TestRemoveOldEpochs(t *testing.T) {

currentEpochPhase = flow.EpochPhaseCommitted
firstBlockOfCommittedPhase := unittest.BlockHeaderFixture()
state.On("AtBlockID", firstBlockOfCommittedPhase.ID()).Return(snapshot).Maybe()
state.On("AtHeight", mock.Anything).Return(snapshot) // TODO remove
state.On("AtHeight", firstBlockOfCommittedPhase.Height).Return(snapshot)
com.EpochCommittedPhaseStarted(currentEpochCounter, firstBlockOfCommittedPhase)
// wait for the protocol event to be processed (async)
require.Eventually(t, func() bool {
Expand Down

0 comments on commit 66f6e7f

Please sign in to comment.