convert test files
This commit is contained in:
parent
e2d8c95a7b
commit
a52e0306ce
|
@ -1,4 +1,3 @@
|
|||
import { expect } from 'chai'
|
||||
import { Waku } from 'js-waku'
|
||||
|
||||
import { Community } from './community'
|
||||
|
@ -6,16 +5,7 @@ import { Community } from './community'
|
|||
import type { CommunityDescription } from './wire/community_description'
|
||||
|
||||
describe('Community [live data]', () => {
|
||||
before(function () {
|
||||
if (process.env.CI) {
|
||||
// Skip live data test in CI
|
||||
this.skip()
|
||||
}
|
||||
})
|
||||
|
||||
it('Retrieves community description For DappConnect Test from Waku prod fleet', async function () {
|
||||
this.timeout(20000)
|
||||
// FIXME?: mock
|
||||
test('Retrieves community description For DappConnect Test from Waku prod fleet', async () => {
|
||||
const waku = await Waku.create({ bootstrap: { default: true } })
|
||||
|
||||
await waku.waitForRemotePeer()
|
||||
|
@ -25,20 +15,20 @@ describe('Community [live data]', () => {
|
|||
waku
|
||||
)
|
||||
const desc = community.description as CommunityDescription
|
||||
expect(desc).to.not.be.undefined
|
||||
expect(desc).toBeDefined()
|
||||
|
||||
expect(desc.identity?.displayName).to.eq('Test Community')
|
||||
expect(desc.identity?.displayName).toEqual('Test Community')
|
||||
|
||||
const descChats = Array.from(desc.chats.values()).map(
|
||||
chat => chat?.identity?.displayName
|
||||
)
|
||||
expect(descChats).to.include('Test Chat')
|
||||
expect(descChats).to.include('Additional Chat')
|
||||
expect(descChats).toEqual(expect.arrayContaining(['Test Chat']))
|
||||
expect(descChats).toEqual(expect.arrayContaining(['Additional Chat']))
|
||||
|
||||
const chats = Array.from(community.chats.values()).map(
|
||||
chat => chat?.communityChat?.identity?.displayName
|
||||
)
|
||||
expect(chats).to.include('Test Chat')
|
||||
expect(chats).to.include('Additional Chat')
|
||||
expect(chats).toEqual(expect.arrayContaining(['Test Chat']))
|
||||
expect(chats).toEqual(expect.arrayContaining(['Additional Chat']))
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,23 +1,21 @@
|
|||
import { expect } from 'chai'
|
||||
|
||||
import { createSymKeyFromPassword } from './encryption'
|
||||
|
||||
describe('Encryption', () => {
|
||||
it('Generate symmetric key from password', async function () {
|
||||
test('Generate symmetric key from password', async () => {
|
||||
const str = 'arbitrary data here'
|
||||
const symKey = await createSymKeyFromPassword(str)
|
||||
|
||||
expect(Buffer.from(symKey).toString('hex')).to.eq(
|
||||
expect(Buffer.from(symKey).toString('hex')).toEqual(
|
||||
'c49ad65ebf2a7b7253bf400e3d27719362a91b2c9b9f54d50a69117021666c33'
|
||||
)
|
||||
})
|
||||
|
||||
it('Generate symmetric key from password for chat', async function () {
|
||||
test('Generate symmetric key from password for chat', async () => {
|
||||
const str =
|
||||
'0x02dcec6041fb999d65f1d33363e08c93d3c1f6f0fbbb26add383e2cf46c2b921f41dc14fd8-9a8b-4df5-a358-2c3067be5439'
|
||||
const symKey = await createSymKeyFromPassword(str)
|
||||
|
||||
expect(Buffer.from(symKey).toString('hex')).to.eq(
|
||||
expect(Buffer.from(symKey).toString('hex')).toEqual(
|
||||
'76ff5bf0a74a8e724367c7fc003f066d477641f468768a8da2817addf5c2ce76'
|
||||
)
|
||||
})
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { expect } from 'chai'
|
||||
import debug from 'debug'
|
||||
import { Protocols } from 'js-waku'
|
||||
|
||||
|
@ -20,9 +19,7 @@ describe('Messenger', () => {
|
|||
let identityAlice: Identity
|
||||
let identityBob: Identity
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(20_000)
|
||||
|
||||
beforeEach(async () => {
|
||||
dbg('Generate keys')
|
||||
identityAlice = Identity.generate()
|
||||
identityBob = Identity.generate()
|
||||
|
@ -51,9 +48,7 @@ describe('Messenger', () => {
|
|||
dbg('Messengers ready')
|
||||
})
|
||||
|
||||
it('Sends & Receive public chat messages', async function () {
|
||||
this.timeout(10_000)
|
||||
|
||||
test('Sends & Receive public chat messages', async () => {
|
||||
await messengerAlice.joinChatById(testChatId)
|
||||
await messengerBob.joinChatById(testChatId)
|
||||
|
||||
|
@ -73,12 +68,10 @@ describe('Messenger', () => {
|
|||
|
||||
const receivedMessage = await receivedMessagePromise
|
||||
|
||||
expect(receivedMessage.chatMessage?.text).to.eq(text)
|
||||
expect(receivedMessage.chatMessage?.text).toEqual(text)
|
||||
})
|
||||
|
||||
it('public chat messages have signers', async function () {
|
||||
this.timeout(10_000)
|
||||
|
||||
test('public chat messages have signers', async () => {
|
||||
await messengerAlice.joinChatById(testChatId)
|
||||
await messengerBob.joinChatById(testChatId)
|
||||
|
||||
|
@ -99,32 +92,22 @@ describe('Messenger', () => {
|
|||
const receivedMessage = await receivedMessagePromise
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
expect(bufToHex(receivedMessage.signer!)).to.eq(
|
||||
expect(bufToHex(receivedMessage.signer!)).toEqual(
|
||||
bufToHex(identityAlice.publicKey)
|
||||
)
|
||||
})
|
||||
|
||||
afterEach(async function () {
|
||||
this.timeout(5000)
|
||||
afterEach(async () => {
|
||||
await messengerAlice.stop()
|
||||
await messengerBob.stop()
|
||||
})
|
||||
})
|
||||
|
||||
describe('Messenger [live data]', () => {
|
||||
before(function () {
|
||||
if (process.env.CI) {
|
||||
// Skip live data test in CI
|
||||
this.skip()
|
||||
}
|
||||
})
|
||||
|
||||
let messenger: Messenger
|
||||
let identity: Identity
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(20_000)
|
||||
|
||||
beforeEach(async () => {
|
||||
dbg('Generate keys')
|
||||
identity = Identity.generate()
|
||||
|
||||
|
@ -139,9 +122,7 @@ describe('Messenger [live data]', () => {
|
|||
dbg('Messengers ready')
|
||||
})
|
||||
|
||||
it('Receive public chat messages', async function () {
|
||||
this.timeout(20_000)
|
||||
|
||||
test('Receive public chat messages', async () => {
|
||||
const community = await Community.instantiateCommunity(
|
||||
'0x02cf13719c8b836bebd4e430c497ee38e798a43e4d8c4760c34bbd9bf4f2434d26',
|
||||
messenger.waku
|
||||
|
@ -172,8 +153,7 @@ describe('Messenger [live data]', () => {
|
|||
)
|
||||
})
|
||||
|
||||
afterEach(async function () {
|
||||
this.timeout(5000)
|
||||
afterEach(async () => {
|
||||
await messenger.stop()
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import { expect } from 'chai'
|
||||
|
||||
import {
|
||||
AudioMessage_AudioType,
|
||||
ChatMessage_ContentType,
|
||||
|
@ -10,7 +8,7 @@ import { ChatMessage, ContentType } from './chat_message'
|
|||
import type { AudioContent, ImageContent, StickerContent } from './chat_message'
|
||||
|
||||
describe('Chat Message', () => {
|
||||
it('Encode & decode Image message', () => {
|
||||
test('Encode & decode Image message', () => {
|
||||
const payload = Buffer.from([1, 1])
|
||||
|
||||
const imageContent: ImageContent = {
|
||||
|
@ -24,12 +22,12 @@ describe('Chat Message', () => {
|
|||
const buf = message.encode()
|
||||
const dec = ChatMessage.decode(buf)
|
||||
|
||||
expect(dec.contentType).eq(ChatMessage_ContentType.CONTENT_TYPE_IMAGE)
|
||||
expect(dec.image?.payload?.toString()).eq(payload.toString())
|
||||
expect(dec.image?.type).eq(ImageType.IMAGE_TYPE_PNG)
|
||||
expect(dec.contentType).toEqual(ChatMessage_ContentType.CONTENT_TYPE_IMAGE)
|
||||
expect(dec.image?.payload?.toString()).toEqual(payload.toString())
|
||||
expect(dec.image?.type).toEqual(ImageType.IMAGE_TYPE_PNG)
|
||||
})
|
||||
|
||||
it('Encode & decode Audio message', () => {
|
||||
test('Encode & decode Audio message', () => {
|
||||
const payload = Buffer.from([1, 1])
|
||||
const durationMs = 12345
|
||||
|
||||
|
@ -45,13 +43,13 @@ describe('Chat Message', () => {
|
|||
const buf = message.encode()
|
||||
const dec = ChatMessage.decode(buf)
|
||||
|
||||
expect(dec.contentType).eq(ChatMessage_ContentType.CONTENT_TYPE_AUDIO)
|
||||
expect(dec.audio?.payload?.toString()).eq(payload.toString())
|
||||
expect(dec.audio?.type).eq(ImageType.IMAGE_TYPE_PNG)
|
||||
expect(dec.audio?.durationMs).eq(durationMs)
|
||||
expect(dec.contentType).toEqual(ChatMessage_ContentType.CONTENT_TYPE_AUDIO)
|
||||
expect(dec.audio?.payload?.toString()).toEqual(payload.toString())
|
||||
expect(dec.audio?.type).toEqual(ImageType.IMAGE_TYPE_PNG)
|
||||
expect(dec.audio?.durationMs).toEqual(durationMs)
|
||||
})
|
||||
|
||||
it('Encode & decode Sticker message', () => {
|
||||
test('Encode & decode Sticker message', () => {
|
||||
const hash = 'deadbeef'
|
||||
const pack = 12345
|
||||
|
||||
|
@ -66,8 +64,10 @@ describe('Chat Message', () => {
|
|||
const buf = message.encode()
|
||||
const dec = ChatMessage.decode(buf)
|
||||
|
||||
expect(dec.contentType).eq(ChatMessage_ContentType.CONTENT_TYPE_STICKER)
|
||||
expect(dec.sticker?.hash).eq(hash)
|
||||
expect(dec.sticker?.pack).eq(pack)
|
||||
expect(dec.contentType).toEqual(
|
||||
ChatMessage_ContentType.CONTENT_TYPE_STICKER
|
||||
)
|
||||
expect(dec.sticker?.hash).toEqual(hash)
|
||||
expect(dec.sticker?.pack).toEqual(pack)
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue