Skip to content

Commit 9203e22

Browse files
committed
common: test ipfs crawler- promisify test server
1 parent e8743fd commit 9203e22

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

packages/indexer-common/src/__tests__/ipfs.test.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,21 @@ describe(SubgraphManifestResolver, () => {
8383
if (manifestMap.has(cid)) {
8484
res.send(manifestMap.get(cid))
8585
} else {
86+
console.log(`CID not found: ${cid}`)
8687
res.status(404).send()
8788
}
8889
})
8990
// Start server and bind to a random port
90-
server = app.listen(0, () => {
91-
console.log(`Mock server running on ${server.address()}`)
91+
server = await new Promise((resolve, reject) => {
92+
const s = app.listen(0, () => {
93+
const address: AddressInfo = s.address() as AddressInfo
94+
console.log(`Mock server running on ${address.address}:${address.port}`)
95+
const serverAddress = `http://localhost:${address.port}`
96+
ipfs = new SubgraphManifestResolver(serverAddress, createLogger({ name: 'test' }))
97+
resolve(s)
98+
})
99+
s.on('error', reject)
92100
})
93-
94-
const address: AddressInfo = server.address() as AddressInfo
95-
const serverAddress = `http://localhost:${address.port}`
96-
ipfs = new SubgraphManifestResolver(serverAddress, createLogger({ name: 'test' }))
97101
})
98102

99103
afterAll(async () => {

0 commit comments

Comments
 (0)