Moves EmptyNostrClient to a class to avoid auto-import issues

This commit is contained in:
Vitor Pamplona
2026-03-22 15:14:49 -04:00
parent 2e1066a609
commit 439b392aa0
7 changed files with 10 additions and 12 deletions
@@ -1791,7 +1791,7 @@ fun mockAccountViewModel(): AccountViewModel {
forceReplacePubkey = false, forceReplacePubkey = false,
) )
val client = EmptyNostrClient val client = EmptyNostrClient()
val authenticator = EmptyIAuthStatus val authenticator = EmptyIAuthStatus
val nwcFilters = NWCPaymentFilterAssembler(client) val nwcFilters = NWCPaymentFilterAssembler(client)
@@ -1842,7 +1842,7 @@ fun mockVitorAccountViewModel(): AccountViewModel {
pubKey = Hex.decode("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c"), pubKey = Hex.decode("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c"),
) )
val client = EmptyNostrClient val client = EmptyNostrClient()
val authenticator = EmptyIAuthStatus val authenticator = EmptyIAuthStatus
val nwcFilters = NWCPaymentFilterAssembler(client) val nwcFilters = NWCPaymentFilterAssembler(client)
@@ -1856,7 +1856,7 @@ fun mockVitorAccountViewModel(): AccountViewModel {
nwcFilterAssembler = nwcFilters, nwcFilterAssembler = nwcFilters,
otsResolverBuilder = EmptyOtsResolverBuilder, otsResolverBuilder = EmptyOtsResolverBuilder,
cache = LocalCache, cache = LocalCache,
client = EmptyNostrClient, client = EmptyNostrClient(),
scope = scope, scope = scope,
) )
@@ -61,7 +61,7 @@ class AccountManagerHeartbeatTest {
NostrSignerRemote.fromBunkerUri( NostrSignerRemote.fromBunkerUri(
"bunker://$validHex?relay=wss://r.com", "bunker://$validHex?relay=wss://r.com",
ephemeral, ephemeral,
EmptyNostrClient, EmptyNostrClient(),
), ),
) )
} }
@@ -25,7 +25,7 @@ Write tests that **reproduce the three NIP-46 bugs** before they're fixed, then
### Existing ### Existing
- Framework: `kotlin.test` + `kotlinx-coroutines-test` + `mockk` - Framework: `kotlin.test` + `kotlinx-coroutines-test` + `mockk`
- Location: `desktopApp/src/jvmTest/kotlin/.../desktop/account/` - Location: `desktopApp/src/jvmTest/kotlin/.../desktop/account/`
- Mocks: `EmptyNostrClient` (no-op), `mockk<SecureKeyStorage>(relaxed = true)`, temp dirs - Mocks: `EmptyNostrClient()` (no-op), `mockk<SecureKeyStorage>(relaxed = true)`, temp dirs
- Pattern: `@BeforeTest` setup → `runTest {}``@AfterTest` cleanup - Pattern: `@BeforeTest` setup → `runTest {}``@AfterTest` cleanup
### Needed ### Needed
@@ -40,9 +40,9 @@ Three tests pass `client` param to `loadSavedAccount()` which no longer accepts
| Test | Fix | | Test | Fix |
|------|-----| |------|-----|
| `loadSavedAccountBunkerNoEphemeralReturnsFailure` (line 114) | Remove `client = EmptyNostrClient` arg | | `loadSavedAccountBunkerNoEphemeralReturnsFailure` (line 114) | Remove `client = EmptyNostrClient()` arg |
| `loadSavedAccountBunkerNoClientFallsBackToInternal` (line 119-136) | **Delete entirely** — concept no longer exists (AccountManager always creates its own NIP-46 client) | | `loadSavedAccountBunkerNoClientFallsBackToInternal` (line 119-136) | **Delete entirely** — concept no longer exists (AccountManager always creates its own NIP-46 client) |
| `loadSavedAccountBunkerSuccess` (line 155-158) | Remove `client = EmptyNostrClient` arg | | `loadSavedAccountBunkerSuccess` (line 155-158) | Remove `client = EmptyNostrClient()` arg |
## Phase 1: Relay Isolation Tests (Bug 2 + 3) ## Phase 1: Relay Isolation Tests (Bug 2 + 3)
@@ -87,7 +87,7 @@ interface INostrClient : AutoCloseable {
fun activeOutboxCache(url: NormalizedRelayUrl): Set<HexKey> fun activeOutboxCache(url: NormalizedRelayUrl): Set<HexKey>
} }
object EmptyNostrClient : INostrClient { class EmptyNostrClient : INostrClient {
override fun connectedRelaysFlow() = MutableStateFlow(emptySet<NormalizedRelayUrl>()) override fun connectedRelaysFlow() = MutableStateFlow(emptySet<NormalizedRelayUrl>())
override fun availableRelaysFlow() = MutableStateFlow(emptySet<NormalizedRelayUrl>()) override fun availableRelaysFlow() = MutableStateFlow(emptySet<NormalizedRelayUrl>())
@@ -21,8 +21,6 @@
package com.vitorpamplona.quartz.nip01Core.relay.client.accessories package com.vitorpamplona.quartz.nip01Core.relay.client.accessories
import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.Event
import com.vitorpamplona.quartz.nip01Core.relay.client.EmptyNostrClient.close
import com.vitorpamplona.quartz.nip01Core.relay.client.EmptyNostrClient.openReqSubscription
import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient
import com.vitorpamplona.quartz.nip01Core.relay.client.reqs.IRequestListener import com.vitorpamplona.quartz.nip01Core.relay.client.reqs.IRequestListener
import com.vitorpamplona.quartz.nip01Core.relay.client.single.newSubId import com.vitorpamplona.quartz.nip01Core.relay.client.single.newSubId
@@ -34,7 +34,7 @@ class ConvertExceptionsTest {
NostrSignerRemote.fromBunkerUri( NostrSignerRemote.fromBunkerUri(
"bunker://${"a".repeat(64)}?relay=wss://r.com", "bunker://${"a".repeat(64)}?relay=wss://r.com",
NostrSignerInternal(KeyPair()), NostrSignerInternal(KeyPair()),
EmptyNostrClient, EmptyNostrClient(),
) )
@Test @Test
@@ -30,7 +30,7 @@ import kotlin.test.assertNull
class FromBunkerUriTest { class FromBunkerUriTest {
private val signer = NostrSignerInternal(KeyPair()) private val signer = NostrSignerInternal(KeyPair())
private val client = EmptyNostrClient private val client = EmptyNostrClient()
private val validHex = "a".repeat(64) private val validHex = "a".repeat(64)
@Test @Test