From bd2dda4a52b3c75200488abf04059f1bf458ab9b Mon Sep 17 00:00:00 2001 From: Urvi Date: Tue, 14 Nov 2023 20:04:25 -0800 Subject: [PATCH 1/2] services/horizon: Remove unused mocks and other cosmetic changes --- .../internal/ingest/processor_runner_test.go | 68 ++++++------------- 1 file changed, 21 insertions(+), 47 deletions(-) diff --git a/services/horizon/internal/ingest/processor_runner_test.go b/services/horizon/internal/ingest/processor_runner_test.go index af7c92a23d..232dd957a2 100644 --- a/services/horizon/internal/ingest/processor_runner_test.go +++ b/services/horizon/internal/ingest/processor_runner_test.go @@ -51,22 +51,20 @@ func TestProcessorRunnerRunHistoryArchiveIngestionGenesis(t *testing.T) { Return(mockAccountSignersBatchInsertBuilder).Twice() mockClaimableBalanceBatchInsertBuilder := &history.MockClaimableBalanceBatchInsertBuilder{} + mockClaimableBalanceBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() q.MockQClaimableBalances.On("NewClaimableBalanceBatchInsertBuilder"). Return(mockClaimableBalanceBatchInsertBuilder).Twice() mockClaimantsBatchInsertBuilder := &history.MockClaimableBalanceClaimantBatchInsertBuilder{} + mockClaimantsBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() q.MockQClaimableBalances.On("NewClaimableBalanceClaimantBatchInsertBuilder"). Return(mockClaimantsBatchInsertBuilder).Twice() - mockClaimantsBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - mockClaimableBalanceBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - mockLiquidityPoolBatchInsertBuilder := &history.MockLiquidityPoolBatchInsertBuilder{} + mockLiquidityPoolBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() q.MockQLiquidityPools.On("NewLiquidityPoolBatchInsertBuilder"). Return(mockLiquidityPoolBatchInsertBuilder).Twice() - mockLiquidityPoolBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - mockOffersBatchInsertBuilder := &history.MockOffersBatchInsertBuilder{} mockOffersBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() q.MockQOffers.On("NewOffersBatchInsertBuilder").Return(mockOffersBatchInsertBuilder).Twice() @@ -138,25 +136,24 @@ func TestProcessorRunnerRunHistoryArchiveIngestionHistoryArchive(t *testing.T) { Return(mockAccountSignersBatchInsertBuilder).Twice() mockClaimableBalanceBatchInsertBuilder := &history.MockClaimableBalanceBatchInsertBuilder{} + mockClaimableBalanceBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() q.MockQClaimableBalances.On("NewClaimableBalanceBatchInsertBuilder"). Return(mockClaimableBalanceBatchInsertBuilder).Twice() mockClaimantsBatchInsertBuilder := &history.MockClaimableBalanceClaimantBatchInsertBuilder{} + mockClaimantsBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() q.MockQClaimableBalances.On("NewClaimableBalanceClaimantBatchInsertBuilder"). Return(mockClaimantsBatchInsertBuilder).Twice() - mockClaimantsBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - mockClaimableBalanceBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - mockLiquidityPoolBatchInsertBuilder := &history.MockLiquidityPoolBatchInsertBuilder{} + mockLiquidityPoolBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() q.MockQLiquidityPools.On("NewLiquidityPoolBatchInsertBuilder"). Return(mockLiquidityPoolBatchInsertBuilder).Twice() - mockLiquidityPoolBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - mockOffersBatchInsertBuilder := &history.MockOffersBatchInsertBuilder{} mockOffersBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - q.MockQOffers.On("NewOffersBatchInsertBuilder").Return(mockOffersBatchInsertBuilder).Twice() + q.MockQOffers.On("NewOffersBatchInsertBuilder"). + Return(mockOffersBatchInsertBuilder).Twice() q.MockQAssetStats.On("InsertAssetStats", ctx, []history.ExpAssetStat{}, 100000). Return(nil) @@ -202,18 +199,13 @@ func TestProcessorRunnerRunHistoryArchiveIngestionProtocolVersionNotSupported(t q.MockQClaimableBalances.On("NewClaimableBalanceClaimantBatchInsertBuilder"). Return(mockClaimantsBatchInsertBuilder).Once() - mockClaimantsBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - mockClaimableBalanceBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - mockLiquidityPoolBatchInsertBuilder := &history.MockLiquidityPoolBatchInsertBuilder{} q.MockQLiquidityPools.On("NewLiquidityPoolBatchInsertBuilder"). - Return(mockLiquidityPoolBatchInsertBuilder).Twice() - - mockLiquidityPoolBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() + Return(mockLiquidityPoolBatchInsertBuilder).Once() mockOffersBatchInsertBuilder := &history.MockOffersBatchInsertBuilder{} - mockOffersBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - q.MockQOffers.On("NewOffersBatchInsertBuilder").Return(mockOffersBatchInsertBuilder).Once() + q.MockQOffers.On("NewOffersBatchInsertBuilder"). + Return(mockOffersBatchInsertBuilder).Once() q.MockQAssetStats.On("InsertAssetStats", ctx, []history.ExpAssetStat{}, 100000). Return(nil) @@ -258,10 +250,9 @@ func TestProcessorRunnerBuildChangeProcessor(t *testing.T) { q.MockQLiquidityPools.On("NewLiquidityPoolBatchInsertBuilder"). Return(mockLiquidityPoolBatchInsertBuilder).Twice() - mockLiquidityPoolBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - mockOfferBatchInsertBuilder := &history.MockOffersBatchInsertBuilder{} - q.MockQOffers.On("NewOffersBatchInsertBuilder").Return(mockOfferBatchInsertBuilder).Twice() + q.MockQOffers.On("NewOffersBatchInsertBuilder"). + Return(mockOfferBatchInsertBuilder).Twice() runner := ProcessorRunner{ ctx: ctx, @@ -388,23 +379,6 @@ func TestProcessorRunnerWithFilterEnabled(t *testing.T) { q.MockQTransactions.On("NewTransactionFilteredTmpBatchInsertBuilder"). Return(mockTransactionsFilteredTmpBatchInsertBuilder) - mockClaimableBalanceBatchInsertBuilder := &history.MockClaimableBalanceBatchInsertBuilder{} - q.MockQClaimableBalances.On("NewClaimableBalanceBatchInsertBuilder"). - Return(mockClaimableBalanceBatchInsertBuilder).Once() - - mockClaimantsBatchInsertBuilder := &history.MockClaimableBalanceClaimantBatchInsertBuilder{} - q.MockQClaimableBalances.On("NewClaimableBalanceClaimantBatchInsertBuilder"). - Return(mockClaimantsBatchInsertBuilder).Once() - - mockClaimantsBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - mockClaimableBalanceBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - - mockLiquidityPoolBatchInsertBuilder := &history.MockLiquidityPoolBatchInsertBuilder{} - q.MockQLiquidityPools.On("NewLiquidityPoolBatchInsertBuilder"). - Return(mockLiquidityPoolBatchInsertBuilder).Twice() - - mockLiquidityPoolBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - q.On("DeleteTransactionsFilteredTmpOlderThan", ctx, mock.AnythingOfType("uint64")). Return(int64(0), nil) @@ -587,24 +561,24 @@ func mockBatchBuilders(q *mockDBQ, mockSession *db.MockSession, ctx context.Cont Return(mockOperationLiquidityPoolBatchInsertBuilder) mockClaimableBalanceClaimantBatchInsertBuilder := &history.MockClaimableBalanceClaimantBatchInsertBuilder{} - mockClaimableBalanceClaimantBatchInsertBuilder.On("Exec", ctx).Return(nil) + mockClaimableBalanceClaimantBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() q.MockQClaimableBalances.On("NewClaimableBalanceClaimantBatchInsertBuilder"). - Return(mockClaimableBalanceClaimantBatchInsertBuilder) + Return(mockClaimableBalanceClaimantBatchInsertBuilder).Twice() mockClaimableBalanceBatchInsertBuilder := &history.MockClaimableBalanceBatchInsertBuilder{} + mockClaimableBalanceBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() q.MockQClaimableBalances.On("NewClaimableBalanceBatchInsertBuilder"). - Return(mockClaimableBalanceBatchInsertBuilder) - mockClaimableBalanceBatchInsertBuilder.On("Exec", ctx).Return(nil) + Return(mockClaimableBalanceBatchInsertBuilder).Twice() mockLiquidityPoolBatchInsertBuilder := &history.MockLiquidityPoolBatchInsertBuilder{} + mockLiquidityPoolBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() q.MockQLiquidityPools.On("NewLiquidityPoolBatchInsertBuilder"). Return(mockLiquidityPoolBatchInsertBuilder).Twice() - mockLiquidityPoolBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - mockOfferBatchInsertBuilder := &history.MockOffersBatchInsertBuilder{} - mockOfferBatchInsertBuilder.On("Exec", ctx).Return(nil) - q.MockQOffers.On("NewOffersBatchInsertBuilder").Return(mockOfferBatchInsertBuilder) + mockOfferBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() + q.MockQOffers.On("NewOffersBatchInsertBuilder"). + Return(mockOfferBatchInsertBuilder).Twice() q.On("NewTradeBatchInsertBuilder").Return(&history.MockTradeBatchInsertBuilder{}) From 0471b4c53a99bd9c6a5385b8079f90bb32426220 Mon Sep 17 00:00:00 2001 From: Urvi Date: Wed, 15 Nov 2023 13:11:37 -0800 Subject: [PATCH 2/2] Refactoring to reduce code duplication and add asserts for mock invocations --- .../internal/ingest/processor_runner_test.go | 162 ++++++------------ 1 file changed, 53 insertions(+), 109 deletions(-) diff --git a/services/horizon/internal/ingest/processor_runner_test.go b/services/horizon/internal/ingest/processor_runner_test.go index 232dd957a2..b932a05129 100644 --- a/services/horizon/internal/ingest/processor_runner_test.go +++ b/services/horizon/internal/ingest/processor_runner_test.go @@ -38,36 +38,16 @@ func TestProcessorRunnerRunHistoryArchiveIngestionGenesis(t *testing.T) { }, }).Return(nil).Once() - mockAccountSignersBatchInsertBuilder := &history.MockAccountSignersBatchInsertBuilder{} - defer mock.AssertExpectationsForObjects(t, mockAccountSignersBatchInsertBuilder) - mockAccountSignersBatchInsertBuilder.On("Add", history.AccountSigner{ + batchBuilders := mockChangeProcessorBatchBuilders(q, ctx, true) + defer mock.AssertExpectationsForObjects(t, batchBuilders...) + + assert.IsType(t, &history.MockAccountSignersBatchInsertBuilder{}, batchBuilders[0]) + batchBuilders[0].(*history.MockAccountSignersBatchInsertBuilder).On("Add", history.AccountSigner{ Account: "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7", Signer: "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7", Weight: 1, Sponsor: null.String{}, }).Return(nil).Once() - mockAccountSignersBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - q.MockQSigners.On("NewAccountSignersBatchInsertBuilder"). - Return(mockAccountSignersBatchInsertBuilder).Twice() - - mockClaimableBalanceBatchInsertBuilder := &history.MockClaimableBalanceBatchInsertBuilder{} - mockClaimableBalanceBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - q.MockQClaimableBalances.On("NewClaimableBalanceBatchInsertBuilder"). - Return(mockClaimableBalanceBatchInsertBuilder).Twice() - - mockClaimantsBatchInsertBuilder := &history.MockClaimableBalanceClaimantBatchInsertBuilder{} - mockClaimantsBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - q.MockQClaimableBalances.On("NewClaimableBalanceClaimantBatchInsertBuilder"). - Return(mockClaimantsBatchInsertBuilder).Twice() - - mockLiquidityPoolBatchInsertBuilder := &history.MockLiquidityPoolBatchInsertBuilder{} - mockLiquidityPoolBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - q.MockQLiquidityPools.On("NewLiquidityPoolBatchInsertBuilder"). - Return(mockLiquidityPoolBatchInsertBuilder).Twice() - - mockOffersBatchInsertBuilder := &history.MockOffersBatchInsertBuilder{} - mockOffersBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - q.MockQOffers.On("NewOffersBatchInsertBuilder").Return(mockOffersBatchInsertBuilder).Twice() q.MockQAssetStats.On("InsertAssetStats", ctx, []history.ExpAssetStat{}, 100000). Return(nil) @@ -124,36 +104,15 @@ func TestProcessorRunnerRunHistoryArchiveIngestionHistoryArchive(t *testing.T) { }, }).Return(nil).Once() - mockAccountSignersBatchInsertBuilder := &history.MockAccountSignersBatchInsertBuilder{} - defer mock.AssertExpectationsForObjects(t, mockAccountSignersBatchInsertBuilder) - mockAccountSignersBatchInsertBuilder.On("Add", history.AccountSigner{ + batchBuilders := mockChangeProcessorBatchBuilders(q, ctx, true) + defer mock.AssertExpectationsForObjects(t, batchBuilders...) + + assert.IsType(t, &history.MockAccountSignersBatchInsertBuilder{}, batchBuilders[0]) + batchBuilders[0].(*history.MockAccountSignersBatchInsertBuilder).On("Add", history.AccountSigner{ Account: "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7", Signer: "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7", Weight: 1, }).Return(nil).Once() - mockAccountSignersBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - q.MockQSigners.On("NewAccountSignersBatchInsertBuilder"). - Return(mockAccountSignersBatchInsertBuilder).Twice() - - mockClaimableBalanceBatchInsertBuilder := &history.MockClaimableBalanceBatchInsertBuilder{} - mockClaimableBalanceBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - q.MockQClaimableBalances.On("NewClaimableBalanceBatchInsertBuilder"). - Return(mockClaimableBalanceBatchInsertBuilder).Twice() - - mockClaimantsBatchInsertBuilder := &history.MockClaimableBalanceClaimantBatchInsertBuilder{} - mockClaimantsBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - q.MockQClaimableBalances.On("NewClaimableBalanceClaimantBatchInsertBuilder"). - Return(mockClaimantsBatchInsertBuilder).Twice() - - mockLiquidityPoolBatchInsertBuilder := &history.MockLiquidityPoolBatchInsertBuilder{} - mockLiquidityPoolBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - q.MockQLiquidityPools.On("NewLiquidityPoolBatchInsertBuilder"). - Return(mockLiquidityPoolBatchInsertBuilder).Twice() - - mockOffersBatchInsertBuilder := &history.MockOffersBatchInsertBuilder{} - mockOffersBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - q.MockQOffers.On("NewOffersBatchInsertBuilder"). - Return(mockOffersBatchInsertBuilder).Twice() q.MockQAssetStats.On("InsertAssetStats", ctx, []history.ExpAssetStat{}, 100000). Return(nil) @@ -185,27 +144,7 @@ func TestProcessorRunnerRunHistoryArchiveIngestionProtocolVersionNotSupported(t defer mock.AssertExpectationsForObjects(t, historyAdapter) // Batches - - mockAccountSignersBatchInsertBuilder := &history.MockAccountSignersBatchInsertBuilder{} - defer mock.AssertExpectationsForObjects(t, mockAccountSignersBatchInsertBuilder) - q.MockQSigners.On("NewAccountSignersBatchInsertBuilder"). - Return(mockAccountSignersBatchInsertBuilder).Once() - - mockClaimableBalanceBatchInsertBuilder := &history.MockClaimableBalanceBatchInsertBuilder{} - q.MockQClaimableBalances.On("NewClaimableBalanceBatchInsertBuilder"). - Return(mockClaimableBalanceBatchInsertBuilder).Once() - - mockClaimantsBatchInsertBuilder := &history.MockClaimableBalanceClaimantBatchInsertBuilder{} - q.MockQClaimableBalances.On("NewClaimableBalanceClaimantBatchInsertBuilder"). - Return(mockClaimantsBatchInsertBuilder).Once() - - mockLiquidityPoolBatchInsertBuilder := &history.MockLiquidityPoolBatchInsertBuilder{} - q.MockQLiquidityPools.On("NewLiquidityPoolBatchInsertBuilder"). - Return(mockLiquidityPoolBatchInsertBuilder).Once() - - mockOffersBatchInsertBuilder := &history.MockOffersBatchInsertBuilder{} - q.MockQOffers.On("NewOffersBatchInsertBuilder"). - Return(mockOffersBatchInsertBuilder).Once() + defer mock.AssertExpectationsForObjects(t, mockChangeProcessorBatchBuilders(q, ctx, false)...) q.MockQAssetStats.On("InsertAssetStats", ctx, []history.ExpAssetStat{}, 100000). Return(nil) @@ -234,25 +173,7 @@ func TestProcessorRunnerBuildChangeProcessor(t *testing.T) { q := &mockDBQ{} defer mock.AssertExpectationsForObjects(t, q) - // Twice = checking ledgerSource and historyArchiveSource - q.MockQSigners.On("NewAccountSignersBatchInsertBuilder"). - Return(&history.MockAccountSignersBatchInsertBuilder{}).Twice() - - mockClaimableBalanceBatchInsertBuilder := &history.MockClaimableBalanceBatchInsertBuilder{} - q.MockQClaimableBalances.On("NewClaimableBalanceBatchInsertBuilder"). - Return(mockClaimableBalanceBatchInsertBuilder).Twice() - - mockClaimantsBatchInsertBuilder := &history.MockClaimableBalanceClaimantBatchInsertBuilder{} - q.MockQClaimableBalances.On("NewClaimableBalanceClaimantBatchInsertBuilder"). - Return(mockClaimantsBatchInsertBuilder).Twice() - - mockLiquidityPoolBatchInsertBuilder := &history.MockLiquidityPoolBatchInsertBuilder{} - q.MockQLiquidityPools.On("NewLiquidityPoolBatchInsertBuilder"). - Return(mockLiquidityPoolBatchInsertBuilder).Twice() - - mockOfferBatchInsertBuilder := &history.MockOffersBatchInsertBuilder{} - q.MockQOffers.On("NewOffersBatchInsertBuilder"). - Return(mockOfferBatchInsertBuilder).Twice() + defer mock.AssertExpectationsForObjects(t, mockChangeProcessorBatchBuilders(q, ctx, false)...) runner := ProcessorRunner{ ctx: ctx, @@ -351,7 +272,6 @@ func TestProcessorRunnerBuildTransactionProcessor(t *testing.T) { func TestProcessorRunnerWithFilterEnabled(t *testing.T) { ctx := context.Background() - maxBatchSize := 100000 config := Config{ NetworkPassphrase: network.PublicNetworkPassphrase, @@ -382,7 +302,7 @@ func TestProcessorRunnerWithFilterEnabled(t *testing.T) { q.On("DeleteTransactionsFilteredTmpOlderThan", ctx, mock.AnythingOfType("uint64")). Return(int64(0), nil) - defer mock.AssertExpectationsForObjects(t, mockBatchBuilders(q, mockSession, ctx, maxBatchSize)...) + defer mock.AssertExpectationsForObjects(t, mockBatchBuilders(q, mockSession, ctx)...) mockBatchInsertBuilder := &history.MockLedgersBatchInsertBuilder{} q.MockQLedgers.On("NewLedgerBatchInsertBuilder").Return(mockBatchInsertBuilder) @@ -409,7 +329,6 @@ func TestProcessorRunnerWithFilterEnabled(t *testing.T) { func TestProcessorRunnerRunAllProcessorsOnLedger(t *testing.T) { ctx := context.Background() - maxBatchSize := 100000 config := Config{ NetworkPassphrase: network.PublicNetworkPassphrase, @@ -430,7 +349,7 @@ func TestProcessorRunnerRunAllProcessorsOnLedger(t *testing.T) { } // Batches - defer mock.AssertExpectationsForObjects(t, mockBatchBuilders(q, mockSession, ctx, maxBatchSize)...) + defer mock.AssertExpectationsForObjects(t, mockBatchBuilders(q, mockSession, ctx)...) mockBatchInsertBuilder := &history.MockLedgersBatchInsertBuilder{} q.MockQLedgers.On("NewLedgerBatchInsertBuilder").Return(mockBatchInsertBuilder) @@ -509,17 +428,12 @@ func TestProcessorRunnerRunAllProcessorsOnLedgerProtocolVersionNotSupported(t *t ) } -func mockBatchBuilders(q *mockDBQ, mockSession *db.MockSession, ctx context.Context, maxBatchSize int) []interface{} { +func mockBatchBuilders(q *mockDBQ, mockSession *db.MockSession, ctx context.Context) []interface{} { mockTransactionsBatchInsertBuilder := &history.MockTransactionsBatchInsertBuilder{} mockTransactionsBatchInsertBuilder.On("Exec", ctx, mockSession).Return(nil).Once() q.MockQTransactions.On("NewTransactionBatchInsertBuilder"). Return(mockTransactionsBatchInsertBuilder) - mockAccountSignersBatchInsertBuilder := &history.MockAccountSignersBatchInsertBuilder{} - mockAccountSignersBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() - q.MockQSigners.On("NewAccountSignersBatchInsertBuilder"). - Return(mockAccountSignersBatchInsertBuilder).Twice() - mockOperationsBatchInsertBuilder := &history.MockOperationsBatchInsertBuilder{} mockOperationsBatchInsertBuilder.On("Exec", ctx, mockSession).Return(nil).Once() q.MockQOperations.On("NewOperationBatchInsertBuilder"). @@ -560,29 +474,59 @@ func mockBatchBuilders(q *mockDBQ, mockSession *db.MockSession, ctx context.Cont q.MockQHistoryLiquidityPools.On("NewOperationLiquidityPoolBatchInsertBuilder"). Return(mockOperationLiquidityPoolBatchInsertBuilder) + q.On("NewTradeBatchInsertBuilder").Return(&history.MockTradeBatchInsertBuilder{}) + + return append([]interface{}{ + mockOperationsBatchInsertBuilder, + mockTransactionsBatchInsertBuilder, + mockTransactionClaimableBalanceBatchInsertBuilder, + mockOperationClaimableBalanceBatchInsertBuilder, + mockTransactionLiquidityPoolBatchInsertBuilder, + mockOperationLiquidityPoolBatchInsertBuilder, + }, mockChangeProcessorBatchBuilders(q, ctx, true)[:]...) +} + +func mockChangeProcessorBatchBuilders(q *mockDBQ, ctx context.Context, mockExec bool) []interface{} { + mockAccountSignersBatchInsertBuilder := &history.MockAccountSignersBatchInsertBuilder{} + if mockExec { + mockAccountSignersBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() + } + q.MockQSigners.On("NewAccountSignersBatchInsertBuilder"). + Return(mockAccountSignersBatchInsertBuilder).Twice() + mockClaimableBalanceClaimantBatchInsertBuilder := &history.MockClaimableBalanceClaimantBatchInsertBuilder{} - mockClaimableBalanceClaimantBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() + if mockExec { + mockClaimableBalanceClaimantBatchInsertBuilder.On("Exec", ctx). + Return(nil).Once() + } q.MockQClaimableBalances.On("NewClaimableBalanceClaimantBatchInsertBuilder"). Return(mockClaimableBalanceClaimantBatchInsertBuilder).Twice() mockClaimableBalanceBatchInsertBuilder := &history.MockClaimableBalanceBatchInsertBuilder{} - mockClaimableBalanceBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() + if mockExec { + mockClaimableBalanceBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() + } q.MockQClaimableBalances.On("NewClaimableBalanceBatchInsertBuilder"). Return(mockClaimableBalanceBatchInsertBuilder).Twice() mockLiquidityPoolBatchInsertBuilder := &history.MockLiquidityPoolBatchInsertBuilder{} - mockLiquidityPoolBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() + if mockExec { + mockLiquidityPoolBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() + } q.MockQLiquidityPools.On("NewLiquidityPoolBatchInsertBuilder"). Return(mockLiquidityPoolBatchInsertBuilder).Twice() mockOfferBatchInsertBuilder := &history.MockOffersBatchInsertBuilder{} - mockOfferBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() + if mockExec { + mockOfferBatchInsertBuilder.On("Exec", ctx).Return(nil).Once() + } q.MockQOffers.On("NewOffersBatchInsertBuilder"). Return(mockOfferBatchInsertBuilder).Twice() - q.On("NewTradeBatchInsertBuilder").Return(&history.MockTradeBatchInsertBuilder{}) - return []interface{}{mockAccountSignersBatchInsertBuilder, - mockOperationsBatchInsertBuilder, - mockTransactionsBatchInsertBuilder} + mockClaimableBalanceBatchInsertBuilder, + mockClaimableBalanceClaimantBatchInsertBuilder, + mockLiquidityPoolBatchInsertBuilder, + mockOfferBatchInsertBuilder, + } }