1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-25 04:17:59 +01:00

Test RevocationState class

This commit is contained in:
Paul Schaub 2023-06-30 18:07:25 +02:00
parent 3942209d33
commit aa74d7d4f1
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -0,0 +1,43 @@
package org.pgpainless.wot.dijkstra
import org.junit.jupiter.api.Test
import org.pgpainless.wot.dijkstra.sq.ReferenceTime
import org.pgpainless.wot.dijkstra.sq.RevocationState
import java.util.*
import kotlin.test.assertFalse
import kotlin.test.assertTrue
class RevocationStateTest {
@Test
fun testNotRevoked() {
val notRevoked = RevocationState.notRevoked()
assertTrue { notRevoked.isNotRevoked() }
assertFalse { notRevoked.isSoftRevocation() }
assertFalse { notRevoked.isHardRevocation() }
assertFalse { notRevoked.isEffective(ReferenceTime.timestamp(Date())) }
}
@Test
fun testSoftRevocation() {
val timestamp = Date()
val before = Date(timestamp.time - 5000)
val after = Date(timestamp.time + 5000)
val softRevoked = RevocationState.softRevoked(timestamp)
assertTrue { softRevoked.isSoftRevocation() }
assertFalse { softRevoked.isHardRevocation() }
assertFalse { softRevoked.isNotRevoked() }
assertTrue { softRevoked.isEffective(ReferenceTime.timestamp(after)) }
assertFalse { softRevoked.isEffective(ReferenceTime.timestamp(before)) }
}
@Test
fun testHardRevoked() {
val hardRevoked = RevocationState.hardRevoked()
assertTrue { hardRevoked.isHardRevocation() }
assertFalse { hardRevoked.isSoftRevocation() }
assertFalse { hardRevoked.isNotRevoked() }
assertTrue { hardRevoked.isEffective(ReferenceTime.now()) }
}
}