Skip to content

Commit

Permalink
add test for it
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Aug 21, 2024
1 parent 9ca2d9f commit e5e6b09
Showing 1 changed file with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -439,4 +439,59 @@ class ClientTest {
}
assertEquals(boClient.inboxId, boInboxId)
}

@Test
fun testRevokesAllOtherInstallations() {
val key = SecureRandom().generateSeed(32)
val context = InstrumentationRegistry.getInstrumentation().targetContext
val alixWallet = PrivateKeyBuilder()
runBlocking {
val alixClient = Client().create(
account = alixWallet,
options = ClientOptions(
ClientOptions.Api(XMTPEnvironment.LOCAL, false),
enableV3 = true,
appContext = context,
dbEncryptionKey = key
)
)
alixClient.dropLocalDatabaseConnection()
alixClient.deleteLocalDatabase()

val alixClient2 = Client().create(
account = alixWallet,
options = ClientOptions(
ClientOptions.Api(XMTPEnvironment.LOCAL, false),
enableV3 = true,
appContext = context,
dbEncryptionKey = key
)
)
alixClient2.dropLocalDatabaseConnection()
alixClient2.deleteLocalDatabase()
}

val alixClient3 = runBlocking {
Client().create(
account = alixWallet,
options = ClientOptions(
ClientOptions.Api(XMTPEnvironment.LOCAL, false),
enableV3 = true,
appContext = context,
dbEncryptionKey = key
)
)
}

var state = runBlocking { alixClient3.inboxState(true) }
assertEquals(state.installationIds.size, 3)

runBlocking {
alixClient3.revokeAllOtherInstallations(alixWallet)
}

state = runBlocking { alixClient3.inboxState(true) }
assertEquals(state.installationIds.size, 1)
}
}

0 comments on commit e5e6b09

Please sign in to comment.