Skip to content

Commit

Permalink
do all the static can message work
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Dec 5, 2024
1 parent c44a2c0 commit f28a59e
Show file tree
Hide file tree
Showing 6 changed files with 325 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,17 @@ class XMTPModule : Module() {
}
}

AsyncFunction("staticCanMessage") Coroutine { environment: String, peerAddresses: List<String> ->
withContext(Dispatchers.IO) {
logV("staticCanMessage")
Client.canMessage(
peerAddresses,
context,
apiEnvironments(environment, null)
)
}
}

AsyncFunction("getOrCreateInboxId") Coroutine { address: String, environment: String ->
withContext(Dispatchers.IO) {
try {
Expand Down
23 changes: 23 additions & 0 deletions example/src/tests/clientTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,29 @@ test('can make a client', async () => {
return true
})

test('static can message', async () => {
const [alix, bo] = await createClients(2)

const addressMap = await Client.canMessage('local', [
alix.address,
'RANDOM',
bo.address,
])

assert(addressMap['RANDOM'] === false, `should not be able to message RANDOM`)

assert(
addressMap[alix.address.toLowerCase()] === true,
`should be able to message ${alix.address}`
)

assert(
addressMap[bo.address.toLowerCase()] === true,
`should be able to message ${bo.address}`
)
return true
})

test('can revoke all other installations', async () => {
const keyBytes = new Uint8Array([
233, 120, 198, 96, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64,
Expand Down
6 changes: 3 additions & 3 deletions example/src/tests/groupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -866,12 +866,12 @@ test('canMessage', async () => {
const canMessageV3 = await caro.canMessage([
caro.address,
alix.address,
'0x0000000000000000000000000000000000000000',
'RANDOM',
])

assert(
canMessageV3['0x0000000000000000000000000000000000000000'] === false,
`should not be able to message 0x0000000000000000000000000000000000000000`
canMessageV3['RANDOM'] === false,
`should not be able to message RANDOM`
)

assert(
Expand Down
Loading

0 comments on commit f28a59e

Please sign in to comment.