test: увеличить таймаут до 40s, включить info логи, показывать parser errors — нужна диагностика почему событие не доходит до клиента

This commit is contained in:
coopops
2026-04-22 05:52:50 +00:00
parent 4b6fc95eca
commit 83b82c7972
@@ -55,7 +55,7 @@ async function startParser(): Promise<string> {
reconnect: { maxAttempts: 3, backoffSeconds: [1, 2, 5] },
abiFallback: 'rpc-current',
chain: { url: CHAIN_URL },
logger: { level: 'warn' },
logger: { level: 'info' }, // для диагностики integration тестов
})
// Перехватываем chainId после connect через отдельный запрос
@@ -64,7 +64,10 @@ async function startParser(): Promise<string> {
resolveChainId(info.chain_id)
// Стартуем парсер асинхронно (он блокирует пока не остановлен)
parser.start().catch(() => { /* ожидаемое завершение в afterAll */ })
parser.start().catch(err => {
// Логируем ошибки парсера — иначе не увидим их в тесте
console.error(' → Parser.start() failed:', err)
})
// Ждём пока парсер начнёт читать блоки (подключится к SHiP)
await sleep(3000)
@@ -147,10 +150,14 @@ describe('eosio.token::issue', () => {
// Собираем событие через AsyncGenerator в фоне
const receivedEvents: ParserEvent[] = []
const eventReceived = new Promise<ParserEvent>((resolve, reject) => {
const timeout = setTimeout(() => reject(new Error('Timeout: event not received in 20s')), 20_000)
const timeout = setTimeout(() => {
console.log(` → Timeout reached, received ${receivedEvents.length} events: ${JSON.stringify(receivedEvents.map(e => e.kind))}`)
reject(new Error(`Timeout: event not received in 40s (got ${receivedEvents.length} events)`))
}, 40_000)
async function consume(): Promise<void> {
for await (const event of client.stream()) {
console.log(` → Received event: kind=${event.kind}`)
receivedEvents.push(event)
if (event.kind === 'action') {
clearTimeout(timeout)
@@ -159,11 +166,14 @@ describe('eosio.token::issue', () => {
}
}
}
consume().catch(reject)
consume().catch(err => {
console.error(' → consume() error:', err)
reject(err)
})
})
// Небольшая пауза чтобы consumer group создалась и начала читать
await sleep(2000)
await sleep(3000)
// Выполняем issue — выпуск дополнительных токенов eosio.token::issue
console.log(' → Pushing eosio.token::issue...')
@@ -179,6 +189,7 @@ describe('eosio.token::issue', () => {
},
},
])
console.log(' → Issue pushed, waiting for event...')
// Ждём события
const event = await eventReceived
@@ -194,5 +205,5 @@ describe('eosio.token::issue', () => {
memo: 'integration-test-issue',
})
}
}, 30_000)
}, 60_000)
})