@@ -87,6 +87,7 @@ class ActivityRepoTest : BaseUnitTest() {
8787 confirmTimestamp : ULong? = baseOnchainActivity.confirmTimestamp,
8888 channelId : String? = baseOnchainActivity.channelId,
8989 transferTxId : String? = baseOnchainActivity.transferTxId,
90+ contact : String? = baseOnchainActivity.contact,
9091 createdAt : ULong? = baseOnchainActivity.createdAt,
9192 updatedAt : ULong? = baseOnchainActivity.updatedAt,
9293 ): Activity .Onchain {
@@ -107,6 +108,7 @@ class ActivityRepoTest : BaseUnitTest() {
107108 confirmTimestamp = confirmTimestamp,
108109 channelId = channelId,
109110 transferTxId = transferTxId,
111+ contact = contact,
110112 createdAt = createdAt,
111113 updatedAt = updatedAt
112114 )
@@ -267,6 +269,91 @@ class ActivityRepoTest : BaseUnitTest() {
267269 assertNull(result.getOrThrow())
268270 }
269271
272+ @Test
273+ fun `contactActivities filters replaced sent transaction` () = test {
274+ val contactPublicKey = " pubky3rsduhcxpw74snwyct86m38c63j3pq8x4ycqikxg64roik8yw5xg"
275+ val replacedTxId = " replaced_tx_id"
276+ val replacedActivity = createOnchainActivity(
277+ id = " replaced_activity_id" ,
278+ txId = replacedTxId,
279+ doesExist = false ,
280+ contact = contactPublicKey,
281+ )
282+ val replacementActivity = createOnchainActivity(
283+ id = " replacement_activity_id" ,
284+ txId = " replacement_tx_id" ,
285+ boostTxIds = listOf (replacedTxId),
286+ contact = contactPublicKey,
287+ )
288+ whenever(coreService.activity.getTxIdsInBoostTxIds()).thenReturn(setOf (replacedTxId))
289+ whenever(
290+ coreService.activity.get(
291+ filter = ActivityFilter .ALL ,
292+ txType = null ,
293+ tags = null ,
294+ search = null ,
295+ minDate = null ,
296+ maxDate = null ,
297+ limit = null ,
298+ sortDirection = SortDirection .DESC ,
299+ )
300+ ).thenReturn(listOf (replacedActivity, replacementActivity))
301+
302+ val result = sut.contactActivities(contactPublicKey)
303+
304+ assertEquals(listOf (replacementActivity), result.getOrThrow())
305+ }
306+
307+ @Test
308+ fun `setContact propagates contact to replacement transaction` () = test {
309+ val contactPublicKey = " pubky3rsduhcxpw74snwyct86m38c63j3pq8x4ycqikxg64roik8yw5xg"
310+ val replacedTxId = " replaced_tx_id"
311+ val replacedActivity = createOnchainActivity(
312+ id = " replaced_activity_id" ,
313+ txId = replacedTxId,
314+ doesExist = false ,
315+ )
316+ val replacementActivity = createOnchainActivity(
317+ id = " replacement_activity_id" ,
318+ txId = " replacement_tx_id" ,
319+ boostTxIds = listOf (replacedTxId),
320+ )
321+ whenever(coreService.activity.getActivity(replacedTxId)).thenReturn(null )
322+ whenever(coreService.activity.getOnchainActivityByTxId(replacedTxId)).thenReturn(replacedActivity.v1)
323+ whenever(
324+ coreService.activity.get(
325+ filter = ActivityFilter .ONCHAIN ,
326+ txType = null ,
327+ tags = null ,
328+ search = null ,
329+ minDate = null ,
330+ maxDate = null ,
331+ limit = null ,
332+ sortDirection = null ,
333+ )
334+ ).thenReturn(listOf (replacedActivity, replacementActivity))
335+
336+ val result = sut.setContact(
337+ contactPublicKey = contactPublicKey,
338+ forPaymentId = replacedTxId,
339+ syncLdkPayments = false ,
340+ )
341+
342+ assertTrue(result.isSuccess)
343+ verify(coreService.activity).update(
344+ eq(replacedActivity.v1.id),
345+ argThat {
346+ this is Activity .Onchain && v1.contact == contactPublicKey
347+ },
348+ )
349+ verify(coreService.activity).update(
350+ eq(replacementActivity.v1.id),
351+ argThat {
352+ this is Activity .Onchain && v1.contact == contactPublicKey
353+ },
354+ )
355+ }
356+
270357 @Test
271358 fun `updateActivity updates successfully when not deleted` () = test {
272359 val activityId = " activity123"
0 commit comments