github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/model/chunks/chunkLocator_test.go (about)

     1  package chunks_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/require"
     7  
     8  	"github.com/onflow/flow-go/utils/unittest"
     9  )
    10  
    11  // TestChunkLocatorConvert evaluates converting chunk locator list to map and vice versa.
    12  func TestChunkLocatorConvert(t *testing.T) {
    13  	originalList := unittest.ChunkLocatorListFixture(10)
    14  	locatorMap := originalList.ToMap()
    15  
    16  	require.Equal(t, len(originalList), len(locatorMap))
    17  	for _, locator := range originalList {
    18  		_, ok := locatorMap[locator.ID()]
    19  		require.True(t, ok, "missing chunk locator in conversion from list to map")
    20  	}
    21  
    22  	convertedList := locatorMap.ToList()
    23  	require.ElementsMatch(t, originalList, convertedList)
    24  }