From 7583f7f8e1f83d484f83d2ecd81bbd3857eff3d6 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Wed, 25 Mar 2026 08:33:04 -0400 Subject: [PATCH] Moves some of the nip-44 based tests to commonTest --- .../quartz/nip44Encryption/Nip44v2Test.kt} | 2 +- .../LnZapPaymentRequestNip44EventTest.kt | 8 +- .../LnZapPaymentRequestNip44EventTest.kt | 84 ------------------- 3 files changed, 5 insertions(+), 89 deletions(-) rename quartz/src/{jvmTest/java/com/vitorpamplona/quartz/nip44Encryption/Nip44v2JvmTest.kt => commonTest/kotlin/com/vitorpamplona/quartz/nip44Encryption/Nip44v2Test.kt} (99%) rename quartz/src/{iosTest => commonTest}/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt (92%) delete mode 100644 quartz/src/jvmTest/java/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt diff --git a/quartz/src/jvmTest/java/com/vitorpamplona/quartz/nip44Encryption/Nip44v2JvmTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip44Encryption/Nip44v2Test.kt similarity index 99% rename from quartz/src/jvmTest/java/com/vitorpamplona/quartz/nip44Encryption/Nip44v2JvmTest.kt rename to quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip44Encryption/Nip44v2Test.kt index 4173f9e22..fd6bcc367 100644 --- a/quartz/src/jvmTest/java/com/vitorpamplona/quartz/nip44Encryption/Nip44v2JvmTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip44Encryption/Nip44v2Test.kt @@ -30,7 +30,7 @@ import kotlin.test.assertEquals * NIP-44v2 tests verifying conversation key derivation, ECDH symmetry, * and encrypt/decrypt round-trips on JVM Desktop. */ -class Nip44v2JvmTest { +class Nip44v2Test { @Test fun conversationKeyFromSpecVector1() { val nip44v2 = Nip44v2() diff --git a/quartz/src/iosTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt similarity index 92% rename from quartz/src/iosTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt rename to quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt index 90117ac43..4e9a209c0 100644 --- a/quartz/src/iosTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt @@ -42,9 +42,9 @@ class LnZapPaymentRequestNip44EventTest { val walletServicePubkey: HexKey = walletKeyPair.pubKey.toHexKey() - val request = GetBalanceMethod.create() + val request = GetBalanceMethod.Companion.create() val event = - LnZapPaymentRequestEvent.createRequest( + LnZapPaymentRequestEvent.Companion.createRequest( request = request, walletServicePubkey = walletServicePubkey, signer = clientSigner, @@ -66,9 +66,9 @@ class LnZapPaymentRequestNip44EventTest { val walletServicePubkey: HexKey = walletKeyPair.pubKey.toHexKey() - val request = GetInfoMethod.create() + val request = GetInfoMethod.Companion.create() val event = - LnZapPaymentRequestEvent.createRequest( + LnZapPaymentRequestEvent.Companion.createRequest( request = request, walletServicePubkey = walletServicePubkey, signer = clientSigner, diff --git a/quartz/src/jvmTest/java/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt b/quartz/src/jvmTest/java/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt deleted file mode 100644 index 90117ac43..000000000 --- a/quartz/src/jvmTest/java/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.quartz.nip47WalletConnect - -import com.vitorpamplona.quartz.nip01Core.core.HexKey -import com.vitorpamplona.quartz.nip01Core.core.toHexKey -import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair -import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentRequestEvent -import com.vitorpamplona.quartz.nip47WalletConnect.rpc.GetBalanceMethod -import com.vitorpamplona.quartz.nip47WalletConnect.rpc.GetInfoMethod -import kotlinx.coroutines.test.runTest -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertIs - -class LnZapPaymentRequestNip44EventTest { - @Test - fun testCreateRequestWithNip44() = - runTest { - val clientKeyPair = KeyPair() - val walletKeyPair = KeyPair() - val clientSigner = NostrSignerInternal(clientKeyPair) - val walletServicePubkey: HexKey = - walletKeyPair.pubKey.toHexKey() - - val request = GetBalanceMethod.create() - val event = - LnZapPaymentRequestEvent.createRequest( - request = request, - walletServicePubkey = walletServicePubkey, - signer = clientSigner, - createdAt = 1000L, - useNip44 = true, - ) - - assertEquals(23194, event.kind) - assertEquals("nip44_v2", event.encryptionScheme()) - } - - @Test - fun testDecryptNip44Request() = - runTest { - val clientKeyPair = KeyPair() - val walletKeyPair = KeyPair() - val clientSigner = NostrSignerInternal(clientKeyPair) - val walletSigner = NostrSignerInternal(walletKeyPair) - val walletServicePubkey: HexKey = - walletKeyPair.pubKey.toHexKey() - - val request = GetInfoMethod.create() - val event = - LnZapPaymentRequestEvent.createRequest( - request = request, - walletServicePubkey = walletServicePubkey, - signer = clientSigner, - useNip44 = true, - ) - - assertEquals("nip44_v2", event.encryptionScheme()) - - // Wallet service should be able to decrypt NIP-44 encrypted request - val decrypted = event.decryptRequest(walletSigner) - assertIs(decrypted) - } -}