Skip to content

Commit

Permalink
Merge branch 'main' into bump-v102.0.0-beta.0
Browse files Browse the repository at this point in the history
  • Loading branch information
teogeb committed Oct 24, 2024
2 parents f985d5c + be66d55 commit 765a69a
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions test/end-to-end.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'reflect-metadata'
import { DhtAddress, NodeType, randomDhtAddress, toDhtAddress, toDhtAddressRaw } from '@streamr/dht'
import StreamrClient, { NetworkNodeType, PeerDescriptor, StreamID, StreamPermission, StreamrClientConfig } from '@streamr/sdk'
import { NetworkNode, createNetworkNode } from '@streamr/trackerless-network'
import { StreamPartID, setAbortableInterval, toStreamPartID, waitForCondition } from '@streamr/utils'
import { StreamPartID, collect, setAbortableInterval, toStreamPartID, waitForCondition } from '@streamr/utils'
import { sample, uniq, without } from 'lodash'
import Container from 'typedi'
import { CONFIG_TOKEN } from '../src/Config'
Expand Down Expand Up @@ -63,11 +63,9 @@ const createClientConfig = (entryPointPeerDescriptor: PeerDescriptor): StreamrCl
}
}

const createClient = (privateKey: string, entryPointPeerDescriptor: PeerDescriptor) => {
const createClient = (privateKey: string | undefined, entryPointPeerDescriptor: PeerDescriptor) => {
return new StreamrClient({
auth: {
privateKey
},
auth: (privateKey !== undefined) ? { privateKey } : undefined,
...createClientConfig(entryPointPeerDescriptor)
})
}
Expand Down Expand Up @@ -177,6 +175,16 @@ describe('end-to-end', () => {
}))
}

const waitForTheGraphToIndex = async (streamIds: StreamID[]): Promise<void> => {
const client = createClient(undefined, entryPoint.getPeerDescriptor())
for (const streamId of streamIds) {
await waitForCondition(async () => {
const streams = await collect(client.searchStreams(streamId, undefined))
return streams.length > 0
}, 5000, 500)
}
}

beforeAll(async () => {
entryPoint = await startEntryPoint()
const config = {
Expand Down Expand Up @@ -221,6 +229,7 @@ describe('end-to-end', () => {
await startPublisherAndSubscriberForStream(privateStream.id, publishingAbortControler.signal)
const publicStream = await createTestStream(true)
await startPublisherAndSubscriberForStream(publicStream.id, publishingAbortControler.signal)
await waitForTheGraphToIndex([privateStream.id, publicStream.id])

crawler = Container.get(Crawler)
await crawler.start(1)
Expand Down

0 comments on commit 765a69a

Please sign in to comment.