fix: resolve conflicts with upstream PR #1789 merge
- Add missing commons domain files (BunkerLoginUseCase, NostrConnectLoginUseCase) - Restore CoroutineScope in NostrSignerRemote for suspend decrypt call - Update isolation test: upstream removed `since` filter (PR #1789) - Add new INostrClient interface methods to TrackingNostrClient mock Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+11
-1
@@ -42,6 +42,11 @@ import com.vitorpamplona.quartz.nip46RemoteSigner.NostrConnectEvent
|
||||
import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent
|
||||
import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent
|
||||
import com.vitorpamplona.quartz.utils.Hex
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class NostrSignerRemote(
|
||||
val signer: NostrSignerInternal,
|
||||
@@ -51,6 +56,8 @@ class NostrSignerRemote(
|
||||
val permissions: String? = null,
|
||||
val secret: String? = null,
|
||||
) : NostrSigner(signer.pubKey) {
|
||||
private val scope = CoroutineScope(Dispatchers.Default + SupervisorJob())
|
||||
|
||||
private val manager =
|
||||
RemoteSignerManager(
|
||||
signer = signer,
|
||||
@@ -69,7 +76,9 @@ class NostrSignerRemote(
|
||||
),
|
||||
) { event ->
|
||||
if (event is NostrConnectEvent) {
|
||||
manager.newResponse(event)
|
||||
scope.launch {
|
||||
manager.newResponse(event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +88,7 @@ class NostrSignerRemote(
|
||||
|
||||
fun closeSubscription() {
|
||||
subscription.close()
|
||||
scope.cancel()
|
||||
}
|
||||
|
||||
override fun isWriteable(): Boolean = true
|
||||
|
||||
+11
-20
@@ -30,7 +30,6 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
|
||||
import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal
|
||||
import com.vitorpamplona.quartz.nip46RemoteSigner.NostrConnectEvent
|
||||
import com.vitorpamplona.quartz.utils.TimeUtils
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
@@ -96,6 +95,12 @@ private class TrackingNostrClient : INostrClient {
|
||||
override fun getReqFiltersOrNull(subId: String): Map<NormalizedRelayUrl, List<Filter>>? = null
|
||||
|
||||
override fun getCountFiltersOrNull(subId: String): Map<NormalizedRelayUrl, List<Filter>>? = null
|
||||
|
||||
override fun activeRequests(url: NormalizedRelayUrl): Map<String, List<Filter>> = emptyMap()
|
||||
|
||||
override fun activeCounts(url: NormalizedRelayUrl): Map<String, List<Filter>> = emptyMap()
|
||||
|
||||
override fun activeOutboxCache(url: NormalizedRelayUrl): Set<String> = emptySet()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,15 +206,12 @@ class NostrSignerRemoteIsolationTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* TDD RED TEST — will fail until Step 8 adds `since` filter.
|
||||
*
|
||||
* Reproduces Bug 3 mitigation: stale NIP-46 responses from previous
|
||||
* sessions should be filtered out via `since` timestamp.
|
||||
* Verify subscription filter does NOT use a `since` timestamp,
|
||||
* matching upstream behavior (PR #1789 removed it).
|
||||
*/
|
||||
@Test
|
||||
fun subscriptionFilterHasSinceTimestamp() {
|
||||
fun subscriptionFilterHasNoSinceTimestamp() {
|
||||
val trackingClient = TrackingNostrClient()
|
||||
val beforeTime = TimeUtils.now()
|
||||
|
||||
NostrSignerRemote(
|
||||
signer = NostrSignerInternal(KeyPair()),
|
||||
@@ -223,20 +225,9 @@ class NostrSignerRemoteIsolationTest {
|
||||
assertTrue(allFilters.isNotEmpty())
|
||||
|
||||
allFilters.forEach { filter ->
|
||||
val since =
|
||||
assertNotNull(
|
||||
filter.since,
|
||||
"Filter missing 'since' timestamp — stale responses won't be filtered",
|
||||
)
|
||||
// since should be roughly now - 60s (with tolerance)
|
||||
val expectedMin = beforeTime - 120 // extra tolerance for test execution time
|
||||
assertTrue(
|
||||
since >= expectedMin,
|
||||
"since too old: $since (expected >= $expectedMin)",
|
||||
)
|
||||
assertTrue(
|
||||
since <= beforeTime,
|
||||
"since in the future: $since",
|
||||
filter.since == null,
|
||||
"Filter should not have a 'since' timestamp",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user