How to use the orbit-db-test-utils.waitForPeers function in orbit-db-test-utils

To help you get started, we’ve selected a few orbit-db-test-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github orbitdb / ipfs-log / test / replicate.spec.js View on Github external
it('replicates logs', async () => {
        await waitForPeers(ipfs1, [id2], channel)

        for (let i = 1; i <= amount; i++) {
          await input1.append('A' + i)
          await input2.append('B' + i)
          const hash1 = await input1.toMultihash()
          const hash2 = await input2.toMultihash()
          await ipfs1.pubsub.publish(channel, Buffer.from(hash1))
          await ipfs2.pubsub.publish(channel, Buffer.from(hash2))
        }

        console.log('\nAll messages sent')

        const whileProcessingMessages = (timeoutMs) => {
          return new Promise((resolve, reject) => {
            setTimeout(() => reject(new Error('timeout')), timeoutMs)
            const timer = setInterval(() => {