From 439b392aa0ec9806420b4916b67670d62aaadd54 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Sun, 22 Mar 2026 15:14:49 -0400 Subject: [PATCH] Moves EmptyNostrClient to a class to avoid auto-import issues --- .../amethyst/ui/screen/loggedIn/AccountViewModel.kt | 6 +++--- .../amethyst/desktop/account/AccountManagerHeartbeatTest.kt | 2 +- docs/plans/2026-03-05-nip46-tdd-tests-plan.md | 6 +++--- .../quartz/nip01Core/relay/client/INostrClient.kt | 2 +- .../accessories/NostrClientReqBypassingRelayLimitsExt.kt | 2 -- .../nip46RemoteSigner/signer/ConvertExceptionsTest.kt | 2 +- .../quartz/nip46RemoteSigner/signer/FromBunkerUriTest.kt | 2 +- 7 files changed, 10 insertions(+), 12 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index b3bd79893..0e83f65e5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -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, ) diff --git a/desktopApp/src/jvmTest/kotlin/com/vitorpamplona/amethyst/desktop/account/AccountManagerHeartbeatTest.kt b/desktopApp/src/jvmTest/kotlin/com/vitorpamplona/amethyst/desktop/account/AccountManagerHeartbeatTest.kt index 7a97d52c8..b0733dc81 100644 --- a/desktopApp/src/jvmTest/kotlin/com/vitorpamplona/amethyst/desktop/account/AccountManagerHeartbeatTest.kt +++ b/desktopApp/src/jvmTest/kotlin/com/vitorpamplona/amethyst/desktop/account/AccountManagerHeartbeatTest.kt @@ -61,7 +61,7 @@ class AccountManagerHeartbeatTest { NostrSignerRemote.fromBunkerUri( "bunker://$validHex?relay=wss://r.com", ephemeral, - EmptyNostrClient, + EmptyNostrClient(), ), ) } diff --git a/docs/plans/2026-03-05-nip46-tdd-tests-plan.md b/docs/plans/2026-03-05-nip46-tdd-tests-plan.md index 5471baf99..a04d2de04 100644 --- a/docs/plans/2026-03-05-nip46-tdd-tests-plan.md +++ b/docs/plans/2026-03-05-nip46-tdd-tests-plan.md @@ -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(relaxed = true)`, temp dirs +- Mocks: `EmptyNostrClient()` (no-op), `mockk(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) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/INostrClient.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/INostrClient.kt index e4d11a98b..6b738aec6 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/INostrClient.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/INostrClient.kt @@ -87,7 +87,7 @@ interface INostrClient : AutoCloseable { fun activeOutboxCache(url: NormalizedRelayUrl): Set } -object EmptyNostrClient : INostrClient { +class EmptyNostrClient : INostrClient { override fun connectedRelaysFlow() = MutableStateFlow(emptySet()) override fun availableRelaysFlow() = MutableStateFlow(emptySet()) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/accessories/NostrClientReqBypassingRelayLimitsExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/accessories/NostrClientReqBypassingRelayLimitsExt.kt index 96219ea0e..a4a20ab3f 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/accessories/NostrClientReqBypassingRelayLimitsExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/accessories/NostrClientReqBypassingRelayLimitsExt.kt @@ -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 diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/signer/ConvertExceptionsTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/signer/ConvertExceptionsTest.kt index 77a45f5a5..73b6b1201 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/signer/ConvertExceptionsTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/signer/ConvertExceptionsTest.kt @@ -34,7 +34,7 @@ class ConvertExceptionsTest { NostrSignerRemote.fromBunkerUri( "bunker://${"a".repeat(64)}?relay=wss://r.com", NostrSignerInternal(KeyPair()), - EmptyNostrClient, + EmptyNostrClient(), ) @Test diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/signer/FromBunkerUriTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/signer/FromBunkerUriTest.kt index 75447e1be..d0061c2f9 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/signer/FromBunkerUriTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/signer/FromBunkerUriTest.kt @@ -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