mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Updates
- removed timeout, use maxIdleTimeMs - made messages a keyedDB to better utitlize message cache - possible fix for group ID bug
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { WAConnection, MessageLogLevel, MessageOptions, MessageType, unixTimestampSeconds, toNumber } from '../WAConnection/WAConnection'
|
||||
import { WAConnection, MessageLogLevel, MessageOptions, MessageType, unixTimestampSeconds, toNumber, GET_MESSAGE_ID, WA_MESSAGE_KEY } from '../WAConnection/WAConnection'
|
||||
import * as assert from 'assert'
|
||||
import {promises as fs} from 'fs'
|
||||
|
||||
@@ -13,8 +13,7 @@ export async function sendAndRetreiveMessage(conn: WAConnection, content, type:
|
||||
|
||||
const chat = conn.chats.get(testJid)
|
||||
|
||||
assertChatDBIntegrity (conn)
|
||||
assert.ok (chat.messages.find(m => m.key.id === response.key.id))
|
||||
assert.ok (chat.messages.get(GET_MESSAGE_ID(message.key)))
|
||||
assert.ok (chat.t >= (unixTimestampSeconds()-5) )
|
||||
return message
|
||||
}
|
||||
@@ -37,13 +36,13 @@ export const WAConnectionTest = (name: string, func: (conn: WAConnection) => voi
|
||||
export const assertChatDBIntegrity = (conn: WAConnection) => {
|
||||
conn.chats.all ().forEach (chat => (
|
||||
assert.deepEqual (
|
||||
[...chat.messages].sort ((m1, m2) => toNumber(m1.messageTimestamp)-toNumber(m2.messageTimestamp)),
|
||||
chat.messages
|
||||
[...chat.messages.all()].sort ((m1, m2) => WA_MESSAGE_KEY(m1)-WA_MESSAGE_KEY(m2)),
|
||||
chat.messages.all()
|
||||
)
|
||||
))
|
||||
conn.chats.all ().forEach (chat => (
|
||||
assert.deepEqual (
|
||||
chat.messages.filter (m => chat.messages.filter(m1 => m1.key.id === m.key.id).length > 1),
|
||||
chat.messages.all().filter (m => chat.messages.all().filter(m1 => m1.key.id === m.key.id).length > 1),
|
||||
[]
|
||||
)
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user