Fix bns test timeout (#1484)

fix: bns test timeout
This commit is contained in:
Nicholas Barnett
2022-12-13 09:26:43 -06:00
committed by GitHub
parent af129b54a8
commit 0586de6814

View File

@@ -1052,6 +1052,7 @@ describe('BNS event server tests', () => {
})
test('BNS middleware is async. /new_block posts return before importing BNS finishes', async () => {
jest.useRealTimers();
process.env.BNS_IMPORT_DIR = 'src/tests-bns/import-test-files';
const genesisBlock = await getGenesisBlockData('src/tests-event-replay/tsv/mainnet.tsv');
@@ -1068,11 +1069,15 @@ describe('BNS event server tests', () => {
expect(configState.bns_names_onchain_imported).toBe(false)
expect(configState.bns_subdomains_imported).toBe(false)
await new Promise(resolve => setTimeout(async() => {
const configState = await db.getConfigState();
expect(configState.bns_names_onchain_imported).toBe(true)
expect(configState.bns_subdomains_imported).toBe(true)
resolve(undefined)
}, 2000))
const timeoutId: NodeJS.Timeout = await new Promise(resolve => {
const timeoutId = setTimeout(async() => {
const configState = await db.getConfigState();
expect(configState.bns_names_onchain_imported).toBe(true)
expect(configState.bns_subdomains_imported).toBe(true)
resolve(timeoutId)
}, 2000)
})
clearTimeout(timeoutId);
})
})