diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/search/PartialTokensTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/search/PartialTokensTest.kt index acaca77d15..c631249285 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/search/PartialTokensTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/search/PartialTokensTest.kt @@ -38,7 +38,7 @@ class PartialTokensTest { fun aHalfWrittenFromOpensThePeoplePicker() { val picker = pickerAtEnd("zaps from:ali") assertTrue(picker is ActivePicker.People) - assertEquals(KeyField.FROM, (picker as ActivePicker.People).keyField) + assertEquals(KeyField.FROM, picker.keyField) assertEquals("ali", picker.token.partial) assertEquals(5, picker.token.start) } @@ -65,7 +65,7 @@ class PartialTokensTest { fun aHalfWrittenDateOpensTheCalendar() { val picker = pickerAtEnd("since:2026-0") assertTrue(picker is ActivePicker.Calendar) - assertEquals(DateField.SINCE, (picker as ActivePicker.Calendar).dateField) + assertEquals(DateField.SINCE, picker.dateField) } @Test diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotPublishBeforeApplyTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotPublishBeforeApplyTest.kt index d84c56ca69..c63f506200 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotPublishBeforeApplyTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotPublishBeforeApplyTest.kt @@ -461,9 +461,9 @@ class MarmotPublishBeforeApplyTest { override suspend fun saveRetainedEpochs( nostrGroupId: String, - epochs: List, + retainedSecrets: List, ) { - retained[nostrGroupId] = epochs + retained[nostrGroupId] = retainedSecrets } override suspend fun loadRetainedEpochs(nostrGroupId: String): List = retained[nostrGroupId] ?: emptyList() diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotPublishDurabilityTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotPublishDurabilityTest.kt index e85afc40ca..e06891794c 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotPublishDurabilityTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotPublishDurabilityTest.kt @@ -105,9 +105,9 @@ class MarmotPublishDurabilityTest { override suspend fun saveRetainedEpochs( nostrGroupId: String, - epochs: List, + retainedSecrets: List, ) { - retained[nostrGroupId] = epochs + retained[nostrGroupId] = retainedSecrets } override suspend fun loadRetainedEpochs(nostrGroupId: String): List = retained[nostrGroupId].orEmpty() diff --git a/marmotBench/src/main/kotlin/com/vitorpamplona/marmotbench/MarmotBenchmarks.kt b/marmotBench/src/main/kotlin/com/vitorpamplona/marmotbench/MarmotBenchmarks.kt index bf5f68f7fe..7a030c58d4 100644 --- a/marmotBench/src/main/kotlin/com/vitorpamplona/marmotbench/MarmotBenchmarks.kt +++ b/marmotBench/src/main/kotlin/com/vitorpamplona/marmotbench/MarmotBenchmarks.kt @@ -24,12 +24,10 @@ import com.vitorpamplona.amethyst.commons.marmot.MarmotManager import com.vitorpamplona.amethyst.commons.marmot.ingest import com.vitorpamplona.quartz.marmot.appComponents.GroupProfileV1 import com.vitorpamplona.quartz.marmot.mip00KeyPackages.KeyPackageEvent -import com.vitorpamplona.quartz.marmot.mip03GroupMessages.GroupEvent 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.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.utils.RandomInstance import kotlinx.coroutines.runBlocking @@ -170,7 +168,7 @@ fun benchJoinWelcome(): BenchResult = } }, ) { (bob, wrap) -> - runBlocking { bob.manager.ingest(wrap as GiftWrapEvent) } + runBlocking { bob.manager.ingest(wrap) } } /** @@ -223,7 +221,7 @@ fun benchIngestAppMessage(members: Int): BenchResult = } }, ) { (bob, event) -> - runBlocking { bob.manager.ingest(event as GroupEvent) } + runBlocking { bob.manager.ingest(event) } } private const val BENCH_RELAY = "wss://bench.invalid" diff --git a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/Nip46Test.kt b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/Nip46Test.kt index 33adaa8851..57c0aa4b8b 100644 --- a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/Nip46Test.kt +++ b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/Nip46Test.kt @@ -56,6 +56,10 @@ internal class Nip46Test { sig = "ec39e60722a083cccbd2d82d2827e13f5499fa7cbcedac5b76011a844c077473adb629d50d01fab147835ac6c8a3d5ba9aaddd87d6723f0c3c864b9119fc4356", ) + // The round trip is only type-safe by construction: the caller hands in a T, + // the message is encoded and decoded, and the decoder returns the same + // BunkerMessage subtype. The runtime has no way to check that. + @Suppress("UNCHECKED_CAST") suspend fun encodeDecodeEvent(req: T): T { val eventStr = NostrConnectEvent.create(req, remoteKey.pubKey, signer).toJson() diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/auth/AuthOutcomeTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/auth/AuthOutcomeTest.kt index 192b013387..af50790016 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/auth/AuthOutcomeTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/auth/AuthOutcomeTest.kt @@ -61,7 +61,7 @@ class AuthOutcomeTest { phase: RelayAuthSnapshot.Phase, successCount: Int = 0, ) { - state.value = state.value.put(relay, RelayAuthSnapshot(phase, null, successCount)) + state.value = state.value.putting(relay, RelayAuthSnapshot(phase, null, successCount)) } } diff --git a/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/marmot/mip00KeyPackages/LastResortKeyPackageReuseTest.kt b/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/marmot/mip00KeyPackages/LastResortKeyPackageReuseTest.kt index b9feeeca5a..403aa6e217 100644 --- a/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/marmot/mip00KeyPackages/LastResortKeyPackageReuseTest.kt +++ b/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/marmot/mip00KeyPackages/LastResortKeyPackageReuseTest.kt @@ -245,8 +245,8 @@ class LastResortKeyPackageReuseTest { override suspend fun load(): ByteArray? = bytes - override suspend fun save(data: ByteArray) { - bytes = data + override suspend fun save(snapshot: ByteArray) { + bytes = snapshot } override suspend fun delete() { diff --git a/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/prodbench/InternTradeoffBenchmark.kt b/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/prodbench/InternTradeoffBenchmark.kt index 9095a17bcf..7a2992d0ce 100644 --- a/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/prodbench/InternTradeoffBenchmark.kt +++ b/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/prodbench/InternTradeoffBenchmark.kt @@ -110,10 +110,16 @@ class InternTradeoffBenchmark { } } + /** + * Holds the last measured corpus so the JIT cannot drop the allocations we + * just paid for. A field rather than a local: a local's assignments are + * visible to the compiler's data flow, which then folds the `check` below + * into a constant. + */ + private var sink: Any? = null + @Test fun internCostAndBenefit() { - var sink: Any? = null - println("\n=== corpus: $EVENTS events, $AUTHORS authors, $RELAYS relays ===") // ---- memory ---- diff --git a/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip50Search/IndexableContentGoldenTest.kt b/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip50Search/IndexableContentGoldenTest.kt index 8f44b686cb..8cfa6fef3c 100644 --- a/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip50Search/IndexableContentGoldenTest.kt +++ b/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip50Search/IndexableContentGoldenTest.kt @@ -131,7 +131,7 @@ class IndexableContentGoldenTest { } } val rejoined = visited.joinToString(event.indexableSeparator()) - if (rejoined == event.indexableContent()) null else "kind $kind: visitor=${rejoined.take(120)!!} content=${event.indexableContent().take(120)}" + if (rejoined == event.indexableContent()) null else "kind $kind: visitor=${rejoined.take(120)} content=${event.indexableContent().take(120)}" } assertEquals("visitor and indexed content disagree", emptyList(), disagreements) } diff --git a/quic/interop/src/main/kotlin/com/vitorpamplona/quic/interop/runner/Http3GetClient.kt b/quic/interop/src/main/kotlin/com/vitorpamplona/quic/interop/runner/Http3GetClient.kt index c1a20bed55..929b2ef6c4 100644 --- a/quic/interop/src/main/kotlin/com/vitorpamplona/quic/interop/runner/Http3GetClient.kt +++ b/quic/interop/src/main/kotlin/com/vitorpamplona/quic/interop/runner/Http3GetClient.kt @@ -203,9 +203,7 @@ class Http3GetClient( body += frame.body } - else -> { - Unit - } + else -> {} } } }