Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix iOS timestamp precision on iOS #281

Draft
wants to merge 3 commits into
base: beta
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions example/src/tests/createdAtTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,3 +546,83 @@ test('conversation createdAt matches streamAll', async () => {

return true
})

test('group and conversation createdAt has millisecond precision', async () => {
// Create three MLS enabled Clients
const aliceClient = await Client.createRandom({
env: 'local',
enableAlphaMls: true,
})
const bobClient = await Client.createRandom({
env: 'local',
enableAlphaMls: true,
})

// Alice creates a group
const aliceGroup = await aliceClient.conversations.newGroup([
bobClient.address,
])

// Bob creates a conversation
const bobConversation = await bobClient.conversations.newConversation(
aliceClient.address
)

console.log('Group createdAt: ' + aliceGroup.createdAt)
console.log('Conversation createdAt: ' + bobConversation.createdAt)
assert(
!bobConversation.createdAt.toString().endsWith('000'),
'Group createdAt should have millisecond precision, but it is ' +
bobConversation.createdAt
)
assert(
!aliceGroup.createdAt.toString().endsWith('000'),
'Group createdAt should have millisecond precision, but it is ' +
aliceGroup.createdAt
)

return true
})

test('message timestamp has millisecond precision', async () => {
// Create three MLS enabled Clients
const aliceClient = await Client.createRandom({
env: 'local',
enableAlphaMls: true,
})
const bobClient = await Client.createRandom({
env: 'local',
enableAlphaMls: true,
})

// Alice creates a group
const aliceGroup = await aliceClient.conversations.newGroup([
bobClient.address,
])

// Bob creates a conversation
const bobConversation = await bobClient.conversations.newConversation(
aliceClient.address
)

await aliceGroup.send('hello')
await bobConversation.send('hi')

const aliceMessage = (await aliceGroup.messages())[0]
const bobMessage = (await bobConversation.messages())[0]

console.log('Group message sent: ' + aliceMessage.sent)
console.log('Conversation message sent: ' + bobMessage.sent)
assert(
!bobMessage.sent.toString().endsWith('000'),
'Conversation message sent should have millisecond precision, but it is ' +
bobMessage.sent
)
assert(
!aliceMessage.sent.toString().endsWith('000'),
'Group message sent should have millisecond precision, but it is ' +
aliceMessage.sent
)

return true
})
Loading