github.com/koko1123/flow-go-1@v0.29.6/state/protocol/util_test.go (about)

     1  package protocol_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  	"github.com/stretchr/testify/require"
     8  
     9  	"github.com/koko1123/flow-go-1/state/protocol"
    10  	"github.com/koko1123/flow-go-1/utils/unittest"
    11  )
    12  
    13  func TestIsSporkRootSnapshot(t *testing.T) {
    14  	t.Run("spork root", func(t *testing.T) {
    15  		snapshot := unittest.RootSnapshotFixture(unittest.IdentityListFixture(10, unittest.WithAllRoles()))
    16  		isSporkRoot, err := protocol.IsSporkRootSnapshot(snapshot)
    17  		require.NoError(t, err)
    18  		assert.True(t, isSporkRoot)
    19  	})
    20  
    21  	t.Run("other snapshot", func(t *testing.T) {
    22  		snapshot := unittest.RootSnapshotFixture(unittest.IdentityListFixture(10, unittest.WithAllRoles()))
    23  		snapshot.Encodable().SealingSegment.Blocks = unittest.BlockFixtures(5)
    24  		isSporkRoot, err := protocol.IsSporkRootSnapshot(snapshot)
    25  		require.NoError(t, err)
    26  		assert.False(t, isSporkRoot)
    27  	})
    28  }