Skip to content

Commit

Permalink
feat: Add option to run with proteus
Browse files Browse the repository at this point in the history
  • Loading branch information
augustocdias committed Jul 6, 2023
1 parent a6a2601 commit 1c22296
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ import com.wire.kalium.logic.feature.conversation.CreateGroupConversationUseCase

class DefaultConversationCreation : ConversationCreation {
override suspend fun invoke(
monkeyGroups: List<List<Monkey>>
monkeyGroups: List<List<Monkey>>,
protocol: ConversationOptions.Protocol
): List<MonkeyConversation> = monkeyGroups.map { group ->
val groupCreator = group.first()
val userScope = groupCreator.operationScope

val conversationResult = userScope.conversations.createGroupConversation(
name = "By Monkey '${groupCreator.user.email}'",
userIdList = group.map { it.user.userId },
options = ConversationOptions(protocol = MonkeyApplication.GROUP_TYPE)
options = ConversationOptions(protocol = protocol)
)

if (conversationResult !is CreateGroupConversationUseCase.Result.Success) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import co.touchlab.kermit.LogWriter
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.arguments.argument
import com.github.ajalt.clikt.parameters.options.default
import com.github.ajalt.clikt.parameters.options.flag
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.types.enum
import com.wire.kalium.logger.KaliumLogLevel
Expand All @@ -40,6 +41,7 @@ class MonkeyApplication : CliktCommand(allowMultipleSubcommands = true) {
private val logLevel by option(help = "log level").enum<KaliumLogLevel>().default(KaliumLogLevel.VERBOSE)
private val logOutputFile by option(help = "output file for logs")
private val fileLogger: LogWriter by lazy { fileLogger(logOutputFile ?: "kalium.log") }
private val proteus by option(help = "run using proteus protocol").flag()

override fun run() = runBlocking {
val coreLogic = coreLogic(
Expand Down Expand Up @@ -67,17 +69,17 @@ class MonkeyApplication : CliktCommand(allowMultipleSubcommands = true) {
users: List<UserData>,
testSequence: TestSequence
) = with(testSequence) {
val protocol = if (proteus) ConversationOptions.Protocol.PROTEUS else ConversationOptions.Protocol.MLS
val monkeyGroups = split(users)
val monkeyScopes = setup(coreLogic, monkeyGroups)
val conversations = createConversations(monkeyScopes)
val conversations = createConversations(monkeyScopes, protocol)
commands.forEach { command ->
command(conversations)
}
}

companion object {
val HOME_DIRECTORY: String = homeDirectory()
val GROUP_TYPE = ConversationOptions.Protocol.MLS
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ fun interface MonkeyCommand {
* Creates a conversation between a watch monkey and a list of monkeys.
*/
fun interface ConversationCreation {
suspend operator fun invoke(monkeyGroups: List<List<Monkey>>): List<MonkeyConversation>
suspend operator fun invoke(
monkeyGroups: kotlin.collections.List<kotlin.collections.List<com.wire.kalium.monkeys.Monkey>>,
protocol: com.wire.kalium.logic.data.conversation.ConversationOptions.Protocol
): List<MonkeyConversation>
}

/**
Expand Down

0 comments on commit 1c22296

Please sign in to comment.