fix: group member and tests with passing constructors
This commit is contained in:
parent
59c5588370
commit
77386a3555
|
@ -1 +1 @@
|
||||||
Subproject commit 883710340a14b74ffbac482b8b4b41aadcad446e
|
Subproject commit 517a61a455d31cd9363198d1b3d02f20093a5811
|
|
@ -4,6 +4,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import androidx.test.platform.app.InstrumentationRegistry
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
import network.loki.messenger.libsession_util.util.*
|
import network.loki.messenger.libsession_util.util.*
|
||||||
import org.hamcrest.CoreMatchers.not
|
import org.hamcrest.CoreMatchers.not
|
||||||
|
import org.hamcrest.CoreMatchers.notNullValue
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.hamcrest.MatcherAssert.assertThat
|
||||||
import org.junit.Assert.*
|
import org.junit.Assert.*
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
@ -21,12 +22,19 @@ class InstrumentedTests {
|
||||||
|
|
||||||
val seed =
|
val seed =
|
||||||
Hex.fromStringCondensed("0123456789abcdef0123456789abcdef00000000000000000000000000000000")
|
Hex.fromStringCondensed("0123456789abcdef0123456789abcdef00000000000000000000000000000000")
|
||||||
|
val groupSeed =
|
||||||
|
Hex.fromStringCondensed("0123456789abcdef0123456789abcdef11111111111111111111111111111111")
|
||||||
|
|
||||||
private val keyPair: KeyPair
|
private val keyPair: KeyPair
|
||||||
get() {
|
get() {
|
||||||
return Sodium.ed25519KeyPair(seed)
|
return Sodium.ed25519KeyPair(seed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val groupKeyPair: KeyPair
|
||||||
|
get() {
|
||||||
|
return Sodium.ed25519KeyPair(groupSeed)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun useAppContext() {
|
fun useAppContext() {
|
||||||
// Context of the app under test.
|
// Context of the app under test.
|
||||||
|
@ -583,10 +591,29 @@ class InstrumentedTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testGroupInfo() {
|
fun testGroupInfo() {
|
||||||
val (public, secret) = keyPair
|
val (groupPublic, groupSecret) = groupKeyPair
|
||||||
val conf = GroupInfoConfig.newInstance(public, secret, null)
|
val (userPublic, userSecret) = keyPair
|
||||||
conf.setName("New Group")
|
val userCurve = Sodium.ed25519PkToCurve25519(userPublic)
|
||||||
assertEquals("New Group", conf.getName())
|
val infoConf = GroupInfoConfig.newInstance(groupPublic, groupSecret)
|
||||||
|
infoConf.setName("New Group")
|
||||||
|
assertEquals("New Group", infoConf.getName())
|
||||||
|
infoConf.setCreated(System.currentTimeMillis())
|
||||||
|
assertThat(infoConf.getCreated(), notNullValue())
|
||||||
|
val memberConf = GroupMemberConfig.newInstance(groupPublic, groupSecret)
|
||||||
|
memberConf.set(
|
||||||
|
GroupMember(
|
||||||
|
sessionId = "05"+Hex.toStringCondensed(userCurve),
|
||||||
|
name = "User",
|
||||||
|
admin = true
|
||||||
|
)
|
||||||
|
)
|
||||||
|
val keys = GroupKeysConfig.newInstance(
|
||||||
|
userSecretKey = userSecret,
|
||||||
|
groupPublicKey = groupPublic,
|
||||||
|
groupSecretKey = groupSecret,
|
||||||
|
info = infoConf,
|
||||||
|
members = memberConf
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -215,8 +215,8 @@ class GroupInfoConfig(pointer: Long): ConfigBase(pointer) {
|
||||||
|
|
||||||
external fun newInstance(
|
external fun newInstance(
|
||||||
pubKey: ByteArray,
|
pubKey: ByteArray,
|
||||||
secretKey: ByteArray,
|
secretKey: ByteArray = byteArrayOf(),
|
||||||
initialDump: ByteArray
|
initialDump: ByteArray = byteArrayOf()
|
||||||
): GroupInfoConfig
|
): GroupInfoConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,11 @@ package network.loki.messenger.libsession_util.util
|
||||||
|
|
||||||
data class GroupMember(
|
data class GroupMember(
|
||||||
val sessionId: String,
|
val sessionId: String,
|
||||||
val name: String?,
|
val name: String? = null,
|
||||||
val profilePicture: UserPic?,
|
val profilePicture: UserPic = UserPic.DEFAULT,
|
||||||
val inviteFailed: Boolean,
|
val inviteFailed: Boolean = false,
|
||||||
val invitePending: Boolean,
|
val invitePending: Boolean = false,
|
||||||
val admin: Boolean,
|
val admin: Boolean = false,
|
||||||
val promotionFailed: Boolean,
|
val promotionFailed: Boolean = false,
|
||||||
val promotionPending: Boolean,
|
val promotionPending: Boolean = false,
|
||||||
)
|
)
|
Loading…
Reference in New Issue