Updates kotlin, compose, multiplatform, activity, serialization, media3, mockk, secp256, tor, androidxCamera, stdlib

This commit is contained in:
Vitor Pamplona
2025-12-29 14:23:48 -05:00
parent 6054c5700d
commit 31d7e135cb
12 changed files with 111 additions and 125 deletions
@@ -20,6 +20,7 @@
*/ */
package com.vitorpamplona.amethyst.model package com.vitorpamplona.amethyst.model
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.combine
@@ -36,23 +37,24 @@ class UiSettingsFlow(
val featureSet: MutableStateFlow<FeatureSetType> = MutableStateFlow(FeatureSetType.SIMPLIFIED), val featureSet: MutableStateFlow<FeatureSetType> = MutableStateFlow(FeatureSetType.SIMPLIFIED),
val gallerySet: MutableStateFlow<ProfileGalleryType> = MutableStateFlow(ProfileGalleryType.CLASSIC), val gallerySet: MutableStateFlow<ProfileGalleryType> = MutableStateFlow(ProfileGalleryType.CLASSIC),
) { ) {
val listOfFlows: List<Flow<Any?>> =
listOf<Flow<Any?>>(
theme,
preferredLanguage,
automaticallyShowImages,
automaticallyStartPlayback,
automaticallyShowUrlPreview,
automaticallyHideNavigationBars,
automaticallyShowProfilePictures,
dontShowPushNotificationSelector,
dontAskForNotificationPermissions,
featureSet,
gallerySet,
)
// emits at every change in any of the propertyes. // emits at every change in any of the propertyes.
val propertyWatchFlow = val propertyWatchFlow: Flow<UiSettings> =
combine( combine<Any?, UiSettings>(listOfFlows) { flows: Array<Any?> ->
listOf(
theme,
preferredLanguage,
automaticallyShowImages,
automaticallyStartPlayback,
automaticallyShowUrlPreview,
automaticallyHideNavigationBars,
automaticallyShowProfilePictures,
dontShowPushNotificationSelector,
dontAskForNotificationPermissions,
featureSet,
gallerySet,
),
) { flows ->
UiSettings( UiSettings(
flows[0] as ThemeType, flows[0] as ThemeType,
flows[1] as String?, flows[1] as String?,
@@ -40,7 +40,7 @@ class TorSettingsFlow(
) { ) {
// emits at every change in any of the properties. // emits at every change in any of the properties.
val propertyWatchFlow = val propertyWatchFlow =
combine( combine<Any, TorSettings>(
listOf( listOf(
torType, torType,
externalSocksPort, externalSocksPort,
+12 -12
View File
@@ -1,7 +1,7 @@
[versions] [versions]
accompanistAdaptive = "0.37.3" accompanistAdaptive = "0.37.3"
composeMultiplatform = "1.7.1" composeMultiplatform = "1.9.3"
activityCompose = "1.12.1" activityCompose = "1.12.2"
agp = "8.13.2" agp = "8.13.2"
android-compileSdk = "36" android-compileSdk = "36"
android-minSdk = "26" android-minSdk = "26"
@@ -14,40 +14,40 @@ benchmark = "1.4.1"
benchmarkJunit4 = "1.4.1" benchmarkJunit4 = "1.4.1"
biometricKtx = "1.2.0-alpha05" biometricKtx = "1.2.0-alpha05"
coil = "3.3.0" coil = "3.3.0"
composeBom = "2025.12.00" composeBom = "2025.12.01"
composeRuntimeAnnotation = "1.10.0" composeRuntimeAnnotation = "1.10.0"
coreKtx = "1.17.0" coreKtx = "1.17.0"
datastore = "1.2.0" datastore = "1.2.0"
espressoCore = "3.7.0" espressoCore = "3.7.0"
firebaseBom = "34.6.0" firebaseBom = "34.7.0"
fragmentKtx = "1.8.9" fragmentKtx = "1.8.9"
gms = "4.4.4" gms = "4.4.4"
jacksonModuleKotlin = "2.20.1" jacksonModuleKotlin = "2.20.1"
jna = "5.18.1" jna = "5.18.1"
jtorctl = "0.4.5.7" jtorctl = "0.4.5.7"
junit = "4.13.2" junit = "4.13.2"
kotlin = "2.2.21" kotlin = "2.3.0"
kotlinxCollectionsImmutable = "0.4.0" kotlinxCollectionsImmutable = "0.4.0"
kotlinxCoroutinesCore = "1.10.2" kotlinxCoroutinesCore = "1.10.2"
kotlinxSerialization = "1.9.0" kotlinxSerialization = "1.9.0"
kotlinxSerializationPlugin = "2.2.21" kotlinxSerializationPlugin = "2.3.0"
languageId = "17.0.6" languageId = "17.0.6"
lazysodiumAndroid = "5.2.0" lazysodiumAndroid = "5.2.0"
lazysodiumJava = "5.2.0" lazysodiumJava = "5.2.0"
lifecycleRuntimeKtx = "2.10.0" lifecycleRuntimeKtx = "2.10.0"
lightcompressor-enhanced = "1.6.0" lightcompressor-enhanced = "1.6.0"
markdown = "f92ef49c9d" markdown = "f92ef49c9d"
media3 = "1.8.0" media3 = "1.9.0"
mockk = "1.14.6" mockk = "1.14.7"
kotlinx-coroutines-test = "1.10.2" kotlinx-coroutines-test = "1.10.2"
navigationCompose = "2.9.6" navigationCompose = "2.9.6"
okhttp = "5.3.2" okhttp = "5.3.2"
runner = "1.7.0" runner = "1.7.0"
rfc3986 = "0.1.2" rfc3986 = "0.1.2"
secp256k1KmpJniAndroid = "0.21.0" secp256k1KmpJniAndroid = "0.22.0"
securityCryptoKtx = "1.1.0" securityCryptoKtx = "1.1.0"
spotless = "8.1.0" spotless = "8.1.0"
torAndroid = "0.4.8.21" torAndroid = "0.4.8.21.1"
translate = "17.0.3" translate = "17.0.3"
unifiedpush = "3.0.10" unifiedpush = "3.0.10"
urlDetector = "0.1.23" urlDetector = "0.1.23"
@@ -57,9 +57,9 @@ zoomable = "2.9.0"
zxing = "3.5.4" zxing = "3.5.4"
zxingAndroidEmbedded = "4.3.0" zxingAndroidEmbedded = "4.3.0"
windowCoreAndroid = "1.5.1" windowCoreAndroid = "1.5.1"
androidxCamera = "1.5.1" androidxCamera = "1.5.2"
androidxCollection = "1.5.0" androidxCollection = "1.5.0"
kotlinStdlib = "2.2.21" kotlinStdlib = "2.3.0"
kotlinTest = "2.2.20" kotlinTest = "2.2.20"
core = "1.7.0" core = "1.7.0"
mavenPublish = "0.35.0" mavenPublish = "0.35.0"
@@ -47,7 +47,7 @@ object Merkle {
// left.ops[OpAppend(right.msg)] = right_prepend_stamp // left.ops[OpAppend(right.msg)] = right_prepend_stamp
// leftAppendStamp = left.ops.add(OpAppend(right.msg)) // leftAppendStamp = left.ops.add(OpAppend(right.msg))
// Timestamp leftPrependStamp = left.add(new 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()) // return rightPrependStamp.ops.add(unaryOpCls())
val res = rightPrependStamp.add(OpSHA256()) val res = rightPrependStamp.add(OpSHA256())
@@ -453,12 +453,12 @@ class Timestamp(
fun allTips(): MutableSet<ByteArray?> { fun allTips(): MutableSet<ByteArray?> {
val set: MutableSet<ByteArray?> = HashSet<ByteArray?>() val set: MutableSet<ByteArray?> = HashSet<ByteArray?>()
if (this.ops.size == 0) { if (this.ops.isEmpty()) {
set.add(this.digest) set.add(this.digest)
} }
for (entry in this.ops.entries) { for (entry in this.ops.entries) {
val ts: Timestamp = entry.value!! val ts: Timestamp = entry.value
// Op op = entry.getKey(); // Op op = entry.getKey();
val subSet = ts.allTips() val subSet = ts.allTips()
@@ -21,6 +21,7 @@
package com.vitorpamplona.quartz.nip10Notes.tags package com.vitorpamplona.quartz.nip10Notes.tags
import com.vitorpamplona.quartz.nip01Core.tags.events.ETag 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 * 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 * 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. * to goes last. The order for any other tag does not matter, so keep the relative order.
*/ */
fun List<String>.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<ETag>.positionalMarkedTags( fun List<ETag>.positionalMarkedTags(
root: ETag?, root: ETag?,
replyingTo: ETag?, replyingTo: ETag?,
forkedFrom: ETag?, forkedFrom: ETag?,
) = sortedWith { o1, o2 -> ): List<GenericETag> =
when { sortedWith { o1, o2 ->
o1.eventId == o2.eventId -> 0 when {
o1.eventId == root?.eventId -> -1 // root goes first o1.eventId == o2.eventId -> 0
o2.eventId == root?.eventId -> 1 // root goes first o1.eventId == root?.eventId -> -1 // root goes first
o1.eventId == replyingTo?.eventId -> 1 // reply event being responded to goes last o2.eventId == root?.eventId -> 1 // root goes first
o2.eventId == replyingTo?.eventId -> -1 // reply event being responded to goes last o1.eventId == replyingTo?.eventId -> 1 // reply event being responded to goes last
else -> 0 // keep the relative order for any other tag 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
}
}
@@ -69,7 +69,7 @@ open class BaseDMGroupEvent(
return result 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() override fun groupMembers() = recipientsPubKey().plus(pubKey).toSet()
@@ -23,7 +23,7 @@ package com.vitorpamplona.quartz.nip17Dm.base
import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.core.HexKey
interface NIP17Group { interface NIP17Group {
fun isIncluded(pubKey: HexKey): Boolean fun isIncluded(user: HexKey): Boolean
fun groupMembers(): Set<HexKey> fun groupMembers(): Set<HexKey>
} }
@@ -70,7 +70,7 @@ class ChannelMetadataEvent(
if (content.isEmpty() || !content.startsWith("{") || isEncrypted()) { if (content.isEmpty() || !content.startsWith("{") || isEncrypted()) {
ChannelDataNorm() ChannelDataNorm()
} else { } else {
ChannelData.parse(content).normalize() ?: ChannelDataNorm() ChannelData.parse(content).normalize()
} }
} catch (e: Exception) { } catch (e: Exception) {
if (e is CancellationException) throw e if (e is CancellationException) throw e
@@ -57,7 +57,7 @@ class EventDeserializerTest {
val templateJson = """{"kind":1,"content":"This is an unsigned event.","created_at":1234,"tags":[]}""" val templateJson = """{"kind":1,"content":"This is an unsigned event.","created_at":1234,"tags":[]}"""
val template = EventTemplate.fromJson(templateJson) val template = EventTemplate.fromJson(templateJson)
val signedEvent = signer.signerSync.sign(template)!! val signedEvent = signer.signerSync.sign(template)
assertTrue(signedEvent.id.isNotEmpty()) assertTrue(signedEvent.id.isNotEmpty())
assertTrue(signedEvent.sig.isNotEmpty()) assertTrue(signedEvent.sig.isNotEmpty())
@@ -107,8 +107,8 @@ class NIP19ParserTest {
assertNotNull(actual) assertNotNull(actual)
assertTrue(actual?.entity is NProfile) assertTrue(actual?.entity is NProfile)
assertEquals("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c", (actual?.entity as? NProfile)?.hex) assertEquals("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c", actual.entity.hex)
assertEquals(NormalizedRelayUrl("wss://vitor.nostr1.com/"), (actual?.entity as? NProfile)?.relay?.first()) assertEquals(NormalizedRelayUrl("wss://vitor.nostr1.com/"), actual.entity.relay?.first())
} }
@Test() @Test()
@@ -116,7 +116,7 @@ class NIP19ParserTest {
val actual = Nip19Parser.uriToRoute("nostr:nprofile1qy2hwumn8ghj7un9d3shjtnyv9kh2uewd9hj7qgwwaehxw309ahx7uewd3hkctcpr9mhxue69uhhyetvv9ujuumwdae8gtnnda3kjctv9uqzq9thu3vem5gvsc6f3l3uyz7c92h6lq56t9wws0zulzkrgc6nrvym5jfztf") val actual = Nip19Parser.uriToRoute("nostr:nprofile1qy2hwumn8ghj7un9d3shjtnyv9kh2uewd9hj7qgwwaehxw309ahx7uewd3hkctcpr9mhxue69uhhyetvv9ujuumwdae8gtnnda3kjctv9uqzq9thu3vem5gvsc6f3l3uyz7c92h6lq56t9wws0zulzkrgc6nrvym5jfztf")
assertTrue(actual?.entity is NProfile) assertTrue(actual?.entity is NProfile)
assertEquals("1577e4599dd10c863498fe3c20bd82aafaf829a595ce83c5cf8ac3463531b09b", (actual?.entity as? NProfile)?.hex) assertEquals("1577e4599dd10c863498fe3c20bd82aafaf829a595ce83c5cf8ac3463531b09b", actual.entity.hex)
} }
@Test() @Test()
@@ -124,7 +124,7 @@ class NIP19ParserTest {
val actual = Nip19Parser.uriToRoute("nostr:nevent1qy2hwumn8ghj7un9d3shjtnyv9kh2uewd9hj7qgwwaehxw309ahx7uewd3hkctcpr9mhxue69uhhyetvv9ujuumwdae8gtnnda3kjctv9uq36amnwvaz7tmjv4kxz7fwvd5xjcmpvahhqmr9vfejucm0d5hsz9mhwden5te0wfjkccte9ec8y6tdv9kzumn9wshsz8thwden5te0dehhxarj9ekh2arfdeuhwctvd3jhgtnrdakj7qg3waehxw309ucngvpwvcmh5tnfduhszythwden5te0dehhxarj9emkjmn99uq3jamnwvaz7tmhv4kxxmmdv5hxummnw3ezuamfdejj7qpqvsup5xk3e2quedxjvn2gjppc0lqny5dmnr2ypc9tftwmdxta0yjqrd6n50") val actual = Nip19Parser.uriToRoute("nostr:nevent1qy2hwumn8ghj7un9d3shjtnyv9kh2uewd9hj7qgwwaehxw309ahx7uewd3hkctcpr9mhxue69uhhyetvv9ujuumwdae8gtnnda3kjctv9uq36amnwvaz7tmjv4kxz7fwvd5xjcmpvahhqmr9vfejucm0d5hsz9mhwden5te0wfjkccte9ec8y6tdv9kzumn9wshsz8thwden5te0dehhxarj9ekh2arfdeuhwctvd3jhgtnrdakj7qg3waehxw309ucngvpwvcmh5tnfduhszythwden5te0dehhxarj9emkjmn99uq3jamnwvaz7tmhv4kxxmmdv5hxummnw3ezuamfdejj7qpqvsup5xk3e2quedxjvn2gjppc0lqny5dmnr2ypc9tftwmdxta0yjqrd6n50")
assertTrue(actual?.entity is NEvent) assertTrue(actual?.entity is NEvent)
assertEquals("64381a1ad1ca81ccb4d264d48904387fc13251bb98d440e0ab4addb6997d7924", (actual?.entity as? NEvent)?.hex) assertEquals("64381a1ad1ca81ccb4d264d48904387fc13251bb98d440e0ab4addb6997d7924", actual.entity.hex)
} }
@Test() @Test()
@@ -132,7 +132,7 @@ class NIP19ParserTest {
val actual = Nip19Parser.uriToRoute("nostr:naddr1qqyxzmt9w358jum5qyt8wumn8ghj7un9d3shjtnwdaehgu3wvfskueqzypd7v3r24z33cydnk3fmlrd0exe5dlej3506zxs05q4puerp765mzqcyqqq8scsq6mk7u") val actual = Nip19Parser.uriToRoute("nostr:naddr1qqyxzmt9w358jum5qyt8wumn8ghj7un9d3shjtnwdaehgu3wvfskueqzypd7v3r24z33cydnk3fmlrd0exe5dlej3506zxs05q4puerp765mzqcyqqq8scsq6mk7u")
assertTrue(actual?.entity is NAddress) assertTrue(actual?.entity is NAddress)
assertEquals("30818:5be6446aa8a31c11b3b453bf8dafc9b346ff328d1fa11a0fa02a1e6461f6a9b1:amethyst", (actual?.entity as? NAddress)?.aTag()) assertEquals("30818:5be6446aa8a31c11b3b453bf8dafc9b346ff328d1fa11a0fa02a1e6461f6a9b1:amethyst", actual.entity.aTag())
} }
@Test @Test
@@ -141,9 +141,10 @@ class NIP19ParserTest {
Nip19Parser.uriToRoute( Nip19Parser.uriToRoute(
"nostr:naddr1qqqqygzxpsj7dqha57pjk5k37gkn6g4nzakewtmqmnwryyhd3jfwlpgxtspsgqqqw4rs3xyxus", "nostr:naddr1qqqqygzxpsj7dqha57pjk5k37gkn6g4nzakewtmqmnwryyhd3jfwlpgxtspsgqqqw4rs3xyxus",
) )
assertNotNull(result)
assertEquals( assertEquals(
"30023:460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c:", "30023:460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c:",
(result?.entity as? NAddress)?.aTag(), (result.entity as? NAddress)?.aTag(),
) )
} }
@@ -153,9 +154,10 @@ class NIP19ParserTest {
Nip19Parser.uriToRoute( Nip19Parser.uriToRoute(
"nostr:naddr1qqqqzxthwden5te0wfjkccte9ejxjanfdejjuanfv3jk7tczyrv4428upmlcujyf2fy4hqrynywj07ukakr99ufvmmw95n5tttj5qqcyqqqgt0qeresua", "nostr:naddr1qqqqzxthwden5te0wfjkccte9ejxjanfdejjuanfv3jk7tczyrv4428upmlcujyf2fy4hqrynywj07ukakr99ufvmmw95n5tttj5qqcyqqqgt0qeresua",
) )
assertNotNull(result)
assertEquals( assertEquals(
"34236:d95aa8fc0eff8e488952495b8064991d27fb96ed8652f12cdedc5a4e8b5ae540:", "34236:d95aa8fc0eff8e488952495b8064991d27fb96ed8652f12cdedc5a4e8b5ae540:",
(result?.entity as? NAddress)?.aTag(), (result.entity as? NAddress)?.aTag(),
) )
} }
@@ -165,9 +167,10 @@ class NIP19ParserTest {
Nip19Parser.uriToRoute( Nip19Parser.uriToRoute(
"nostr:naddr1qq8kwatfv3jj6amfwfjkwatpwfjqygxsm6lelvfda7qlg0tud9pfhduysy4vrexj65azqtdk4tr75j6xdspsgqqqw4rsg32ag8", "nostr:naddr1qq8kwatfv3jj6amfwfjkwatpwfjqygxsm6lelvfda7qlg0tud9pfhduysy4vrexj65azqtdk4tr75j6xdspsgqqqw4rsg32ag8",
) )
assertNotNull(result)
assertEquals( assertEquals(
"30023:d0debf9fb12def81f43d7c69429bb784812ac1e4d2d53a202db6aac7ea4b466c:guide-wireguard", "30023:d0debf9fb12def81f43d7c69429bb784812ac1e4d2d53a202db6aac7ea4b466c:guide-wireguard",
(result?.entity as? NAddress)?.aTag(), (result.entity as? NAddress)?.aTag(),
) )
} }
@@ -177,12 +180,13 @@ class NIP19ParserTest {
Nip19Parser.uriToRoute( Nip19Parser.uriToRoute(
"naddr1qqyrswtyv5mnjv3sqy28wumn8ghj7un9d3shjtnyv9kh2uewd9hsygx3uczxts4hwue9ayfn7ggq62anzstde2qs749pm9tx2csuthhpjvpsgqqqw4rs8pmj38", "naddr1qqyrswtyv5mnjv3sqy28wumn8ghj7un9d3shjtnyv9kh2uewd9hsygx3uczxts4hwue9ayfn7ggq62anzstde2qs749pm9tx2csuthhpjvpsgqqqw4rs8pmj38",
) )
assertTrue(result?.entity is NAddress) assertNotNull(result)
assertTrue(result.entity is NAddress)
assertEquals( assertEquals(
"30023:d1e60465c2b777325e9133f2100d2bb31416dca810f54a1d95665621c5dee193:89de7920", "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 @Test
@@ -261,11 +265,11 @@ class NIP19ParserTest {
assertNotNull(result) assertNotNull(result)
assertEquals( assertEquals(
"31337:27241bb702d145a975260cfedee6265936dcd939eaecb88ea0e4071752c30402:xx1xulrf7wdbdlbc31far", "31337:27241bb702d145a975260cfedee6265936dcd939eaecb88ea0e4071752c30402:xx1xulrf7wdbdlbc31far",
result?.aTag(), result.aTag(),
) )
assertEquals(true, result?.relay?.isEmpty()) assertEquals(true, result.relay?.isEmpty())
assertEquals("27241bb702d145a975260cfedee6265936dcd939eaecb88ea0e4071752c30402", result?.author) assertEquals("27241bb702d145a975260cfedee6265936dcd939eaecb88ea0e4071752c30402", result.author)
assertEquals(31337, result?.kind) assertEquals(31337, result.kind)
} }
@Test @Test
@@ -279,11 +283,11 @@ class NIP19ParserTest {
assertNotNull(result) assertNotNull(result)
assertEquals( assertEquals(
"30023:46fcbe3065eaf1ae7811465924e48923363ff3f526bd6f73d7c184b16bd8ce4d:613f014d2911fb9df52e048aae70268c0d216790287b5814910e1e781e8e0509", "30023:46fcbe3065eaf1ae7811465924e48923363ff3f526bd6f73d7c184b16bd8ce4d:613f014d2911fb9df52e048aae70268c0d216790287b5814910e1e781e8e0509",
result?.aTag(), result.aTag(),
) )
assertEquals(true, result?.relay?.isEmpty()) assertEquals(true, result.relay?.isEmpty())
assertEquals("46fcbe3065eaf1ae7811465924e48923363ff3f526bd6f73d7c184b16bd8ce4d", result?.author) assertEquals("46fcbe3065eaf1ae7811465924e48923363ff3f526bd6f73d7c184b16bd8ce4d", result.author)
assertEquals(30023, result?.kind) assertEquals(30023, result.kind)
} }
@Test @Test
@@ -297,11 +301,11 @@ class NIP19ParserTest {
assertNotNull(result) assertNotNull(result)
assertEquals( assertEquals(
"30023:46fcbe3065eaf1ae7811465924e48923363ff3f526bd6f73d7c184b16bd8ce4d:1679509418", "30023:46fcbe3065eaf1ae7811465924e48923363ff3f526bd6f73d7c184b16bd8ce4d:1679509418",
result?.aTag(), result.aTag(),
) )
assertEquals(true, result?.relay?.isEmpty()) assertEquals(true, result.relay?.isEmpty())
assertEquals("46fcbe3065eaf1ae7811465924e48923363ff3f526bd6f73d7c184b16bd8ce4d", result?.author) assertEquals("46fcbe3065eaf1ae7811465924e48923363ff3f526bd6f73d7c184b16bd8ce4d", result.author)
assertEquals(30023, result?.kind) assertEquals(30023, result.kind)
} }
@Test @Test
@@ -310,10 +314,10 @@ class NIP19ParserTest {
Nip19Parser.uriToRoute("nostr:nevent1qqsdw6xpk28tjnrajz4xhy2jqg0md8ywxj6997rsutjzxs0207tedjspz4mhxue69uhhyetvv9ujumn0wd68ytnzvuhsygx2crjrydvqdksffurc0fdsfc566pxtrg78afw0v8kursecwdqg9vpsgqqqqqqsnknas6")?.entity as? NEvent Nip19Parser.uriToRoute("nostr:nevent1qqsdw6xpk28tjnrajz4xhy2jqg0md8ywxj6997rsutjzxs0207tedjspz4mhxue69uhhyetvv9ujumn0wd68ytnzvuhsygx2crjrydvqdksffurc0fdsfc566pxtrg78afw0v8kursecwdqg9vpsgqqqqqqsnknas6")?.entity as? NEvent
assertNotNull(result) assertNotNull(result)
assertEquals("d768c1b28eb94c7d90aa6b9152021fb69c8e34b452f870e2e42341ea7f9796ca", result?.hex) assertEquals("d768c1b28eb94c7d90aa6b9152021fb69c8e34b452f870e2e42341ea7f9796ca", result.hex)
assertEquals("wss://relay.nostr.bg/", result?.relay?.firstOrNull()?.url) assertEquals("wss://relay.nostr.bg/", result.relay.firstOrNull()?.url)
assertEquals("cac0e43235806da094f0787a5b04e29ad04cb1a3c7ea5cf61edc1c338734082b", result?.author) assertEquals("cac0e43235806da094f0787a5b04e29ad04cb1a3c7ea5cf61edc1c338734082b", result.author)
assertEquals(1, result?.kind) assertEquals(1, result.kind)
} }
@Test @Test
@@ -322,10 +326,10 @@ class NIP19ParserTest {
Nip19Parser.uriToRoute("nostr:nevent1qqs0tsw8hjacs4fppgdg7f5yhgwwfkyua4xcs3re9wwkpkk2qeu6mhql22rcy")?.entity as? NEvent Nip19Parser.uriToRoute("nostr:nevent1qqs0tsw8hjacs4fppgdg7f5yhgwwfkyua4xcs3re9wwkpkk2qeu6mhql22rcy")?.entity as? NEvent
assertNotNull(result) assertNotNull(result)
assertEquals("f5c1c7bcbb8855210a1a8f2684ba1ce4d89ced4d8844792b9d60daca0679addc", result?.hex) assertEquals("f5c1c7bcbb8855210a1a8f2684ba1ce4d89ced4d8844792b9d60daca0679addc", result.hex)
assertEquals(true, result?.relay?.isEmpty()) assertEquals(true, result.relay.isEmpty())
assertEquals(null, result?.author) assertEquals(null, result.author)
assertEquals(null, result?.kind) assertEquals(null, result.kind)
} }
@Test @Test
@@ -334,10 +338,10 @@ class NIP19ParserTest {
Nip19Parser.uriToRoute("nostr:nevent1qqsfvaa2w3nkw472lt2ezr6x5x347k8hht398vp7hrl6wrdjldry86sprfmhxue69uhhyetvv9ujuam9wd6x2unwvf6xxtnrdaks5myyah")?.entity as? NEvent Nip19Parser.uriToRoute("nostr:nevent1qqsfvaa2w3nkw472lt2ezr6x5x347k8hht398vp7hrl6wrdjldry86sprfmhxue69uhhyetvv9ujuam9wd6x2unwvf6xxtnrdaks5myyah")?.entity as? NEvent
assertNotNull(result) assertNotNull(result)
assertEquals("9677aa74676757cafad5910f46a1a35f58f7bae253b03eb8ffa70db2fb4643ea", result?.hex) assertEquals("9677aa74676757cafad5910f46a1a35f58f7bae253b03eb8ffa70db2fb4643ea", result.hex)
assertEquals("wss://relay.westernbtc.com/", result?.relay?.firstOrNull()?.url) assertEquals("wss://relay.westernbtc.com/", result.relay.firstOrNull()?.url)
assertEquals(null, result?.author) assertEquals(null, result.author)
assertEquals(null, result?.kind) assertEquals(null, result.kind)
} }
@Test @Test
@@ -349,13 +353,13 @@ class NIP19ParserTest {
)?.entity as? NEvent )?.entity as? NEvent
assertNotNull(result) assertNotNull(result)
assertEquals("b60ffa7256d3dd7543d830eb717ae50d05a6c32c5f791ed15b867c2bb0b954ac", result?.hex) assertEquals("b60ffa7256d3dd7543d830eb717ae50d05a6c32c5f791ed15b867c2bb0b954ac", result.hex)
assertEquals( assertEquals(
NormalizedRelayUrl("wss://nostr.mom/"), NormalizedRelayUrl("wss://nostr.mom/"),
result?.relay?.get(0), result.relay?.get(0),
) )
assertEquals("f8ff11c7a7d3478355d3b4d174e5a473797a906ea4aa61aa9b6bc0652c1ea17a", result?.author) assertEquals("f8ff11c7a7d3478355d3b4d174e5a473797a906ea4aa61aa9b6bc0652c1ea17a", result.author)
assertEquals(1, result?.kind) assertEquals(1, result.kind)
} }
@Test @Test
@@ -367,10 +371,10 @@ class NIP19ParserTest {
)?.entity as? NEvent )?.entity as? NEvent
assertNotNull(result) assertNotNull(result)
assertEquals("1f878e82063d80f41a781d3a2ef7bc336f1beb7942bf3b49b42aee1251eb5cf0", result?.hex) assertEquals("1f878e82063d80f41a781d3a2ef7bc336f1beb7942bf3b49b42aee1251eb5cf0", result.hex)
assertEquals(NormalizedRelayUrl("wss://relay.damus.io/"), result.relay.get(0)) assertEquals(NormalizedRelayUrl("wss://relay.damus.io/"), result.relay[0])
assertEquals("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c", result?.author) assertEquals("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c", result.author)
assertEquals(1, result?.kind) assertEquals(1, result.kind)
} }
@Test @Test
@@ -382,10 +386,10 @@ class NIP19ParserTest {
)?.entity as? NEvent )?.entity as? NEvent
assertNotNull(result) assertNotNull(result)
assertEquals("8d2338bb62db88d13cea23f55f27c4886f68cf777dac42f2b65e6f709a5e6926", result?.hex) assertEquals("8d2338bb62db88d13cea23f55f27c4886f68cf777dac42f2b65e6f709a5e6926", result.hex)
assertEquals( assertEquals(
"wss://nos.lol/,wss://nostr.oxtr.dev/,wss://relay.nostr.bg/,wss://nostr.einundzwanzig.space/,wss://relay.nostr.band/,wss://relay.damus.io/", "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 )?.entity as? NEvent
assertNotNull(result) assertNotNull(result)
assertEquals("4300ec7fa2f98a276f033908349651620aa8e282b76030ab22abca63e85e07e6", result?.hex) assertEquals("4300ec7fa2f98a276f033908349651620aa8e282b76030ab22abca63e85e07e6", result.hex)
assertEquals("wss://relay.damus.io/", result?.relay?.get(0)?.url) assertEquals("wss://relay.damus.io/", result.relay.get(0)?.url)
assertEquals("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c", result?.author) assertEquals("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c", result.author)
assertEquals(1, result?.kind) assertEquals(1, result.kind)
} }
@Test @Test
@@ -22,6 +22,7 @@ package com.vitorpamplona.quartz.nip46RemoteSigner
import com.vitorpamplona.quartz.nip01Core.core.OptimizedJsonMapper import com.vitorpamplona.quartz.nip01Core.core.OptimizedJsonMapper
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue import kotlin.test.assertTrue
class BunkerRequestTest { class BunkerRequestTest {
@@ -31,6 +32,6 @@ class BunkerRequestTest {
val bunkerRequest = OptimizedJsonMapper.fromJsonTo<BunkerRequest>(requestJson) val bunkerRequest = OptimizedJsonMapper.fromJsonTo<BunkerRequest>(requestJson)
assertTrue(bunkerRequest is BunkerRequestSign) assertTrue(bunkerRequest is BunkerRequestSign)
assertTrue((bunkerRequest as BunkerRequestSign).event.kind == 1) assertEquals(1, bunkerRequest.event.kind)
} }
} }