some fixes

This commit is contained in:
einhornimmond 2025-06-17 17:29:13 +02:00
parent 0b67759c66
commit b8807f8452
3 changed files with 8 additions and 4 deletions

View File

@ -698,6 +698,9 @@ describe('UserResolver', () => {
})
describe('no users in database', () => {
beforeAll(() => {
clearLogs()
})
it('throws an error', async () => {
jest.clearAllMocks()
const result = await mutate({ mutation: login, variables })
@ -709,6 +712,7 @@ describe('UserResolver', () => {
})
it('logs the error found', () => {
printLogs()
expect(logger.warn).toBeCalledWith(
`findUserByEmail failed, user with email=${variables.email} not found`,
)

View File

@ -3,7 +3,7 @@ import { Community as DbCommunity, FederatedCommunity as DbFederatedCommunity }
import { validate as validateUUID, version as versionUUID } from 'uuid'
import { cleanDB, testEnvironment } from '@test/helpers'
import { cleanLogs, getLogger, printLogs } from 'config-schema/test/testSetup'
import { clearLogs, getLogger, printLogs } from 'config-schema/test/testSetup'
import { CONFIG } from '@/config'
@ -358,6 +358,7 @@ describe('federation', () => {
let jsonArray: any[]
let result: DbFederatedCommunity[] = []
beforeAll(async () => {
clearLogs()
jest.clearAllMocks()
jsonArray = [
{
@ -373,6 +374,7 @@ describe('federation', () => {
]
await socketEventMocks.data(Buffer.from(JSON.stringify(jsonArray)))
result = await DbFederatedCommunity.find({ where: { foreign: true } })
printLogs()
})
afterAll(async () => {

View File

@ -60,7 +60,6 @@ export const startDHT = async (topic: string): Promise<void> => {
server.on('connection', function (socket: any) {
logger.info(`server on... with Remote public key: ${socket.remotePublicKey.toString('hex')}`)
socket.on('data', async (data: Buffer) => {
try {
if (data.length > 1141) {
@ -110,10 +109,9 @@ export const startDHT = async (topic: string): Promise<void> => {
const variables = {
apiVersion: recApiVersion.api,
endPoint: recApiVersion.url,
publicKey: socket.remotePublicKey.toString('hex'),
publicKey: socket.remotePublicKey,
lastAnnouncedAt: new Date(),
}
logger.debug(`upsert with variables=${JSON.stringify(variables, null, 2)}`)
// this will NOT update the updatedAt column, to distingue between a normal update and the last announcement
await DbFederatedCommunity.createQueryBuilder()
.insert()