Skip to content

Commit 495214f

Browse files
committed
add blockexecutiondata tests, fix indexer tests
1 parent 7fe3055 commit 495214f

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

module/executiondatasync/execution_data/execution_data_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,42 @@ import (
77

88
"github.com/onflow/flow-go/model/flow"
99
"github.com/onflow/flow-go/module/executiondatasync/execution_data"
10+
"github.com/onflow/flow-go/utils/unittest/fixtures"
1011
)
1112

13+
func TestBlockExecutionDataHelpers(t *testing.T) {
14+
g := fixtures.NewGeneratorSuite()
15+
chunkDatas := g.ChunkExecutionDatas().List(5)
16+
blockData := g.BlockExecutionDatas().Fixture(
17+
fixtures.BlockExecutionData.WithChunkExecutionDatas(chunkDatas...),
18+
)
19+
20+
expectedStardardChunks := chunkDatas[:len(chunkDatas)-1]
21+
expectedStandardCollections := make([]*flow.Collection, len(expectedStardardChunks))
22+
for i, chunk := range expectedStardardChunks {
23+
expectedStandardCollections[i] = chunk.Collection
24+
}
25+
26+
expectedSystemChunk := chunkDatas[len(chunkDatas)-1]
27+
expectedSystemCollection := expectedSystemChunk.Collection
28+
29+
t.Run("StandardChunks", func(t *testing.T) {
30+
assert.Equal(t, blockData.StandardChunks(), expectedStardardChunks)
31+
})
32+
33+
t.Run("StandardCollections", func(t *testing.T) {
34+
assert.Equal(t, blockData.StandardCollections(), expectedStandardCollections)
35+
})
36+
37+
t.Run("SystemChunk", func(t *testing.T) {
38+
assert.Equal(t, blockData.SystemChunk(), expectedSystemChunk)
39+
})
40+
41+
t.Run("SystemCollection", func(t *testing.T) {
42+
assert.Equal(t, blockData.SystemCollection(), expectedSystemCollection)
43+
})
44+
}
45+
1246
func TestConvertTransactionResults(t *testing.T) {
1347
t.Parallel()
1448

module/state_synchronization/indexer/indexer_core_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,7 @@ func TestExecutionState_IndexBlockData(t *testing.T) {
250250
assert.ElementsMatch(t, tf.ExpectedRegisterEntries, entries)
251251
}).
252252
Return(nil)
253-
for _, collection := range tf.ExpectedCollections {
254-
test.collectionIndexer.On("OnCollectionReceived", collection).Once()
255-
}
253+
test.collectionIndexer.On("IndexCollections", tf.ExpectedCollections).Return(nil).Once()
256254
for txID, scheduledTxID := range tf.ExpectedScheduledTransactions {
257255
test.scheduledTransactions.On("BatchIndex", mock.Anything, blockID, txID, scheduledTxID, mock.Anything).
258256
Return(func(lctx lockctx.Proof, blockID flow.Identifier, txID flow.Identifier, scheduledTxID uint64, batch storage.ReaderBatchWriter) error {

module/state_synchronization/indexer/indexer_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func TestIndexer_Success(t *testing.T) {
201201
})
202202

203203
test.executionData.On("Get", blockID).Return(ed, true).Once()
204-
test.indexTest.collectionIndexer.On("OnCollectionReceived", collection).Return(nil).Once()
204+
test.indexTest.collectionIndexer.On("IndexCollections", ed.StandardCollections()).Return(nil).Once()
205205
test.indexTest.registers.On("Store", flow.RegisterEntries{}, block.Height).Return(nil).Once()
206206
}
207207

@@ -243,7 +243,7 @@ func TestIndexer_Failure(t *testing.T) {
243243
})
244244

245245
test.executionData.On("Get", blockID).Return(ed, true).Once()
246-
test.indexTest.collectionIndexer.On("OnCollectionReceived", collection).Return(nil).Once()
246+
test.indexTest.collectionIndexer.On("IndexCollections", ed.StandardCollections()).Return(nil).Once()
247247

248248
// return an error on the last block to trigger the error path
249249
if block.Height == lastHeight {

0 commit comments

Comments
 (0)