@@ -111,93 +111,94 @@ describe('LogJobService', () => {
111111 it ( 'should filter same length sender & receiver' , async ( ) => {
112112 if ( new Date ( ) . getHours ( ) > 19 ) return ;
113113
114+ // Items 0-6 are > 21 days old (will be filtered out), items 7-9 are < 21 days (will remain)
114115 const receiverTx = [
115- createCustomExchangeTx ( { id : 63189 , created : Util . hoursBefore ( 409 ) , amount : 9500.0 } ) ,
116- createCustomExchangeTx ( { id : 63190 , created : Util . hoursBefore ( 409 ) , amount : 9500.0 } ) ,
117- createCustomExchangeTx ( { id : 63191 , created : Util . hoursBefore ( 409 ) , amount : 9500.0 } ) ,
118- createCustomExchangeTx ( { id : 63232 , created : Util . hoursBefore ( 407 ) , amount : 9500.0 } ) ,
119- createCustomExchangeTx ( { id : 63277 , created : Util . hoursBefore ( 310 ) , amount : 9500.0 } ) ,
120- createCustomExchangeTx ( { id : 63278 , created : Util . hoursBefore ( 310 ) , amount : 9500.0 } ) ,
121- createCustomExchangeTx ( { id : 63279 , created : Util . hoursBefore ( 310 ) , amount : 9500.0 } ) ,
122- createCustomExchangeTx ( { id : 63280 , created : Util . hoursBefore ( 310 ) , amount : 9500.0 } ) ,
123- createCustomExchangeTx ( { id : 63281 , created : Util . hoursBefore ( 310 ) , amount : 9500.0 } ) ,
124- createCustomExchangeTx ( { id : 63282 , created : Util . hoursBefore ( 310 ) , amount : 9500.0 } ) ,
116+ createCustomExchangeTx ( { id : 63189 , created : Util . hoursBefore ( 529 ) , amount : 9500.0 } ) , // 22d
117+ createCustomExchangeTx ( { id : 63190 , created : Util . hoursBefore ( 529 ) , amount : 9500.0 } ) , // 22d
118+ createCustomExchangeTx ( { id : 63191 , created : Util . hoursBefore ( 529 ) , amount : 9500.0 } ) , // 22d
119+ createCustomExchangeTx ( { id : 63232 , created : Util . hoursBefore ( 527 ) , amount : 9500.0 } ) , // 22d
120+ createCustomExchangeTx ( { id : 63277 , created : Util . hoursBefore ( 520 ) , amount : 9500.0 } ) , // 21.6d
121+ createCustomExchangeTx ( { id : 63278 , created : Util . hoursBefore ( 520 ) , amount : 9500.0 } ) , // 21.6d
122+ createCustomExchangeTx ( { id : 63279 , created : Util . hoursBefore ( 520 ) , amount : 9500.0 } ) , // 21.6d
123+ createCustomExchangeTx ( { id : 63280 , created : Util . hoursBefore ( 310 ) , amount : 9500.0 } ) , // 13d
124+ createCustomExchangeTx ( { id : 63281 , created : Util . hoursBefore ( 310 ) , amount : 9500.0 } ) , // 13d
125+ createCustomExchangeTx ( { id : 63282 , created : Util . hoursBefore ( 310 ) , amount : 9500.0 } ) , // 13d
125126 ] ;
126127
127128 const senderTx = [
128129 createCustomBankTx ( {
129130 id : 142006 ,
130- created : Util . hoursBefore ( 432 ) ,
131- valueDate : Util . hoursBefore ( 406 ) ,
131+ created : Util . hoursBefore ( 552 ) , // 23d
132+ valueDate : Util . hoursBefore ( 526 ) ,
132133 instructedAmount : 9500.0 ,
133134 amount : 9500.0 ,
134135 } ) ,
135136 createCustomBankTx ( {
136137 id : 142007 ,
137- created : Util . hoursBefore ( 432 ) ,
138- valueDate : Util . hoursBefore ( 406 ) ,
138+ created : Util . hoursBefore ( 552 ) , // 23d
139+ valueDate : Util . hoursBefore ( 526 ) ,
139140 instructedAmount : 9500.0 ,
140141 amount : 9500.0 ,
141142 } ) ,
142143 createCustomBankTx ( {
143144 id : 142008 ,
144- created : Util . hoursBefore ( 432 ) ,
145- valueDate : Util . hoursBefore ( 406 ) ,
145+ created : Util . hoursBefore ( 552 ) , // 23d
146+ valueDate : Util . hoursBefore ( 526 ) ,
146147 instructedAmount : 9500.0 ,
147148 amount : 9500.0 ,
148149 } ) ,
149150 createCustomBankTx ( {
150151 id : 142153 ,
151- created : Util . hoursBefore ( 408 ) ,
152- valueDate : Util . hoursBefore ( 406 ) ,
152+ created : Util . hoursBefore ( 528 ) , // 22d
153+ valueDate : Util . hoursBefore ( 526 ) ,
153154 instructedAmount : 9500.0 ,
154155 amount : 9500.0 ,
155156 } ) ,
156157 createCustomBankTx ( {
157158 id : 142199 ,
158- created : Util . hoursBefore ( 384 ) ,
159- valueDate : Util . hoursBefore ( 384 ) ,
159+ created : Util . hoursBefore ( 520 ) , // 21.6d
160+ valueDate : Util . hoursBefore ( 520 ) ,
160161 instructedAmount : 9500.0 ,
161162 amount : 9500.0 ,
162163 } ) ,
163164 createCustomBankTx ( {
164165 id : 142218 ,
165- created : Util . hoursBefore ( 384 ) ,
166- valueDate : Util . hoursBefore ( 384 ) ,
166+ created : Util . hoursBefore ( 520 ) , // 21.6d
167+ valueDate : Util . hoursBefore ( 520 ) ,
167168 instructedAmount : 9500.0 ,
168169 amount : 9500.0 ,
169170 } ) ,
170171 createCustomBankTx ( {
171172 id : 142265 ,
172- created : Util . hoursBefore ( 384 ) ,
173- valueDate : Util . hoursBefore ( 384 ) ,
173+ created : Util . hoursBefore ( 520 ) , // 21.6d
174+ valueDate : Util . hoursBefore ( 520 ) ,
174175 instructedAmount : 9500.0 ,
175176 amount : 9500.0 ,
176177 } ) ,
177178 createCustomBankTx ( {
178179 id : 142396 ,
179- created : Util . hoursBefore ( 312 ) ,
180+ created : Util . hoursBefore ( 312 ) , // 13d
180181 valueDate : Util . hoursBefore ( 312 ) ,
181182 instructedAmount : 9500.0 ,
182183 amount : 9500.0 ,
183184 } ) ,
184185 createCustomBankTx ( {
185186 id : 142407 ,
186- created : Util . hoursBefore ( 312 ) ,
187+ created : Util . hoursBefore ( 312 ) , // 13d
187188 valueDate : Util . hoursBefore ( 312 ) ,
188189 instructedAmount : 9500.0 ,
189190 amount : 9500.0 ,
190191 } ) ,
191192 createCustomBankTx ( {
192193 id : 142408 ,
193- created : Util . hoursBefore ( 312 ) ,
194+ created : Util . hoursBefore ( 312 ) , // 13d
194195 valueDate : Util . hoursBefore ( 312 ) ,
195196 instructedAmount : 9500.0 ,
196197 amount : 9500.0 ,
197198 } ) ,
198199 createCustomBankTx ( {
199200 id : 142409 ,
200- created : Util . hoursBefore ( 309 ) ,
201+ created : Util . hoursBefore ( 309 ) , // 13d
201202 valueDate : Util . hoursBefore ( 309 ) ,
202203 instructedAmount : 9500.0 ,
203204 amount : 9500.0 ,
@@ -270,25 +271,25 @@ describe('LogJobService', () => {
270271 } ) ;
271272 } ) ;
272273
273- it ( 'should filter tx 14d or older' , async ( ) => {
274+ it ( 'should filter tx 21d or older' , async ( ) => {
274275 const senderTx = [
275- createCustomExchangeTx ( { id : 1 , created : Util . daysBefore ( 17 ) , amount : 9999.0 } ) ,
276- createCustomExchangeTx ( { id : 2 , created : Util . daysBefore ( 12 ) , amount : 9999.0 } ) ,
276+ createCustomExchangeTx ( { id : 1 , created : Util . daysBefore ( 22 ) , amount : 9999.0 } ) ,
277+ createCustomExchangeTx ( { id : 2 , created : Util . daysBefore ( 17 ) , amount : 9999.0 } ) ,
277278 createCustomExchangeTx ( { id : 3 , created : Util . daysBefore ( 7 ) , amount : 9999.0 } ) ,
278279 ] ;
279280
280281 const receiverTx = [
281282 createCustomBankTx ( {
282283 id : 1 ,
283- created : Util . daysBefore ( 16 ) ,
284- valueDate : Util . daysBefore ( 16 ) ,
284+ created : Util . daysBefore ( 21 ) ,
285+ valueDate : Util . daysBefore ( 21 ) ,
285286 instructedAmount : 9999.0 ,
286287 amount : 9999.0 ,
287288 } ) ,
288289 createCustomBankTx ( {
289290 id : 2 ,
290- created : Util . daysBefore ( 11 ) ,
291- valueDate : Util . daysBefore ( 11 ) ,
291+ created : Util . daysBefore ( 16 ) ,
292+ valueDate : Util . daysBefore ( 16 ) ,
292293 instructedAmount : 9999.0 ,
293294 amount : 9999.0 ,
294295 } ) ,
@@ -337,118 +338,122 @@ describe('LogJobService', () => {
337338 } ) ;
338339
339340 it ( 'should filter receiver 21d or older' , async ( ) => {
341+ // All senders created after receiver, so matching finds sender with highest id
340342 const senderTx = [
341- createCustomExchangeTx ( { id : 3 , created : Util . daysBefore ( 19 ) , amount : 9999.0 } ) ,
342- createCustomExchangeTx ( { id : 2 , created : Util . daysBefore ( 18 ) , amount : 9999.0 } ) ,
343- createCustomExchangeTx ( { id : 1 , created : Util . daysBefore ( 17 ) , amount : 9999.0 } ) ,
343+ createCustomExchangeTx ( { id : 3 , created : Util . daysBefore ( 20 ) , amount : 9999.0 } ) ,
344+ createCustomExchangeTx ( { id : 2 , created : Util . daysBefore ( 19 ) , amount : 9999.0 } ) ,
345+ createCustomExchangeTx ( { id : 1 , created : Util . daysBefore ( 19 ) , amount : 9999.0 } ) ,
344346 ] ;
345347
346348 const receiverTx = [
347349 createCustomBankTx ( {
348350 id : 1 ,
349- created : Util . daysBefore ( 21 ) ,
351+ created : Util . daysBefore ( 21 ) , // This will be filtered out (>= 21d)
350352 valueDate : Util . daysBefore ( 21 ) ,
351353 instructedAmount : 9999.0 ,
352354 amount : 9999.0 ,
353355 } ) ,
354356 createCustomBankTx ( {
355357 id : 2 ,
356- created : Util . daysBefore ( 18 ) ,
358+ created : Util . daysBefore ( 18 ) , // This will remain (< 21d)
357359 valueDate : Util . daysBefore ( 18 ) ,
358360 instructedAmount : 9999.0 ,
359361 amount : 9999.0 ,
360362 } ) ,
361363 ] ;
362364
365+ // Matching finds sender id=3 (oldest sender that's still older than receiver at 18d)
366+ // Filter keeps only senders with id >= 3
363367 expect ( service . filterSenderPendingList ( senderTx , receiverTx ) ) . toMatchObject ( {
364- sender : senderTx ,
368+ sender : [ senderTx [ 0 ] ] , // Only id=3 remains after matching
365369 receiver : [ receiverTx [ 1 ] ] ,
366370 } ) ;
367371 } ) ;
368372
369- it ( 'should filter same length sender & receiver' , async ( ) => {
373+ it ( 'should filter same length sender & receiver (reverse) ' , async ( ) => {
370374 if ( new Date ( ) . getHours ( ) > 19 ) return ;
371375
376+ // Items 0-6 are > 21 days old (will be filtered out), items 7-9 are < 21 days (will remain)
372377 const receiverTx = [
373- createCustomExchangeTx ( { id : 63189 , created : Util . hoursBefore ( 409 ) , amount : 9500.0 } ) ,
374- createCustomExchangeTx ( { id : 63190 , created : Util . hoursBefore ( 409 ) , amount : 9500.0 } ) ,
375- createCustomExchangeTx ( { id : 63191 , created : Util . hoursBefore ( 409 ) , amount : 9500.0 } ) ,
376- createCustomExchangeTx ( { id : 63232 , created : Util . hoursBefore ( 407 ) , amount : 9500.0 } ) ,
377- createCustomExchangeTx ( { id : 63277 , created : Util . hoursBefore ( 310 ) , amount : 9500.0 } ) ,
378- createCustomExchangeTx ( { id : 63278 , created : Util . hoursBefore ( 310 ) , amount : 9500.0 } ) ,
379- createCustomExchangeTx ( { id : 63279 , created : Util . hoursBefore ( 310 ) , amount : 9500.0 } ) ,
380- createCustomExchangeTx ( { id : 63280 , created : Util . hoursBefore ( 310 ) , amount : 9500.0 } ) ,
381- createCustomExchangeTx ( { id : 63281 , created : Util . hoursBefore ( 310 ) , amount : 9500.0 } ) ,
382- createCustomExchangeTx ( { id : 63282 , created : Util . hoursBefore ( 310 ) , amount : 9500.0 } ) ,
378+ createCustomExchangeTx ( { id : 63189 , created : Util . hoursBefore ( 529 ) , amount : 9500.0 } ) , // 22d
379+ createCustomExchangeTx ( { id : 63190 , created : Util . hoursBefore ( 529 ) , amount : 9500.0 } ) , // 22d
380+ createCustomExchangeTx ( { id : 63191 , created : Util . hoursBefore ( 529 ) , amount : 9500.0 } ) , // 22d
381+ createCustomExchangeTx ( { id : 63232 , created : Util . hoursBefore ( 527 ) , amount : 9500.0 } ) , // 22d
382+ createCustomExchangeTx ( { id : 63277 , created : Util . hoursBefore ( 520 ) , amount : 9500.0 } ) , // 21.6d
383+ createCustomExchangeTx ( { id : 63278 , created : Util . hoursBefore ( 520 ) , amount : 9500.0 } ) , // 21.6d
384+ createCustomExchangeTx ( { id : 63279 , created : Util . hoursBefore ( 520 ) , amount : 9500.0 } ) , // 21.6d
385+ createCustomExchangeTx ( { id : 63280 , created : Util . hoursBefore ( 310 ) , amount : 9500.0 } ) , // 13d
386+ createCustomExchangeTx ( { id : 63281 , created : Util . hoursBefore ( 310 ) , amount : 9500.0 } ) , // 13d
387+ createCustomExchangeTx ( { id : 63282 , created : Util . hoursBefore ( 310 ) , amount : 9500.0 } ) , // 13d
383388 ] ;
384389
385390 const senderTx = [
386391 createCustomBankTx ( {
387392 id : 142006 ,
388- created : Util . hoursBefore ( 432 ) ,
389- valueDate : Util . hoursBefore ( 406 ) ,
393+ created : Util . hoursBefore ( 552 ) , // 23d
394+ valueDate : Util . hoursBefore ( 526 ) ,
390395 instructedAmount : 9500.0 ,
391396 amount : 9500.0 ,
392397 } ) ,
393398 createCustomBankTx ( {
394399 id : 142007 ,
395- created : Util . hoursBefore ( 432 ) ,
396- valueDate : Util . hoursBefore ( 406 ) ,
400+ created : Util . hoursBefore ( 552 ) , // 23d
401+ valueDate : Util . hoursBefore ( 526 ) ,
397402 instructedAmount : 9500.0 ,
398403 amount : 9500.0 ,
399404 } ) ,
400405 createCustomBankTx ( {
401406 id : 142008 ,
402- created : Util . hoursBefore ( 432 ) ,
403- valueDate : Util . hoursBefore ( 406 ) ,
407+ created : Util . hoursBefore ( 552 ) , // 23d
408+ valueDate : Util . hoursBefore ( 526 ) ,
404409 instructedAmount : 9500.0 ,
405410 amount : 9500.0 ,
406411 } ) ,
407412 createCustomBankTx ( {
408413 id : 142153 ,
409- created : Util . hoursBefore ( 408 ) ,
410- valueDate : Util . hoursBefore ( 406 ) ,
414+ created : Util . hoursBefore ( 528 ) , // 22d
415+ valueDate : Util . hoursBefore ( 526 ) ,
411416 instructedAmount : 9500.0 ,
412417 amount : 9500.0 ,
413418 } ) ,
414419 createCustomBankTx ( {
415420 id : 142199 ,
416- created : Util . hoursBefore ( 384 ) ,
417- valueDate : Util . hoursBefore ( 384 ) ,
421+ created : Util . hoursBefore ( 520 ) , // 21.6d
422+ valueDate : Util . hoursBefore ( 520 ) ,
418423 instructedAmount : 9500.0 ,
419424 amount : 9500.0 ,
420425 } ) ,
421426 createCustomBankTx ( {
422427 id : 142218 ,
423- created : Util . hoursBefore ( 384 ) ,
424- valueDate : Util . hoursBefore ( 384 ) ,
428+ created : Util . hoursBefore ( 520 ) , // 21.6d
429+ valueDate : Util . hoursBefore ( 520 ) ,
425430 instructedAmount : 9500.0 ,
426431 amount : 9500.0 ,
427432 } ) ,
428433 createCustomBankTx ( {
429434 id : 142265 ,
430- created : Util . hoursBefore ( 384 ) ,
431- valueDate : Util . hoursBefore ( 384 ) ,
435+ created : Util . hoursBefore ( 520 ) , // 21.6d
436+ valueDate : Util . hoursBefore ( 520 ) ,
432437 instructedAmount : 9500.0 ,
433438 amount : 9500.0 ,
434439 } ) ,
435440 createCustomBankTx ( {
436441 id : 142396 ,
437- created : Util . hoursBefore ( 312 ) ,
442+ created : Util . hoursBefore ( 312 ) , // 13d
438443 valueDate : Util . hoursBefore ( 312 ) ,
439444 instructedAmount : 9500.0 ,
440445 amount : 9500.0 ,
441446 } ) ,
442447 createCustomBankTx ( {
443448 id : 142407 ,
444- created : Util . hoursBefore ( 312 ) ,
449+ created : Util . hoursBefore ( 312 ) , // 13d
445450 valueDate : Util . hoursBefore ( 312 ) ,
446451 instructedAmount : 9500.0 ,
447452 amount : 9500.0 ,
448453 } ) ,
449454 createCustomBankTx ( {
450455 id : 142408 ,
451- created : Util . hoursBefore ( 312 ) ,
456+ created : Util . hoursBefore ( 312 ) , // 13d
452457 valueDate : Util . hoursBefore ( 312 ) ,
453458 instructedAmount : 9500.0 ,
454459 amount : 9500.0 ,
0 commit comments