@@ -88,14 +88,14 @@ var (
88
88
func TestIndexer_ProcessTransaction (t * testing.T ) {
89
89
tests := []struct {
90
90
name string
91
- setupMocks func (* MockParticipantsProcessor , * MockTokenTransferProcessor , * MockEffectsProcessor , * MockIndexerBuffer )
91
+ setupMocks func (* MockParticipantsProcessor , * MockTokenTransferProcessor , * MockOperationProcessor , * MockOperationProcessor , * MockIndexerBuffer )
92
92
wantError string
93
93
txParticipants set.Set [string ]
94
94
opsParticipants map [int64 ]processors.OperationParticipants
95
95
}{
96
96
{
97
97
name : "🟢 successful processing with participants" ,
98
- setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockEffectsProcessor , mockBuffer * MockIndexerBuffer ) {
98
+ setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockOperationProcessor , mockContractDeploy * MockOperationProcessor , mockBuffer * MockIndexerBuffer ) {
99
99
participants := set .NewSet ("alice" , "bob" )
100
100
mockParticipants .On ("GetTransactionParticipants" , mock .Anything ).Return (participants , nil )
101
101
@@ -116,7 +116,10 @@ func TestIndexer_ProcessTransaction(t *testing.T) {
116
116
mockTokenTransfer .On ("ProcessTransaction" , mock .Anything , mock .Anything ).Return (tokenStateChanges , nil )
117
117
118
118
effectsStateChanges := []types.StateChange {{ID : "effects_sc1" }}
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 )
120
+
121
+ contractDeployStateChanges := []types.StateChange {{ID : "contract_deploy_sc1" }}
122
+ mockContractDeploy .On ("ProcessOperation" , mock .Anything , mock .Anything ).Return (contractDeployStateChanges , nil )
120
123
121
124
// Verify transaction was pushed to buffer with correct participants
122
125
// PushParticipantTransaction is called once for each participant
@@ -149,6 +152,10 @@ func TestIndexer_ProcessTransaction(t *testing.T) {
149
152
mock .MatchedBy (func (stateChanges []types.StateChange ) bool {
150
153
return len (stateChanges ) == 1 && stateChanges [0 ].ID == "token_sc1"
151
154
})).Return ()
155
+ mockBuffer .On ("PushStateChanges" ,
156
+ mock .MatchedBy (func (stateChanges []types.StateChange ) bool {
157
+ return len (stateChanges ) == 1 && stateChanges [0 ].ID == "contract_deploy_sc1"
158
+ })).Return ()
152
159
},
153
160
txParticipants : set .NewSet ("alice" , "bob" ),
154
161
opsParticipants : map [int64 ]processors.OperationParticipants {
@@ -165,7 +172,7 @@ func TestIndexer_ProcessTransaction(t *testing.T) {
165
172
},
166
173
{
167
174
name : "🟢 successful processing without participants" ,
168
- setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockEffectsProcessor , mockBuffer * MockIndexerBuffer ) {
175
+ setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockOperationProcessor , mockContractDeploy * MockOperationProcessor , mockBuffer * MockIndexerBuffer ) {
169
176
participants := set .NewSet [string ]()
170
177
mockParticipants .On ("GetTransactionParticipants" , mock .Anything ).Return (participants , nil )
171
178
@@ -187,14 +194,14 @@ func TestIndexer_ProcessTransaction(t *testing.T) {
187
194
},
188
195
{
189
196
name : "🔴 error getting transaction participants" ,
190
- setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockEffectsProcessor , mockBuffer * MockIndexerBuffer ) {
197
+ setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockOperationProcessor , mockContractDeploy * MockOperationProcessor , mockBuffer * MockIndexerBuffer ) {
191
198
mockParticipants .On ("GetTransactionParticipants" , mock .Anything ).Return (set .NewSet [string ](), errors .New ("participant error" ))
192
199
},
193
200
wantError : "getting transaction participants: participant error" ,
194
201
},
195
202
{
196
203
name : "🔴 error getting operations participants" ,
197
- setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockEffectsProcessor , mockBuffer * MockIndexerBuffer ) {
204
+ setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockOperationProcessor , mockContractDeploy * MockOperationProcessor , mockBuffer * MockIndexerBuffer ) {
198
205
participants := set .NewSet [string ]()
199
206
mockParticipants .On ("GetTransactionParticipants" , mock .Anything ).Return (participants , nil )
200
207
mockParticipants .On ("GetOperationsParticipants" , mock .Anything ).Return (map [int64 ]processors.OperationParticipants {}, errors .New ("operations error" ))
@@ -203,7 +210,7 @@ func TestIndexer_ProcessTransaction(t *testing.T) {
203
210
},
204
211
{
205
212
name : "🔴 error processing effects state changes" ,
206
- setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockEffectsProcessor , mockBuffer * MockIndexerBuffer ) {
213
+ setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockOperationProcessor , mockContractDeploy * MockOperationProcessor , mockBuffer * MockIndexerBuffer ) {
207
214
participants := set .NewSet [string ]()
208
215
mockParticipants .On ("GetTransactionParticipants" , mock .Anything ).Return (participants , nil )
209
216
@@ -221,13 +228,13 @@ func TestIndexer_ProcessTransaction(t *testing.T) {
221
228
mockParticipants .On ("GetOperationsParticipants" , mock .Anything ).Return (opParticipants , nil )
222
229
223
230
mockBuffer .On ("PushParticipantOperation" , mock .Anything , mock .Anything , mock .Anything ).Return ()
224
- mockEffects .On ("ProcessOperation" , mock .Anything , mock .Anything , mock . Anything , mock . Anything ).Return ([]types.StateChange {}, errors .New ("effects error" ))
231
+ mockEffects .On ("ProcessOperation" , mock .Anything , mock .Anything ).Return ([]types.StateChange {}, errors .New ("effects error" ))
225
232
},
226
233
wantError : "processing effects state changes: effects error" ,
227
234
},
228
235
{
229
236
name : "🔴 error processing token transfer state changes" ,
230
- setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockEffectsProcessor , mockBuffer * MockIndexerBuffer ) {
237
+ setupMocks : func (mockParticipants * MockParticipantsProcessor , mockTokenTransfer * MockTokenTransferProcessor , mockEffects * MockOperationProcessor , mockContractDeploy * MockOperationProcessor , mockBuffer * MockIndexerBuffer ) {
231
238
participants := set .NewSet [string ]()
232
239
mockParticipants .On ("GetTransactionParticipants" , mock .Anything ).Return (participants , nil )
233
240
@@ -245,18 +252,20 @@ func TestIndexer_ProcessTransaction(t *testing.T) {
245
252
// Create mocks
246
253
mockParticipants := & MockParticipantsProcessor {}
247
254
mockTokenTransfer := & MockTokenTransferProcessor {}
248
- mockEffects := & MockEffectsProcessor {}
255
+ mockEffects := & MockOperationProcessor {}
256
+ mockContractDeploy := & MockOperationProcessor {}
249
257
mockBuffer := & MockIndexerBuffer {}
250
258
251
259
// Setup mock expectations
252
- tt .setupMocks (mockParticipants , mockTokenTransfer , mockEffects , mockBuffer )
260
+ tt .setupMocks (mockParticipants , mockTokenTransfer , mockEffects , mockContractDeploy , mockBuffer )
253
261
254
262
// Create testable indexer with mocked dependencies
255
263
indexer := & Indexer {
256
- Buffer : mockBuffer ,
257
- participantsProcessor : mockParticipants ,
258
- tokenTransferProcessor : mockTokenTransfer ,
259
- effectsProcessor : mockEffects ,
264
+ Buffer : mockBuffer ,
265
+ participantsProcessor : mockParticipants ,
266
+ tokenTransferProcessor : mockTokenTransfer ,
267
+ effectsProcessor : mockEffects ,
268
+ contractDeployProcessor : mockContractDeploy ,
260
269
}
261
270
262
271
err := indexer .ProcessTransaction (context .Background (), testTx )
0 commit comments