-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve PreparedMessage handling (#113)
- Loading branch information
1 parent
b82ac6c
commit 0976446
Showing
6 changed files
with
113 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
library/src/test/java/org/xmtp/android/library/PreparedMessageTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.xmtp.android.library | ||
|
||
import com.google.protobuf.kotlin.toByteStringUtf8 | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import org.xmtp.android.library.messages.Envelope | ||
|
||
class PreparedMessageTest { | ||
|
||
@Test | ||
fun testSerializing() { | ||
val original = PreparedMessage( | ||
listOf( | ||
Envelope.newBuilder().apply { | ||
contentTopic = "topic1" | ||
timestampNs = 1234 | ||
message = "abc123".toByteStringUtf8() | ||
}.build(), | ||
Envelope.newBuilder().apply { | ||
contentTopic = "topic2" | ||
timestampNs = 5678 | ||
message = "def456".toByteStringUtf8() | ||
}.build(), | ||
) | ||
) | ||
val serialized = original.toSerializedData() | ||
val unserialized = PreparedMessage.fromSerializedData(serialized) | ||
assertEquals(original, unserialized) | ||
} | ||
} |