@@ -3,6 +3,7 @@ package org.xmtp.android.library
3
3
import androidx.test.ext.junit.runners.AndroidJUnit4
4
4
import app.cash.turbine.test
5
5
import com.google.protobuf.kotlin.toByteString
6
+ import com.google.protobuf.kotlin.toByteStringUtf8
6
7
import kotlinx.coroutines.ExperimentalCoroutinesApi
7
8
import org.junit.Assert
8
9
import org.junit.Assert.assertEquals
@@ -228,12 +229,21 @@ class ConversationTest {
228
229
signedBytes,
229
230
additionalData = headerBytes,
230
231
)
232
+ val thirtyDayPeriodsSinceEpoch =
233
+ (Date ().time / 1000 / 60 / 60 / 24 / 30 ).toInt()
234
+ val info = " $thirtyDayPeriodsSinceEpoch -${aliceClient.address} "
235
+ val infoEncoded = info.toByteStringUtf8().toByteArray()
236
+ val senderHmacGenerated =
237
+ Crypto .calculateMac(
238
+ Crypto .deriveKey(aliceConversation.keyMaterial!! , ByteArray (0 ), infoEncoded),
239
+ headerBytes
240
+ )
231
241
val tamperedMessage =
232
242
MessageV2Builder .buildFromCipherText(
233
243
headerBytes = headerBytes,
234
244
ciphertext = ciphertext,
235
- senderHmac = null ,
236
- shouldPush = true ,
245
+ senderHmac = senderHmacGenerated ,
246
+ shouldPush = codec.shouldPush( " this is a fake " ) ,
237
247
)
238
248
val tamperedEnvelope = EnvelopeBuilder .buildFromString(
239
249
topic = aliceConversation.topic,
0 commit comments