mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-08 23:54:39 +00:00
Fixes warnings
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
/.idea/deviceManager.xml
|
||||
/.idea/inspectionProfiles/
|
||||
/.idea/migrations.xml
|
||||
/.idea/planningMode.xml
|
||||
/desktopApp/vlc-temp/
|
||||
/commons/.idea/gradle.xml
|
||||
/commons/.idea/misc.xml
|
||||
|
||||
+22
-15
@@ -32,6 +32,7 @@ import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent
|
||||
import com.vitorpamplona.quartz.nip40Expiration.isExpired
|
||||
import com.vitorpamplona.quartz.utils.Log
|
||||
import com.vitorpamplona.quartz.utils.flattenToSet
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
@@ -53,11 +54,13 @@ class LargeDBInsertBenchmark : BaseLargeCacheBenchmark() {
|
||||
runWithMeasurementDisabled {
|
||||
EventStore(null)
|
||||
}
|
||||
firstThousandEvents.forEach { event ->
|
||||
try {
|
||||
db.insert(event)
|
||||
} catch (e: SQLiteException) {
|
||||
Log.w("LargeDBInsertBenchmark") { "Error inserting event: ${e.message} for event: ${event.toJson()}" }
|
||||
runBlocking {
|
||||
firstThousandEvents.forEach { event ->
|
||||
try {
|
||||
db.insert(event)
|
||||
} catch (e: SQLiteException) {
|
||||
Log.w("LargeDBInsertBenchmark") { "Error inserting event: ${e.message} for event: ${event.toJson()}" }
|
||||
}
|
||||
}
|
||||
}
|
||||
runWithMeasurementDisabled {
|
||||
@@ -83,21 +86,25 @@ class LargeDBInsertBenchmark : BaseLargeCacheBenchmark() {
|
||||
runWithMeasurementDisabled {
|
||||
val db =
|
||||
EventStore(null)
|
||||
toBeDeletedEvents.forEach { event ->
|
||||
try {
|
||||
db.insert(event)
|
||||
} catch (e: SQLiteException) {
|
||||
Log.w("LargeDBInsertBenchmark") { "Error inserting event: ${e.message} for event: ${event.toJson()}" }
|
||||
runBlocking {
|
||||
toBeDeletedEvents.forEach { event ->
|
||||
try {
|
||||
db.insert(event)
|
||||
} catch (e: SQLiteException) {
|
||||
Log.w("LargeDBInsertBenchmark") { "Error inserting event: ${e.message} for event: ${event.toJson()}" }
|
||||
}
|
||||
}
|
||||
}
|
||||
db
|
||||
}
|
||||
|
||||
deletions.forEach { event ->
|
||||
try {
|
||||
db.insert(event)
|
||||
} catch (e: SQLiteException) {
|
||||
Log.w("LargeDBInsertBenchmark") { "Error inserting event: ${e.message} for event: $event" }
|
||||
runBlocking {
|
||||
deletions.forEach { event ->
|
||||
try {
|
||||
db.insert(event)
|
||||
} catch (e: SQLiteException) {
|
||||
Log.w("LargeDBInsertBenchmark") { "Error inserting event: ${e.message} for event: $event" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+58
-42
@@ -34,6 +34,7 @@ import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent
|
||||
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
|
||||
import com.vitorpamplona.quartz.utils.Log
|
||||
import junit.framework.TestCase.assertEquals
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
@@ -52,19 +53,20 @@ class LargeDBQueryingBenchmark : BaseLargeCacheBenchmark() {
|
||||
lateinit var db: com.vitorpamplona.quartz.nip01Core.store.sqlite.EventStore
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
fun setup() =
|
||||
runBlocking {
|
||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
|
||||
context.deleteDatabase("allEvents.db")
|
||||
db = EventStore("allEvents.db")
|
||||
allEvents.forEach { event ->
|
||||
try {
|
||||
db.insert(event)
|
||||
} catch (e: SQLiteException) {
|
||||
Log.w("LargeDBQueryingBenchmark") { "Error inserting event: ${e.message} for event: ${event.toJson()}" }
|
||||
context.deleteDatabase("allEvents.db")
|
||||
db = EventStore("allEvents.db")
|
||||
allEvents.forEach { event ->
|
||||
try {
|
||||
db.insert(event)
|
||||
} catch (e: SQLiteException) {
|
||||
Log.w("LargeDBQueryingBenchmark") { "Error inserting event: ${e.message} for event: ${event.toJson()}" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
@@ -76,30 +78,36 @@ class LargeDBQueryingBenchmark : BaseLargeCacheBenchmark() {
|
||||
@Test
|
||||
fun benchQuerying1000Events() {
|
||||
benchmarkRule.measureRepeated {
|
||||
db.query<Event>(Filter(limit = 1000))
|
||||
runBlocking {
|
||||
db.query<Event>(Filter(limit = 1000))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun benchQuerying1614GiftWrapsEvents() {
|
||||
benchmarkRule.measureRepeated {
|
||||
db.query<GiftWrapEvent>(
|
||||
Filter(
|
||||
kinds = listOf(GiftWrapEvent.KIND),
|
||||
tags = mapOf("p" to listOf("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c")),
|
||||
),
|
||||
)
|
||||
runBlocking {
|
||||
db.query<GiftWrapEvent>(
|
||||
Filter(
|
||||
kinds = listOf(GiftWrapEvent.KIND),
|
||||
tags = mapOf("p" to listOf("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c")),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun benchQueryingEventsByAuthor() {
|
||||
benchmarkRule.measureRepeated {
|
||||
db.query<Event>(
|
||||
Filter(
|
||||
authors = listOf("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c"),
|
||||
),
|
||||
)
|
||||
runBlocking {
|
||||
db.query<Event>(
|
||||
Filter(
|
||||
authors = listOf("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c"),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,12 +115,14 @@ class LargeDBQueryingBenchmark : BaseLargeCacheBenchmark() {
|
||||
fun benchQueryingMetadataByAuthor() {
|
||||
benchmarkRule.measureRepeated {
|
||||
val result =
|
||||
db.query<MetadataEvent>(
|
||||
Filter(
|
||||
kinds = listOf(MetadataEvent.KIND),
|
||||
authors = listOf("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c"),
|
||||
),
|
||||
)
|
||||
runBlocking {
|
||||
db.query<MetadataEvent>(
|
||||
Filter(
|
||||
kinds = listOf(MetadataEvent.KIND),
|
||||
authors = listOf("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c"),
|
||||
),
|
||||
)
|
||||
}
|
||||
assertEquals(1, result.size)
|
||||
}
|
||||
}
|
||||
@@ -121,12 +131,14 @@ class LargeDBQueryingBenchmark : BaseLargeCacheBenchmark() {
|
||||
fun benchQueryingRelayListByAuthor() {
|
||||
benchmarkRule.measureRepeated {
|
||||
val result =
|
||||
db.query<AdvertisedRelayListEvent>(
|
||||
Filter(
|
||||
kinds = listOf(AdvertisedRelayListEvent.KIND),
|
||||
authors = listOf("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c"),
|
||||
),
|
||||
)
|
||||
runBlocking {
|
||||
db.query<AdvertisedRelayListEvent>(
|
||||
Filter(
|
||||
kinds = listOf(AdvertisedRelayListEvent.KIND),
|
||||
authors = listOf("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c"),
|
||||
),
|
||||
)
|
||||
}
|
||||
assertEquals(0, result.size)
|
||||
}
|
||||
}
|
||||
@@ -134,20 +146,24 @@ class LargeDBQueryingBenchmark : BaseLargeCacheBenchmark() {
|
||||
@Test
|
||||
fun benchQueryingEmptyReturnByTags() {
|
||||
benchmarkRule.measureRepeated {
|
||||
db.query<Event>(
|
||||
Filter(
|
||||
tags = mapOf("p" to listOf("176d972f60dcdc3212ed8c92ef85065c176d972f60dcdc3212ed8c92ef85065c")),
|
||||
),
|
||||
)
|
||||
runBlocking {
|
||||
db.query<Event>(
|
||||
Filter(
|
||||
tags = mapOf("p" to listOf("176d972f60dcdc3212ed8c92ef85065c176d972f60dcdc3212ed8c92ef85065c")),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun benchQueryingEmptyReturnByIds() {
|
||||
benchmarkRule.measureRepeated {
|
||||
db.query<Event>(
|
||||
Filter(ids = listOf("176d972f60dcdc3212ed8c92ef85065c176d972f60dcdc3212ed8c92ef85065c")),
|
||||
)
|
||||
runBlocking {
|
||||
db.query<Event>(
|
||||
Filter(ids = listOf("176d972f60dcdc3212ed8c92ef85065c176d972f60dcdc3212ed8c92ef85065c")),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -61,8 +61,8 @@ class PoWMinerTest {
|
||||
|
||||
val event = signer.sign(template)
|
||||
|
||||
println(event?.toJson())
|
||||
println(event.toJson())
|
||||
|
||||
assertEquals(25, event!!.pow())
|
||||
assertEquals(25, event.pow())
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ class GeolocatedComments {
|
||||
),
|
||||
)
|
||||
|
||||
assertEquals("drt3n", event!!.geohashedScope())
|
||||
assertEquals("drt3n", event.geohashedScope())
|
||||
assertTrue(event.isTaggedScope(GeohashId.toScope("drt3n")))
|
||||
assertFalse(event.isTaggedScope("drt3n"))
|
||||
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ class SignStringTest {
|
||||
assertEquals(expectedValue, signedMessage)
|
||||
|
||||
val message2 = "Hello"
|
||||
val signedMessage2 = signString(message2, keyPair.privKey!!, random).toHexKey()
|
||||
val signedMessage2 = signString(message2, keyPair.privKey, random).toHexKey()
|
||||
val expectedValue2 = "7ec8194a585bfb513564113b6b7bfeaafa0254c99d24eaf92280657c2291bab908b1b7bc553c83276a0254aef5041bbe6a50e93381edc4de3d859efa1c3a5a1e"
|
||||
assertEquals(expectedValue2, signedMessage2)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user