@@ -88,14 +88,14 @@ var (
8888func TestIndexer_ProcessTransaction (t * testing.T ) {
8989 tests := []struct {
9090 name string
91- setupMocks func (* MockParticipantsProcessor , * MockTokenTransferProcessor , * MockOperationProcessor , * MockOperationProcessor , * MockIndexerBuffer )
91+ setupMocks func (* MockParticipantsProcessor , * MockTokenTransferProcessor , * MockOperationProcessor , * MockOperationProcessor , * MockOperationProcessor , * MockIndexerBuffer )
9292 wantError string
9393 txParticipants set.Set [string ]
9494 opsParticipants map [int64 ]processors.OperationParticipants
9595 }{
9696 {
9797 name : "🟢 successful processing with participants" ,
98- setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockOperationProcessor , mockContractDeploy * MockOperationProcessor , mockBuffer * MockIndexerBuffer ) {
98+ setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockOperationProcessor , mockContractDeploy * MockOperationProcessor , mockSACEventsProcessor * MockOperationProcessor , mockBuffer * MockIndexerBuffer ) {
9999 participants := set .NewSet ("alice" , "bob" )
100100 mockParticipants .On ("GetTransactionParticipants" , mock .Anything ).Return (participants , nil )
101101
@@ -116,11 +116,14 @@ func TestIndexer_ProcessTransaction(t *testing.T) {
116116 mockTokenTransfer .On ("ProcessTransaction" , mock .Anything , mock .Anything ).Return (tokenStateChanges , nil )
117117
118118 effectsStateChanges := []types.StateChange {{ToID : 2 , StateChangeOrder : 1 }}
119- mockEffects .On ("ProcessOperation" , mock .Anything , mock .Anything , mock . Anything , mock . Anything ).Return (effectsStateChanges , nil )
119+ mockEffects .On ("ProcessOperation" , mock .Anything , mock .Anything ).Return (effectsStateChanges , nil )
120120
121121 contractDeployStateChanges := []types.StateChange {{ToID : 3 , StateChangeOrder : 1 }}
122122 mockContractDeploy .On ("ProcessOperation" , mock .Anything , mock .Anything ).Return (contractDeployStateChanges , nil )
123123
124+ contractSACEventsStateChanges := []types.StateChange {{ToID : 4 , StateChangeOrder : 1 }}
125+ mockSACEventsProcessor .On ("ProcessOperation" , mock .Anything , mock .Anything ).Return (contractSACEventsStateChanges , nil )
126+
124127 // Verify transaction was pushed to buffer with correct participants
125128 // PushParticipantTransaction is called once for each participant
126129 mockBuffer .On ("PushParticipantTransaction" , "alice" ,
@@ -157,6 +160,10 @@ func TestIndexer_ProcessTransaction(t *testing.T) {
157160 mock .MatchedBy (func (stateChanges []types.StateChange ) bool {
158161 return len (stateChanges ) == 1 && stateChanges [0 ].ToID == 3 && stateChanges [0 ].StateChangeOrder == 1
159162 })).Return ()
163+ mockBuffer .On ("PushStateChanges" ,
164+ mock .MatchedBy (func (stateChanges []types.StateChange ) bool {
165+ return len (stateChanges ) == 1 && stateChanges [0 ].ToID == 4 && stateChanges [0 ].StateChangeOrder == 1
166+ })).Return ()
160167 },
161168 txParticipants : set .NewSet ("alice" , "bob" ),
162169 opsParticipants : map [int64 ]processors.OperationParticipants {
@@ -173,7 +180,7 @@ func TestIndexer_ProcessTransaction(t *testing.T) {
173180 },
174181 {
175182 name : "🟢 successful processing without participants" ,
176- setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockOperationProcessor , mockContractDeploy * MockOperationProcessor , mockBuffer * MockIndexerBuffer ) {
183+ setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockOperationProcessor , mockContractDeploy * MockOperationProcessor , mockSACEventsProcessor * MockOperationProcessor , mockBuffer * MockIndexerBuffer ) {
177184 participants := set .NewSet [string ]()
178185 mockParticipants .On ("GetTransactionParticipants" , mock .Anything ).Return (participants , nil )
179186
@@ -196,14 +203,14 @@ func TestIndexer_ProcessTransaction(t *testing.T) {
196203 },
197204 {
198205 name : "🔴 error getting transaction participants" ,
199- setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockOperationProcessor , mockContractDeploy * MockOperationProcessor , mockBuffer * MockIndexerBuffer ) {
206+ setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockOperationProcessor , mockContractDeploy * MockOperationProcessor , mockSACEventsProcessor * MockOperationProcessor , mockBuffer * MockIndexerBuffer ) {
200207 mockParticipants .On ("GetTransactionParticipants" , mock .Anything ).Return (set .NewSet [string ](), errors .New ("participant error" ))
201208 },
202209 wantError : "getting transaction participants: participant error" ,
203210 },
204211 {
205212 name : "🔴 error getting operations participants" ,
206- setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockOperationProcessor , mockContractDeploy * MockOperationProcessor , mockBuffer * MockIndexerBuffer ) {
213+ setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockOperationProcessor , mockContractDeploy * MockOperationProcessor , mockSACEventsProcessor * MockOperationProcessor , mockBuffer * MockIndexerBuffer ) {
207214 participants := set .NewSet [string ]()
208215 mockParticipants .On ("GetTransactionParticipants" , mock .Anything ).Return (participants , nil )
209216 mockParticipants .On ("GetOperationsParticipants" , mock .Anything ).Return (map [int64 ]processors.OperationParticipants {}, errors .New ("operations error" ))
@@ -212,7 +219,7 @@ func TestIndexer_ProcessTransaction(t *testing.T) {
212219 },
213220 {
214221 name : "🔴 error processing effects state changes" ,
215- setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockOperationProcessor , mockContractDeploy * MockOperationProcessor , mockBuffer * MockIndexerBuffer ) {
222+ setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockOperationProcessor , mockContractDeploy * MockOperationProcessor , mockSACEventsProcessor * MockOperationProcessor , mockBuffer * MockIndexerBuffer ) {
216223 participants := set .NewSet [string ]()
217224 mockParticipants .On ("GetTransactionParticipants" , mock .Anything ).Return (participants , nil )
218225
@@ -231,12 +238,13 @@ func TestIndexer_ProcessTransaction(t *testing.T) {
231238
232239 mockBuffer .On ("PushParticipantOperation" , mock .Anything , mock .Anything , mock .Anything ).Return ()
233240 mockEffects .On ("ProcessOperation" , mock .Anything , mock .Anything ).Return ([]types.StateChange {}, errors .New ("effects error" ))
241+ mockEffects .On ("Name" ).Return ("effects" )
234242 },
235243 wantError : "processing effects state changes: effects error" ,
236244 },
237245 {
238246 name : "🔴 error processing token transfer state changes" ,
239- setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockOperationProcessor , mockContractDeploy * MockOperationProcessor , mockBuffer * MockIndexerBuffer ) {
247+ setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockOperationProcessor , mockContractDeploy * MockOperationProcessor , mockSACEventsProcessor * MockOperationProcessor , mockBuffer * MockIndexerBuffer ) {
240248 participants := set .NewSet [string ]()
241249 mockParticipants .On ("GetTransactionParticipants" , mock .Anything ).Return (participants , nil )
242250
@@ -256,18 +264,18 @@ func TestIndexer_ProcessTransaction(t *testing.T) {
256264 mockTokenTransfer := & MockTokenTransferProcessor {}
257265 mockEffects := & MockOperationProcessor {}
258266 mockContractDeploy := & MockOperationProcessor {}
267+ mockSACEventsProcessor := & MockOperationProcessor {}
259268 mockBuffer := & MockIndexerBuffer {}
260269
261270 // Setup mock expectations
262- tt .setupMocks (mockParticipants , mockTokenTransfer , mockEffects , mockContractDeploy , mockBuffer )
271+ tt .setupMocks (mockParticipants , mockTokenTransfer , mockEffects , mockContractDeploy , mockSACEventsProcessor , mockBuffer )
263272
264273 // Create testable indexer with mocked dependencies
265274 indexer := & Indexer {
266- Buffer : mockBuffer ,
267- participantsProcessor : mockParticipants ,
268- tokenTransferProcessor : mockTokenTransfer ,
269- effectsProcessor : mockEffects ,
270- contractDeployProcessor : mockContractDeploy ,
275+ Buffer : mockBuffer ,
276+ participantsProcessor : mockParticipants ,
277+ tokenTransferProcessor : mockTokenTransfer ,
278+ processors : []OperationProcessorInterface {mockEffects , mockContractDeploy , mockSACEventsProcessor },
271279 }
272280
273281 err := indexer .ProcessTransaction (context .Background (), testTx )
@@ -305,6 +313,8 @@ func TestIndexer_ProcessTransaction(t *testing.T) {
305313 mockParticipants .AssertExpectations (t )
306314 mockTokenTransfer .AssertExpectations (t )
307315 mockEffects .AssertExpectations (t )
316+ mockContractDeploy .AssertExpectations (t )
317+ mockSACEventsProcessor .AssertExpectations (t )
308318 mockBuffer .AssertExpectations (t )
309319 })
310320 }
0 commit comments