mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-04-23 17:42:13 +00:00
In order to support no-copy operations in streams, update all deps to support streaming Uint8ArrayLists.
34 lines
771 B
JavaScript
34 lines
771 B
JavaScript
import path from 'path'
|
|
import { execa } from 'execa'
|
|
import pWaitFor from 'p-wait-for'
|
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
|
|
export async function test () {
|
|
let discoveredNodes = 0
|
|
|
|
process.stdout.write('2.js\n')
|
|
|
|
const proc = execa('node', [path.join(__dirname, '2.js')], {
|
|
cwd: path.resolve(__dirname),
|
|
all: true
|
|
})
|
|
|
|
proc.all.on('data', async (data) => {
|
|
process.stdout.write(data)
|
|
const str = uint8ArrayToString(data)
|
|
|
|
str.split('\n').forEach(line => {
|
|
if (line.includes('Discovered:')) {
|
|
discoveredNodes++
|
|
}
|
|
})
|
|
})
|
|
|
|
await pWaitFor(() => discoveredNodes > 1)
|
|
|
|
proc.kill()
|
|
}
|