mirror of
https://github.com/oxen-io/session-android.git
synced 2023-12-14 02:53:01 +01:00
fix: group member and tests with passing constructors
This commit is contained in:
parent
59c5588370
commit
77386a3555
4 changed files with 41 additions and 14 deletions
|
@ -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 network.loki.messenger.libsession_util.util.*
|
||||
import org.hamcrest.CoreMatchers.not
|
||||
import org.hamcrest.CoreMatchers.notNullValue
|
||||
import org.hamcrest.MatcherAssert.assertThat
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
@ -21,12 +22,19 @@ class InstrumentedTests {
|
|||
|
||||
val seed =
|
||||
Hex.fromStringCondensed("0123456789abcdef0123456789abcdef00000000000000000000000000000000")
|
||||
val groupSeed =
|
||||
Hex.fromStringCondensed("0123456789abcdef0123456789abcdef11111111111111111111111111111111")
|
||||
|
||||
private val keyPair: KeyPair
|
||||
get() {
|
||||
return Sodium.ed25519KeyPair(seed)
|
||||
}
|
||||
|
||||
private val groupKeyPair: KeyPair
|
||||
get() {
|
||||
return Sodium.ed25519KeyPair(groupSeed)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
|
@ -583,10 +591,29 @@ class InstrumentedTests {
|
|||
|
||||
@Test
|
||||
fun testGroupInfo() {
|
||||
val (public, secret) = keyPair
|
||||
val conf = GroupInfoConfig.newInstance(public, secret, null)
|
||||
conf.setName("New Group")
|
||||
assertEquals("New Group", conf.getName())
|
||||
val (groupPublic, groupSecret) = groupKeyPair
|
||||
val (userPublic, userSecret) = keyPair
|
||||
val userCurve = Sodium.ed25519PkToCurve25519(userPublic)
|
||||
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(
|
||||
pubKey: ByteArray,
|
||||
secretKey: ByteArray,
|
||||
initialDump: ByteArray
|
||||
secretKey: ByteArray = byteArrayOf(),
|
||||
initialDump: ByteArray = byteArrayOf()
|
||||
): GroupInfoConfig
|
||||
}
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@ package network.loki.messenger.libsession_util.util
|
|||
|
||||
data class GroupMember(
|
||||
val sessionId: String,
|
||||
val name: String?,
|
||||
val profilePicture: UserPic?,
|
||||
val inviteFailed: Boolean,
|
||||
val invitePending: Boolean,
|
||||
val admin: Boolean,
|
||||
val promotionFailed: Boolean,
|
||||
val promotionPending: Boolean,
|
||||
val name: String? = null,
|
||||
val profilePicture: UserPic = UserPic.DEFAULT,
|
||||
val inviteFailed: Boolean = false,
|
||||
val invitePending: Boolean = false,
|
||||
val admin: Boolean = false,
|
||||
val promotionFailed: Boolean = false,
|
||||
val promotionPending: Boolean = false,
|
||||
)
|
Loading…
Reference in a new issue