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,
)
val client = EmptyNostrClient
val client = EmptyNostrClient()
val authenticator = EmptyIAuthStatus
val nwcFilters = NWCPaymentFilterAssembler(client)
@@ -1842,7 +1842,7 @@ fun mockVitorAccountViewModel(): AccountViewModel {
pubKey = Hex.decode("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c"),
)
val client = EmptyNostrClient
val client = EmptyNostrClient()
val authenticator = EmptyIAuthStatus
val nwcFilters = NWCPaymentFilterAssembler(client)
@@ -1856,7 +1856,7 @@ fun mockVitorAccountViewModel(): AccountViewModel {
nwcFilterAssembler = nwcFilters,
otsResolverBuilder = EmptyOtsResolverBuilder,
cache = LocalCache,
client = EmptyNostrClient,
client = EmptyNostrClient(),
scope = scope,
)
@@ -61,7 +61,7 @@ class AccountManagerHeartbeatTest {
NostrSignerRemote.fromBunkerUri(
"bunker://$validHex?relay=wss://r.com",
ephemeral,
EmptyNostrClient,
EmptyNostrClient(),
),
)
}
@@ -25,7 +25,7 @@ Write tests that **reproduce the three NIP-46 bugs** before they're fixed, then
### Existing
- Framework: `kotlin.test` + `kotlinx-coroutines-test` + `mockk`
- 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
### Needed
@@ -40,9 +40,9 @@ Three tests pass `client` param to `loadSavedAccount()` which no longer accepts
| 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) |
| `loadSavedAccountBunkerSuccess` (line 155-158) | Remove `client = EmptyNostrClient` arg |
| `loadSavedAccountBunkerSuccess` (line 155-158) | Remove `client = EmptyNostrClient()` arg |
## Phase 1: Relay Isolation Tests (Bug 2 + 3)
@@ -87,7 +87,7 @@ interface INostrClient : AutoCloseable {
fun activeOutboxCache(url: NormalizedRelayUrl): Set<HexKey>
}
object EmptyNostrClient : INostrClient {
class EmptyNostrClient : INostrClient {
override fun connectedRelaysFlow() = MutableStateFlow(emptySet<NormalizedRelayUrl>())
override fun availableRelaysFlow() = MutableStateFlow(emptySet<NormalizedRelayUrl>())
@@ -21,8 +21,6 @@
package com.vitorpamplona.quartz.nip01Core.relay.client.accessories
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.reqs.IRequestListener
import com.vitorpamplona.quartz.nip01Core.relay.client.single.newSubId
@@ -34,7 +34,7 @@ class ConvertExceptionsTest {
NostrSignerRemote.fromBunkerUri(
"bunker://${"a".repeat(64)}?relay=wss://r.com",
NostrSignerInternal(KeyPair()),
EmptyNostrClient,
EmptyNostrClient(),
)
@Test
@@ -30,7 +30,7 @@ import kotlin.test.assertNull
class FromBunkerUriTest {
private val signer = NostrSignerInternal(KeyPair())
private val client = EmptyNostrClient
private val client = EmptyNostrClient()
private val validHex = "a".repeat(64)
@Test