From fd85148976fd80e996c47025230bcf39f7155a80 Mon Sep 17 00:00:00 2001 From: nabarun Date: Mon, 4 Jul 2022 12:02:32 +0530 Subject: [PATCH] Add test case with 16 workers for TestRecovery --- pkg/snapshot/service_test.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/pkg/snapshot/service_test.go b/pkg/snapshot/service_test.go index 0d08ba8..4202d57 100644 --- a/pkg/snapshot/service_test.go +++ b/pkg/snapshot/service_test.go @@ -94,15 +94,18 @@ func TestRecovery(t *testing.T) { // Max number of children of a node in trie const maxChildren = 16 + const maxChildrenWithSiblings = 15 + expectedPublishStateNodeCalls := math.Min( - 16, + maxChildrenWithSiblings, math.Min( float64(workers), float64(len(fixt.Block1_StateNodePaths)), ), ) pub.EXPECT().PublishStateNode(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()). - Times(int(expectedPublishStateNodeCalls)). + MinTimes(int(expectedPublishStateNodeCalls)). + MaxTimes(maxChildren). DoAndReturn(failingPublishStateNode) config := testConfig(fixt.ChaindataPath, fixt.AncientdataPath) @@ -128,7 +131,17 @@ func TestRecovery(t *testing.T) { t.Fatal("cannot stat recovery file:", err) } + pub, tx = makeMocks(t) + pub.EXPECT().PublishHeader(gomock.Any()).AnyTimes() + pub.EXPECT().BeginTx().Return(tx, nil).AnyTimes() + pub.EXPECT().PrepareTxForBatch(gomock.Any(), gomock.Any()).Return(tx, nil).AnyTimes() + tx.EXPECT().Commit().AnyTimes() pub.EXPECT().PublishStateNode(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() + service, err = NewSnapshotService(edb, pub, recovery) + if err != nil { + t.Fatal(err) + } + err = service.CreateSnapshot(params) if err != nil { t.Fatal(err) @@ -144,7 +157,7 @@ func TestRecovery(t *testing.T) { } } - testCases := []int{1, 4, 32} + testCases := []int{1, 4, 16, 32} for _, tc := range testCases { t.Run("case", func(t *testing.T) { runCase(t, tc) }) }