github.com/koko1123/flow-go-1@v0.29.6/engine/execution/convert_test.go (about)

     1  package execution_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  	"github.com/stretchr/testify/mock"
     8  	"github.com/stretchr/testify/require"
     9  
    10  	"github.com/koko1123/flow-go-1/engine/execution"
    11  	executionUnittest "github.com/koko1123/flow-go-1/engine/execution/state/unittest"
    12  	"github.com/koko1123/flow-go-1/model/flow"
    13  	modulemock "github.com/koko1123/flow-go-1/module/mock"
    14  	"github.com/koko1123/flow-go-1/utils/unittest"
    15  )
    16  
    17  func Test_BuildChunkDataPack(t *testing.T) {
    18  	t.Run("number of transactions is included", func(t *testing.T) {
    19  
    20  		// fixture provide one tx per collection, and number of collections equal to
    21  		// len of provided signersIDs
    22  		cr := executionUnittest.ComputationResultFixture([][]flow.Identifier{
    23  			{flow.ZeroID},
    24  			{flow.ZeroID},
    25  			{flow.ZeroID},
    26  		})
    27  
    28  		numberOfChunks := 4
    29  		exemetrics := new(modulemock.ExecutionMetrics)
    30  		exemetrics.On("ExecutionChunkDataPackGenerated",
    31  			mock.Anything,
    32  			mock.Anything).
    33  			Return(nil).
    34  			Times(numberOfChunks) // 1 collection + system collection
    35  
    36  		_, _, result, err := execution.GenerateExecutionResultAndChunkDataPacks(exemetrics, unittest.IdentifierFixture(), unittest.StateCommitmentFixture(), cr)
    37  		assert.NoError(t, err)
    38  
    39  		require.Len(t, result.Chunks, numberOfChunks) // +1 for system chunk
    40  
    41  		assert.Equal(t, uint64(1), result.Chunks[0].NumberOfTransactions)
    42  		assert.Equal(t, uint64(1), result.Chunks[1].NumberOfTransactions)
    43  		assert.Equal(t, uint64(1), result.Chunks[2].NumberOfTransactions)
    44  
    45  		// system chunk is special case, but currently also 1 tx
    46  		assert.Equal(t, uint64(1), result.Chunks[3].NumberOfTransactions)
    47  	})
    48  }