github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/utils/unittest/mocks/finalized_header_cache.go (about)

     1  package mocks
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/require"
     7  
     8  	"github.com/onflow/flow-go/model/flow"
     9  	"github.com/onflow/flow-go/state/protocol"
    10  )
    11  
    12  type finalizedHeaderCache struct {
    13  	t     *testing.T
    14  	state protocol.State
    15  }
    16  
    17  func NewFinalizedHeaderCache(t *testing.T, state protocol.State) *finalizedHeaderCache {
    18  	return &finalizedHeaderCache{
    19  		t:     t,
    20  		state: state,
    21  	}
    22  }
    23  
    24  func (cache *finalizedHeaderCache) Get() *flow.Header {
    25  	head, err := cache.state.Final().Head()
    26  	require.NoError(cache.t, err)
    27  	return head
    28  }