Refactors SHA-256 methods to its own class

This commit is contained in:
Vitor Pamplona
2025-01-06 12:56:57 -05:00
parent 0971b716e1
commit 5f577df819
10 changed files with 54 additions and 62 deletions
@@ -24,7 +24,7 @@ import androidx.benchmark.junit4.BenchmarkRule
import androidx.benchmark.junit4.measureRepeated
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.vitorpamplona.quartz.crypto.CryptoUtils
import com.vitorpamplona.quartz.crypto.sha256Hash
import com.vitorpamplona.quartz.encoders.Nip01Serializer
import com.vitorpamplona.quartz.events.Event
import com.vitorpamplona.quartz.events.EventFactory
@@ -181,12 +181,12 @@ class EventBenchmark {
benchmarkRule.measureRepeated {
// Should pass
assertNotNull(CryptoUtils.sha256(byteArray))
assertNotNull(sha256Hash(byteArray))
}
}
@Test
fun checkIDHashPayload2Slow() {
fun checkIDHashPayload2() {
val event = Event.fromJson(payload2)
benchmarkRule.measureRepeated {
// Should pass
@@ -194,15 +194,6 @@ class EventBenchmark {
}
}
@Test
fun checkIDHashPayload2Fast() {
val event = Event.fromJson(payload2)
benchmarkRule.measureRepeated {
// Should pass
assertTrue(event.hasCorrectIDHash2())
}
}
@Test
fun eventSerializerTest() {
val event = Event.fromJson(payload2)