From 31d7e135cb047590ca41d78adfe8a0dc40df416c Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Mon, 29 Dec 2025 14:23:48 -0500 Subject: [PATCH] Updates kotlin, compose, multiplatform, activity, serialization, media3, mockk, secp256, tor, androidxCamera, stdlib --- .../amethyst/model/UiSettingsFlow.kt | 34 +++--- .../amethyst/ui/tor/TorSettingsFlow.kt | 2 +- gradle/libs.versions.toml | 24 ++--- .../quartz/nip03Timestamp/ots/Merkle.kt | 2 +- .../quartz/nip03Timestamp/ots/Timestamp.kt | 4 +- .../quartz/nip10Notes/tags/Positional.kt | 57 ++++------ .../quartz/nip17Dm/base/BaseDMGroupEvent.kt | 2 +- .../quartz/nip17Dm/base/NIP17Group.kt | 2 +- .../admin/ChannelMetadataEvent.kt | 2 +- .../jackson/EventDeserializerTest.kt | 2 +- .../quartz/nip19Bech32/NIP19ParserTest.kt | 102 +++++++++--------- .../nip46RemoteSigner/BunkerRequestTest.kt | 3 +- 12 files changed, 111 insertions(+), 125 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/UiSettingsFlow.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/UiSettingsFlow.kt index e51f89b14..d1d4303a7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/UiSettingsFlow.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/UiSettingsFlow.kt @@ -20,6 +20,7 @@ */ package com.vitorpamplona.amethyst.model +import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.combine @@ -36,23 +37,24 @@ class UiSettingsFlow( val featureSet: MutableStateFlow = MutableStateFlow(FeatureSetType.SIMPLIFIED), val gallerySet: MutableStateFlow = MutableStateFlow(ProfileGalleryType.CLASSIC), ) { + val listOfFlows: List> = + listOf>( + theme, + preferredLanguage, + automaticallyShowImages, + automaticallyStartPlayback, + automaticallyShowUrlPreview, + automaticallyHideNavigationBars, + automaticallyShowProfilePictures, + dontShowPushNotificationSelector, + dontAskForNotificationPermissions, + featureSet, + gallerySet, + ) + // emits at every change in any of the propertyes. - val propertyWatchFlow = - combine( - listOf( - theme, - preferredLanguage, - automaticallyShowImages, - automaticallyStartPlayback, - automaticallyShowUrlPreview, - automaticallyHideNavigationBars, - automaticallyShowProfilePictures, - dontShowPushNotificationSelector, - dontAskForNotificationPermissions, - featureSet, - gallerySet, - ), - ) { flows -> + val propertyWatchFlow: Flow = + combine(listOfFlows) { flows: Array -> UiSettings( flows[0] as ThemeType, flows[1] as String?, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsFlow.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsFlow.kt index 5c7c0a361..3b46a3272 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsFlow.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsFlow.kt @@ -40,7 +40,7 @@ class TorSettingsFlow( ) { // emits at every change in any of the properties. val propertyWatchFlow = - combine( + combine( listOf( torType, externalSocksPort, diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b28210259..f2c9693c5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] accompanistAdaptive = "0.37.3" -composeMultiplatform = "1.7.1" -activityCompose = "1.12.1" +composeMultiplatform = "1.9.3" +activityCompose = "1.12.2" agp = "8.13.2" android-compileSdk = "36" android-minSdk = "26" @@ -14,40 +14,40 @@ benchmark = "1.4.1" benchmarkJunit4 = "1.4.1" biometricKtx = "1.2.0-alpha05" coil = "3.3.0" -composeBom = "2025.12.00" +composeBom = "2025.12.01" composeRuntimeAnnotation = "1.10.0" coreKtx = "1.17.0" datastore = "1.2.0" espressoCore = "3.7.0" -firebaseBom = "34.6.0" +firebaseBom = "34.7.0" fragmentKtx = "1.8.9" gms = "4.4.4" jacksonModuleKotlin = "2.20.1" jna = "5.18.1" jtorctl = "0.4.5.7" junit = "4.13.2" -kotlin = "2.2.21" +kotlin = "2.3.0" kotlinxCollectionsImmutable = "0.4.0" kotlinxCoroutinesCore = "1.10.2" kotlinxSerialization = "1.9.0" -kotlinxSerializationPlugin = "2.2.21" +kotlinxSerializationPlugin = "2.3.0" languageId = "17.0.6" lazysodiumAndroid = "5.2.0" lazysodiumJava = "5.2.0" lifecycleRuntimeKtx = "2.10.0" lightcompressor-enhanced = "1.6.0" markdown = "f92ef49c9d" -media3 = "1.8.0" -mockk = "1.14.6" +media3 = "1.9.0" +mockk = "1.14.7" kotlinx-coroutines-test = "1.10.2" navigationCompose = "2.9.6" okhttp = "5.3.2" runner = "1.7.0" rfc3986 = "0.1.2" -secp256k1KmpJniAndroid = "0.21.0" +secp256k1KmpJniAndroid = "0.22.0" securityCryptoKtx = "1.1.0" spotless = "8.1.0" -torAndroid = "0.4.8.21" +torAndroid = "0.4.8.21.1" translate = "17.0.3" unifiedpush = "3.0.10" urlDetector = "0.1.23" @@ -57,9 +57,9 @@ zoomable = "2.9.0" zxing = "3.5.4" zxingAndroidEmbedded = "4.3.0" windowCoreAndroid = "1.5.1" -androidxCamera = "1.5.1" +androidxCamera = "1.5.2" androidxCollection = "1.5.0" -kotlinStdlib = "2.2.21" +kotlinStdlib = "2.3.0" kotlinTest = "2.2.20" core = "1.7.0" mavenPublish = "0.35.0" diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip03Timestamp/ots/Merkle.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip03Timestamp/ots/Merkle.kt index 4d96a22d7..378b42f40 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip03Timestamp/ots/Merkle.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip03Timestamp/ots/Merkle.kt @@ -47,7 +47,7 @@ object Merkle { // left.ops[OpAppend(right.msg)] = right_prepend_stamp // leftAppendStamp = left.ops.add(OpAppend(right.msg)) // Timestamp leftPrependStamp = left.add(new OpAppend(right.msg)); - left.ops.put(OpAppend(right.digest), rightPrependStamp!!) + left.ops[OpAppend(right.digest)] = rightPrependStamp // return rightPrependStamp.ops.add(unaryOpCls()) val res = rightPrependStamp.add(OpSHA256()) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip03Timestamp/ots/Timestamp.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip03Timestamp/ots/Timestamp.kt index b44e59a73..92c611a8f 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip03Timestamp/ots/Timestamp.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip03Timestamp/ots/Timestamp.kt @@ -453,12 +453,12 @@ class Timestamp( fun allTips(): MutableSet { val set: MutableSet = HashSet() - if (this.ops.size == 0) { + if (this.ops.isEmpty()) { set.add(this.digest) } for (entry in this.ops.entries) { - val ts: Timestamp = entry.value!! + val ts: Timestamp = entry.value // Op op = entry.getKey(); val subSet = ts.allTips() diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip10Notes/tags/Positional.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip10Notes/tags/Positional.kt index 91884e339..0f68990b8 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip10Notes/tags/Positional.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip10Notes/tags/Positional.kt @@ -21,6 +21,7 @@ package com.vitorpamplona.quartz.nip10Notes.tags import com.vitorpamplona.quartz.nip01Core.tags.events.ETag +import com.vitorpamplona.quartz.nip01Core.tags.events.GenericETag /** * Returns a list of NIP-10 marked tags that are also ordered at best effort to support the @@ -32,47 +33,25 @@ import com.vitorpamplona.quartz.nip01Core.tags.events.ETag * The tag to the root of the reply chain goes first. The tag to the reply event being responded * to goes last. The order for any other tag does not matter, so keep the relative order. */ -fun List.positionalMarkedTags( - tagName: String, - root: String?, - replyingTo: String?, - forkedFrom: String?, -) = sortedWith { o1, o2 -> - when { - o1 == o2 -> 0 - o1 == root -> -1 // root goes first - o2 == root -> 1 // root goes first - o1 == replyingTo -> 1 // reply event being responded to goes last - o2 == replyingTo -> -1 // reply event being responded to goes last - else -> 0 // keep the relative order for any other tag - } -}.map { - when (it) { - root -> arrayOf(tagName, it, "", MarkedETag.MARKER.ROOT) - replyingTo -> arrayOf(tagName, it, "", MarkedETag.MARKER.REPLY) - forkedFrom -> arrayOf(tagName, it, "", MarkedETag.MARKER.FORK) - else -> arrayOf(tagName, it) - } -} - fun List.positionalMarkedTags( root: ETag?, replyingTo: ETag?, forkedFrom: ETag?, -) = sortedWith { o1, o2 -> - when { - o1.eventId == o2.eventId -> 0 - o1.eventId == root?.eventId -> -1 // root goes first - o2.eventId == root?.eventId -> 1 // root goes first - o1.eventId == replyingTo?.eventId -> 1 // reply event being responded to goes last - o2.eventId == replyingTo?.eventId -> -1 // reply event being responded to goes last - else -> 0 // keep the relative order for any other tag +): List = + sortedWith { o1, o2 -> + when { + o1.eventId == o2.eventId -> 0 + o1.eventId == root?.eventId -> -1 // root goes first + o2.eventId == root?.eventId -> 1 // root goes first + o1.eventId == replyingTo?.eventId -> 1 // reply event being responded to goes last + o2.eventId == replyingTo?.eventId -> -1 // reply event being responded to goes last + else -> 0 // keep the relative order for any other tag + } + }.map { + when (it.eventId) { + root?.eventId -> MarkedETag(it.eventId, it.relay, MarkedETag.MARKER.ROOT, it.author) + replyingTo?.eventId -> MarkedETag(it.eventId, it.relay, MarkedETag.MARKER.REPLY, it.author) + forkedFrom?.eventId -> MarkedETag(it.eventId, it.relay, MarkedETag.MARKER.FORK, it.author) + else -> it + } } -}.map { - when (it.eventId) { - root?.eventId -> MarkedETag(it.eventId, it.relay, MarkedETag.MARKER.ROOT, it.author) - replyingTo?.eventId -> MarkedETag(it.eventId, it.relay, MarkedETag.MARKER.REPLY, it.author) - forkedFrom?.eventId -> MarkedETag(it.eventId, it.relay, MarkedETag.MARKER.FORK, it.author) - else -> it - } -} diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip17Dm/base/BaseDMGroupEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip17Dm/base/BaseDMGroupEvent.kt index b47e875ce..0e2d3da7c 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip17Dm/base/BaseDMGroupEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip17Dm/base/BaseDMGroupEvent.kt @@ -69,7 +69,7 @@ open class BaseDMGroupEvent( return result } - override fun isIncluded(pubKey: HexKey) = pubKey == this.pubKey || tags.any(PTag::isTagged, pubKey) + override fun isIncluded(user: HexKey) = pubKey == this.pubKey || tags.any(PTag::isTagged, pubKey) override fun groupMembers() = recipientsPubKey().plus(pubKey).toSet() diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip17Dm/base/NIP17Group.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip17Dm/base/NIP17Group.kt index 0beca6658..6f3a49d68 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip17Dm/base/NIP17Group.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip17Dm/base/NIP17Group.kt @@ -23,7 +23,7 @@ package com.vitorpamplona.quartz.nip17Dm.base import com.vitorpamplona.quartz.nip01Core.core.HexKey interface NIP17Group { - fun isIncluded(pubKey: HexKey): Boolean + fun isIncluded(user: HexKey): Boolean fun groupMembers(): Set } diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/admin/ChannelMetadataEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/admin/ChannelMetadataEvent.kt index 02ead09a9..9f6ffd5f9 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/admin/ChannelMetadataEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/admin/ChannelMetadataEvent.kt @@ -70,7 +70,7 @@ class ChannelMetadataEvent( if (content.isEmpty() || !content.startsWith("{") || isEncrypted()) { ChannelDataNorm() } else { - ChannelData.parse(content).normalize() ?: ChannelDataNorm() + ChannelData.parse(content).normalize() } } catch (e: Exception) { if (e is CancellationException) throw e diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/jackson/EventDeserializerTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/jackson/EventDeserializerTest.kt index b082372ba..d061ebd8f 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/jackson/EventDeserializerTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/jackson/EventDeserializerTest.kt @@ -57,7 +57,7 @@ class EventDeserializerTest { val templateJson = """{"kind":1,"content":"This is an unsigned event.","created_at":1234,"tags":[]}""" val template = EventTemplate.fromJson(templateJson) - val signedEvent = signer.signerSync.sign(template)!! + val signedEvent = signer.signerSync.sign(template) assertTrue(signedEvent.id.isNotEmpty()) assertTrue(signedEvent.sig.isNotEmpty()) diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip19Bech32/NIP19ParserTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip19Bech32/NIP19ParserTest.kt index 63198581c..58eb50846 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip19Bech32/NIP19ParserTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip19Bech32/NIP19ParserTest.kt @@ -107,8 +107,8 @@ class NIP19ParserTest { assertNotNull(actual) assertTrue(actual?.entity is NProfile) - assertEquals("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c", (actual?.entity as? NProfile)?.hex) - assertEquals(NormalizedRelayUrl("wss://vitor.nostr1.com/"), (actual?.entity as? NProfile)?.relay?.first()) + assertEquals("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c", actual.entity.hex) + assertEquals(NormalizedRelayUrl("wss://vitor.nostr1.com/"), actual.entity.relay?.first()) } @Test() @@ -116,7 +116,7 @@ class NIP19ParserTest { val actual = Nip19Parser.uriToRoute("nostr:nprofile1qy2hwumn8ghj7un9d3shjtnyv9kh2uewd9hj7qgwwaehxw309ahx7uewd3hkctcpr9mhxue69uhhyetvv9ujuumwdae8gtnnda3kjctv9uqzq9thu3vem5gvsc6f3l3uyz7c92h6lq56t9wws0zulzkrgc6nrvym5jfztf") assertTrue(actual?.entity is NProfile) - assertEquals("1577e4599dd10c863498fe3c20bd82aafaf829a595ce83c5cf8ac3463531b09b", (actual?.entity as? NProfile)?.hex) + assertEquals("1577e4599dd10c863498fe3c20bd82aafaf829a595ce83c5cf8ac3463531b09b", actual.entity.hex) } @Test() @@ -124,7 +124,7 @@ class NIP19ParserTest { val actual = Nip19Parser.uriToRoute("nostr:nevent1qy2hwumn8ghj7un9d3shjtnyv9kh2uewd9hj7qgwwaehxw309ahx7uewd3hkctcpr9mhxue69uhhyetvv9ujuumwdae8gtnnda3kjctv9uq36amnwvaz7tmjv4kxz7fwvd5xjcmpvahhqmr9vfejucm0d5hsz9mhwden5te0wfjkccte9ec8y6tdv9kzumn9wshsz8thwden5te0dehhxarj9ekh2arfdeuhwctvd3jhgtnrdakj7qg3waehxw309ucngvpwvcmh5tnfduhszythwden5te0dehhxarj9emkjmn99uq3jamnwvaz7tmhv4kxxmmdv5hxummnw3ezuamfdejj7qpqvsup5xk3e2quedxjvn2gjppc0lqny5dmnr2ypc9tftwmdxta0yjqrd6n50") assertTrue(actual?.entity is NEvent) - assertEquals("64381a1ad1ca81ccb4d264d48904387fc13251bb98d440e0ab4addb6997d7924", (actual?.entity as? NEvent)?.hex) + assertEquals("64381a1ad1ca81ccb4d264d48904387fc13251bb98d440e0ab4addb6997d7924", actual.entity.hex) } @Test() @@ -132,7 +132,7 @@ class NIP19ParserTest { val actual = Nip19Parser.uriToRoute("nostr:naddr1qqyxzmt9w358jum5qyt8wumn8ghj7un9d3shjtnwdaehgu3wvfskueqzypd7v3r24z33cydnk3fmlrd0exe5dlej3506zxs05q4puerp765mzqcyqqq8scsq6mk7u") assertTrue(actual?.entity is NAddress) - assertEquals("30818:5be6446aa8a31c11b3b453bf8dafc9b346ff328d1fa11a0fa02a1e6461f6a9b1:amethyst", (actual?.entity as? NAddress)?.aTag()) + assertEquals("30818:5be6446aa8a31c11b3b453bf8dafc9b346ff328d1fa11a0fa02a1e6461f6a9b1:amethyst", actual.entity.aTag()) } @Test @@ -141,9 +141,10 @@ class NIP19ParserTest { Nip19Parser.uriToRoute( "nostr:naddr1qqqqygzxpsj7dqha57pjk5k37gkn6g4nzakewtmqmnwryyhd3jfwlpgxtspsgqqqw4rs3xyxus", ) + assertNotNull(result) assertEquals( "30023:460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c:", - (result?.entity as? NAddress)?.aTag(), + (result.entity as? NAddress)?.aTag(), ) } @@ -153,9 +154,10 @@ class NIP19ParserTest { Nip19Parser.uriToRoute( "nostr:naddr1qqqqzxthwden5te0wfjkccte9ejxjanfdejjuanfv3jk7tczyrv4428upmlcujyf2fy4hqrynywj07ukakr99ufvmmw95n5tttj5qqcyqqqgt0qeresua", ) + assertNotNull(result) assertEquals( "34236:d95aa8fc0eff8e488952495b8064991d27fb96ed8652f12cdedc5a4e8b5ae540:", - (result?.entity as? NAddress)?.aTag(), + (result.entity as? NAddress)?.aTag(), ) } @@ -165,9 +167,10 @@ class NIP19ParserTest { Nip19Parser.uriToRoute( "nostr:naddr1qq8kwatfv3jj6amfwfjkwatpwfjqygxsm6lelvfda7qlg0tud9pfhduysy4vrexj65azqtdk4tr75j6xdspsgqqqw4rsg32ag8", ) + assertNotNull(result) assertEquals( "30023:d0debf9fb12def81f43d7c69429bb784812ac1e4d2d53a202db6aac7ea4b466c:guide-wireguard", - (result?.entity as? NAddress)?.aTag(), + (result.entity as? NAddress)?.aTag(), ) } @@ -177,12 +180,13 @@ class NIP19ParserTest { Nip19Parser.uriToRoute( "naddr1qqyrswtyv5mnjv3sqy28wumn8ghj7un9d3shjtnyv9kh2uewd9hsygx3uczxts4hwue9ayfn7ggq62anzstde2qs749pm9tx2csuthhpjvpsgqqqw4rs8pmj38", ) - assertTrue(result?.entity is NAddress) + assertNotNull(result) + assertTrue(result.entity is NAddress) assertEquals( "30023:d1e60465c2b777325e9133f2100d2bb31416dca810f54a1d95665621c5dee193:89de7920", - (result?.entity as? NAddress)?.aTag(), + result.entity.aTag(), ) - assertEquals(NormalizedRelayUrl("wss://relay.damus.io/"), (result?.entity as? NAddress)?.relay?.get(0)) + assertEquals(NormalizedRelayUrl("wss://relay.damus.io/"), result.entity.relay[0]) } @Test @@ -261,11 +265,11 @@ class NIP19ParserTest { assertNotNull(result) assertEquals( "31337:27241bb702d145a975260cfedee6265936dcd939eaecb88ea0e4071752c30402:xx1xulrf7wdbdlbc31far", - result?.aTag(), + result.aTag(), ) - assertEquals(true, result?.relay?.isEmpty()) - assertEquals("27241bb702d145a975260cfedee6265936dcd939eaecb88ea0e4071752c30402", result?.author) - assertEquals(31337, result?.kind) + assertEquals(true, result.relay?.isEmpty()) + assertEquals("27241bb702d145a975260cfedee6265936dcd939eaecb88ea0e4071752c30402", result.author) + assertEquals(31337, result.kind) } @Test @@ -279,11 +283,11 @@ class NIP19ParserTest { assertNotNull(result) assertEquals( "30023:46fcbe3065eaf1ae7811465924e48923363ff3f526bd6f73d7c184b16bd8ce4d:613f014d2911fb9df52e048aae70268c0d216790287b5814910e1e781e8e0509", - result?.aTag(), + result.aTag(), ) - assertEquals(true, result?.relay?.isEmpty()) - assertEquals("46fcbe3065eaf1ae7811465924e48923363ff3f526bd6f73d7c184b16bd8ce4d", result?.author) - assertEquals(30023, result?.kind) + assertEquals(true, result.relay?.isEmpty()) + assertEquals("46fcbe3065eaf1ae7811465924e48923363ff3f526bd6f73d7c184b16bd8ce4d", result.author) + assertEquals(30023, result.kind) } @Test @@ -297,11 +301,11 @@ class NIP19ParserTest { assertNotNull(result) assertEquals( "30023:46fcbe3065eaf1ae7811465924e48923363ff3f526bd6f73d7c184b16bd8ce4d:1679509418", - result?.aTag(), + result.aTag(), ) - assertEquals(true, result?.relay?.isEmpty()) - assertEquals("46fcbe3065eaf1ae7811465924e48923363ff3f526bd6f73d7c184b16bd8ce4d", result?.author) - assertEquals(30023, result?.kind) + assertEquals(true, result.relay?.isEmpty()) + assertEquals("46fcbe3065eaf1ae7811465924e48923363ff3f526bd6f73d7c184b16bd8ce4d", result.author) + assertEquals(30023, result.kind) } @Test @@ -310,10 +314,10 @@ class NIP19ParserTest { Nip19Parser.uriToRoute("nostr:nevent1qqsdw6xpk28tjnrajz4xhy2jqg0md8ywxj6997rsutjzxs0207tedjspz4mhxue69uhhyetvv9ujumn0wd68ytnzvuhsygx2crjrydvqdksffurc0fdsfc566pxtrg78afw0v8kursecwdqg9vpsgqqqqqqsnknas6")?.entity as? NEvent assertNotNull(result) - assertEquals("d768c1b28eb94c7d90aa6b9152021fb69c8e34b452f870e2e42341ea7f9796ca", result?.hex) - assertEquals("wss://relay.nostr.bg/", result?.relay?.firstOrNull()?.url) - assertEquals("cac0e43235806da094f0787a5b04e29ad04cb1a3c7ea5cf61edc1c338734082b", result?.author) - assertEquals(1, result?.kind) + assertEquals("d768c1b28eb94c7d90aa6b9152021fb69c8e34b452f870e2e42341ea7f9796ca", result.hex) + assertEquals("wss://relay.nostr.bg/", result.relay.firstOrNull()?.url) + assertEquals("cac0e43235806da094f0787a5b04e29ad04cb1a3c7ea5cf61edc1c338734082b", result.author) + assertEquals(1, result.kind) } @Test @@ -322,10 +326,10 @@ class NIP19ParserTest { Nip19Parser.uriToRoute("nostr:nevent1qqs0tsw8hjacs4fppgdg7f5yhgwwfkyua4xcs3re9wwkpkk2qeu6mhql22rcy")?.entity as? NEvent assertNotNull(result) - assertEquals("f5c1c7bcbb8855210a1a8f2684ba1ce4d89ced4d8844792b9d60daca0679addc", result?.hex) - assertEquals(true, result?.relay?.isEmpty()) - assertEquals(null, result?.author) - assertEquals(null, result?.kind) + assertEquals("f5c1c7bcbb8855210a1a8f2684ba1ce4d89ced4d8844792b9d60daca0679addc", result.hex) + assertEquals(true, result.relay.isEmpty()) + assertEquals(null, result.author) + assertEquals(null, result.kind) } @Test @@ -334,10 +338,10 @@ class NIP19ParserTest { Nip19Parser.uriToRoute("nostr:nevent1qqsfvaa2w3nkw472lt2ezr6x5x347k8hht398vp7hrl6wrdjldry86sprfmhxue69uhhyetvv9ujuam9wd6x2unwvf6xxtnrdaks5myyah")?.entity as? NEvent assertNotNull(result) - assertEquals("9677aa74676757cafad5910f46a1a35f58f7bae253b03eb8ffa70db2fb4643ea", result?.hex) - assertEquals("wss://relay.westernbtc.com/", result?.relay?.firstOrNull()?.url) - assertEquals(null, result?.author) - assertEquals(null, result?.kind) + assertEquals("9677aa74676757cafad5910f46a1a35f58f7bae253b03eb8ffa70db2fb4643ea", result.hex) + assertEquals("wss://relay.westernbtc.com/", result.relay.firstOrNull()?.url) + assertEquals(null, result.author) + assertEquals(null, result.kind) } @Test @@ -349,13 +353,13 @@ class NIP19ParserTest { )?.entity as? NEvent assertNotNull(result) - assertEquals("b60ffa7256d3dd7543d830eb717ae50d05a6c32c5f791ed15b867c2bb0b954ac", result?.hex) + assertEquals("b60ffa7256d3dd7543d830eb717ae50d05a6c32c5f791ed15b867c2bb0b954ac", result.hex) assertEquals( NormalizedRelayUrl("wss://nostr.mom/"), - result?.relay?.get(0), + result.relay?.get(0), ) - assertEquals("f8ff11c7a7d3478355d3b4d174e5a473797a906ea4aa61aa9b6bc0652c1ea17a", result?.author) - assertEquals(1, result?.kind) + assertEquals("f8ff11c7a7d3478355d3b4d174e5a473797a906ea4aa61aa9b6bc0652c1ea17a", result.author) + assertEquals(1, result.kind) } @Test @@ -367,10 +371,10 @@ class NIP19ParserTest { )?.entity as? NEvent assertNotNull(result) - assertEquals("1f878e82063d80f41a781d3a2ef7bc336f1beb7942bf3b49b42aee1251eb5cf0", result?.hex) - assertEquals(NormalizedRelayUrl("wss://relay.damus.io/"), result.relay.get(0)) - assertEquals("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c", result?.author) - assertEquals(1, result?.kind) + assertEquals("1f878e82063d80f41a781d3a2ef7bc336f1beb7942bf3b49b42aee1251eb5cf0", result.hex) + assertEquals(NormalizedRelayUrl("wss://relay.damus.io/"), result.relay[0]) + assertEquals("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c", result.author) + assertEquals(1, result.kind) } @Test @@ -382,10 +386,10 @@ class NIP19ParserTest { )?.entity as? NEvent assertNotNull(result) - assertEquals("8d2338bb62db88d13cea23f55f27c4886f68cf777dac42f2b65e6f709a5e6926", result?.hex) + assertEquals("8d2338bb62db88d13cea23f55f27c4886f68cf777dac42f2b65e6f709a5e6926", result.hex) assertEquals( "wss://nos.lol/,wss://nostr.oxtr.dev/,wss://relay.nostr.bg/,wss://nostr.einundzwanzig.space/,wss://relay.nostr.band/,wss://relay.damus.io/", - result?.relay?.joinToString(",") { it.url }, + result.relay.joinToString(",") { it.url }, ) } @@ -398,10 +402,10 @@ class NIP19ParserTest { )?.entity as? NEvent assertNotNull(result) - assertEquals("4300ec7fa2f98a276f033908349651620aa8e282b76030ab22abca63e85e07e6", result?.hex) - assertEquals("wss://relay.damus.io/", result?.relay?.get(0)?.url) - assertEquals("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c", result?.author) - assertEquals(1, result?.kind) + assertEquals("4300ec7fa2f98a276f033908349651620aa8e282b76030ab22abca63e85e07e6", result.hex) + assertEquals("wss://relay.damus.io/", result.relay.get(0)?.url) + assertEquals("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c", result.author) + assertEquals(1, result.kind) } @Test diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/BunkerRequestTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/BunkerRequestTest.kt index fe6c4f7a9..32d82c516 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/BunkerRequestTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/BunkerRequestTest.kt @@ -22,6 +22,7 @@ package com.vitorpamplona.quartz.nip46RemoteSigner import com.vitorpamplona.quartz.nip01Core.core.OptimizedJsonMapper import kotlin.test.Test +import kotlin.test.assertEquals import kotlin.test.assertTrue class BunkerRequestTest { @@ -31,6 +32,6 @@ class BunkerRequestTest { val bunkerRequest = OptimizedJsonMapper.fromJsonTo(requestJson) assertTrue(bunkerRequest is BunkerRequestSign) - assertTrue((bunkerRequest as BunkerRequestSign).event.kind == 1) + assertEquals(1, bunkerRequest.event.kind) } }