fix compilation warning

This commit is contained in:
valere 2022-12-13 15:48:13 +01:00
parent c3f439ea72
commit 3abd68c153
1 changed files with 55 additions and 60 deletions

View File

@ -22,7 +22,6 @@ import io.mockk.mockk
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.SendChannel import kotlinx.coroutines.channels.SendChannel
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.session.crypto.verification.ValidVerificationInfoReady import org.matrix.android.sdk.api.session.crypto.verification.ValidVerificationInfoReady
@ -32,9 +31,6 @@ import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.room.model.message.MessageVerificationReadyContent import org.matrix.android.sdk.api.session.room.model.message.MessageVerificationReadyContent
import org.matrix.android.sdk.api.session.room.model.message.MessageVerificationRequestContent import org.matrix.android.sdk.api.session.room.model.message.MessageVerificationRequestContent
import org.matrix.android.sdk.api.session.room.model.message.ValidVerificationDone import org.matrix.android.sdk.api.session.room.model.message.ValidVerificationDone
import org.matrix.android.sdk.internal.crypto.SecretShareManager
import org.matrix.android.sdk.internal.util.time.Clock
import org.matrix.olm.OlmSAS
import java.util.UUID import java.util.UUID
internal class VerificationActorHelper { internal class VerificationActorHelper {
@ -46,12 +42,12 @@ internal class VerificationActorHelper {
val bobStore: FakeCryptoStoreForVerification, val bobStore: FakeCryptoStoreForVerification,
) )
val actorAScope = CoroutineScope(SupervisorJob()) private val actorAScope = CoroutineScope(SupervisorJob())
val actorBScope = CoroutineScope(SupervisorJob()) private val actorBScope = CoroutineScope(SupervisorJob())
val transportScope = CoroutineScope(SupervisorJob()) private val transportScope = CoroutineScope(SupervisorJob())
var bobChannel: SendChannel<VerificationIntent>? = null private var bobChannel: SendChannel<VerificationIntent>? = null
var aliceChannel: SendChannel<VerificationIntent>? = null private var aliceChannel: SendChannel<VerificationIntent>? = null
fun setUpActors(): TestData { fun setUpActors(): TestData {
val aliceTransportLayer = mockTransportTo(FakeCryptoStoreForVerification.aliceMxId) { listOf(bobChannel) } val aliceTransportLayer = mockTransportTo(FakeCryptoStoreForVerification.aliceMxId) { listOf(bobChannel) }
@ -83,54 +79,54 @@ internal class VerificationActorHelper {
) )
} }
fun setupMultipleSessions() { // fun setupMultipleSessions() {
val aliceTargetChannels = mutableListOf<Channel<VerificationIntent>>() // val aliceTargetChannels = mutableListOf<Channel<VerificationIntent>>()
val aliceTransportLayer = mockTransportTo(FakeCryptoStoreForVerification.aliceMxId) { aliceTargetChannels } // val aliceTransportLayer = mockTransportTo(FakeCryptoStoreForVerification.aliceMxId) { aliceTargetChannels }
val bobTargetChannels = mutableListOf<Channel<VerificationIntent>>() // val bobTargetChannels = mutableListOf<Channel<VerificationIntent>>()
val bobTransportLayer = mockTransportTo(FakeCryptoStoreForVerification.bobMxId) { bobTargetChannels } // val bobTransportLayer = mockTransportTo(FakeCryptoStoreForVerification.bobMxId) { bobTargetChannels }
val bob2TargetChannels = mutableListOf<Channel<VerificationIntent>>() // val bob2TargetChannels = mutableListOf<Channel<VerificationIntent>>()
val bob2TransportLayer = mockTransportTo(FakeCryptoStoreForVerification.bobMxId) { bob2TargetChannels } // val bob2TransportLayer = mockTransportTo(FakeCryptoStoreForVerification.bobMxId) { bob2TargetChannels }
//
val fakeAliceStore = FakeCryptoStoreForVerification(StoreMode.Alice) // val fakeAliceStore = FakeCryptoStoreForVerification(StoreMode.Alice)
val aliceActor = fakeActor( // val aliceActor = fakeActor(
actorAScope, // actorAScope,
FakeCryptoStoreForVerification.aliceMxId, // FakeCryptoStoreForVerification.aliceMxId,
fakeAliceStore.instance, // fakeAliceStore.instance,
aliceTransportLayer, // aliceTransportLayer,
) // )
//
val fakeBobStore1 = FakeCryptoStoreForVerification(StoreMode.Bob) // val fakeBobStore1 = FakeCryptoStoreForVerification(StoreMode.Bob)
val bobActor = fakeActor( // val bobActor = fakeActor(
actorBScope, // actorBScope,
FakeCryptoStoreForVerification.bobMxId, // FakeCryptoStoreForVerification.bobMxId,
fakeBobStore1.instance, // fakeBobStore1.instance,
bobTransportLayer // bobTransportLayer
) // )
//
val actorCScope = CoroutineScope(SupervisorJob()) // val actorCScope = CoroutineScope(SupervisorJob())
val fakeBobStore2 = FakeCryptoStoreForVerification(StoreMode.Bob) // val fakeBobStore2 = FakeCryptoStoreForVerification(StoreMode.Bob)
every { fakeBobStore2.instance.getMyDeviceId() } returns FakeCryptoStoreForVerification.bobDeviceId2 // every { fakeBobStore2.instance.getMyDeviceId() } returns FakeCryptoStoreForVerification.bobDeviceId2
every { fakeBobStore2.instance.getMyDevice() } returns FakeCryptoStoreForVerification.aBobDevice2 // every { fakeBobStore2.instance.getMyDevice() } returns FakeCryptoStoreForVerification.aBobDevice2
//
val bobActor2 = fakeActor( // val bobActor2 = fakeActor(
actorCScope, // actorCScope,
FakeCryptoStoreForVerification.bobMxId, // FakeCryptoStoreForVerification.bobMxId,
fakeBobStore2.instance, // fakeBobStore2.instance,
bobTransportLayer // bobTransportLayer
) // )
//
aliceTargetChannels.add(bobActor.channel) // aliceTargetChannels.add(bobActor.channel)
aliceTargetChannels.add(bobActor2.channel) // aliceTargetChannels.add(bobActor2.channel)
//
bobTargetChannels.add(aliceActor.channel) // bobTargetChannels.add(aliceActor.channel)
bobTargetChannels.add(bobActor2.channel) // bobTargetChannels.add(bobActor2.channel)
//
bob2TargetChannels.add(aliceActor.channel) // bob2TargetChannels.add(aliceActor.channel)
bob2TargetChannels.add(bobActor.channel) // bob2TargetChannels.add(bobActor.channel)
} // }
private fun mockTransportTo(fromUser: String, otherChannel: (() -> List<SendChannel<VerificationIntent>?>)): VerificationTransportLayer { private fun mockTransportTo(fromUser: String, otherChannel: (() -> List<SendChannel<VerificationIntent>?>)): VerificationTransportLayer {
return mockk<VerificationTransportLayer> { return mockk {
coEvery { sendToOther(any(), any(), any()) } answers { coEvery { sendToOther(any(), any(), any()) } answers {
val request = firstArg<KotlinVerificationRequest>() val request = firstArg<KotlinVerificationRequest>()
val type = secondArg<String>() val type = secondArg<String>()
@ -266,17 +262,16 @@ internal class VerificationActorHelper {
): VerificationActor { ): VerificationActor {
return VerificationActor( return VerificationActor(
scope, scope,
// channel = channel, clock = mockk {
clock = mockk<Clock> {
every { epochMillis() } returns System.currentTimeMillis() every { epochMillis() } returns System.currentTimeMillis()
}, },
myUserId = userId, myUserId = userId,
verificationTrustBackend = cryptoStore, verificationTrustBackend = cryptoStore,
secretShareManager = mockk<SecretShareManager> {}, secretShareManager = mockk {},
transportLayer = transportLayer, transportLayer = transportLayer,
verificationRequestsStore = VerificationRequestsStore(), verificationRequestsStore = VerificationRequestsStore(),
olmPrimitiveProvider = mockk<VerificationCryptoPrimitiveProvider> { olmPrimitiveProvider = mockk {
every { provideOlmSas() } returns mockk<OlmSAS> { every { provideOlmSas() } returns mockk {
every { publicKey } returns "Tm9JRGVhRmFrZQo=" every { publicKey } returns "Tm9JRGVhRmFrZQo="
every { setTheirPublicKey(any()) } returns Unit every { setTheirPublicKey(any()) } returns Unit
every { generateShortCode(any(), any()) } returns byteArrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9) every { generateShortCode(any(), any()) } returns byteArrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9)