1
- import { encode } from 'bs58' ;
2
- import { generatePeerId , peerIdToSeed , seedToPeerId } from '../../internal/peerIdUtils' ;
3
- import { FluenceClientImpl } from '../../internal/FluenceClientImpl' ;
4
- import { createConnectedClient } from '../util' ;
1
+ import { encode } from 'bs58' ;
2
+ import { generatePeerId , peerIdToSeed , seedToPeerId } from '../../internal/peerIdUtils' ;
3
+ import { FluenceClientImpl } from '../../internal/FluenceClientImpl' ;
4
+ import { createConnectedClient } from '../util' ;
5
5
import log from 'loglevel' ;
6
- import { createClient } from '../../api' ;
6
+ import { createClient } from '../../api' ;
7
7
import Multiaddr from 'multiaddr' ;
8
8
9
9
const devNodeAddress = '/dns4/dev.fluence.dev/tcp/19001/wss/p2p/12D3KooWEXNUbCXooUwHrHBbrmjsrpHXoEphPwbjQXEGyzbqKnE9' ;
@@ -40,8 +40,7 @@ describe('Typescript usage suite', () => {
40
40
41
41
await client . sendScript ( script , data ) ;
42
42
43
- const res = await resMakingPromise ;
44
- return res ;
43
+ return await resMakingPromise ;
45
44
} ;
46
45
47
46
it ( 'address as string' , async function ( ) {
@@ -198,13 +197,8 @@ describe('Typescript usage suite', () => {
198
197
199
198
it ( 'two clients should work inside the same time browser' , async function ( ) {
200
199
// arrange
201
- const pid1 = await generatePeerId ( ) ;
202
- const client1 = new FluenceClientImpl ( pid1 ) ;
203
- await client1 . connect ( devNodeAddress ) ;
204
-
205
- const pid2 = await generatePeerId ( ) ;
206
- const client2 = new FluenceClientImpl ( pid2 ) ;
207
- await client2 . connect ( devNodeAddress ) ;
200
+ const client1 = await createConnectedClient ( devNodeAddress ) ;
201
+ const client2 = await createConnectedClient ( devNodeAddress ) ;
208
202
209
203
let resMakingPromise = new Promise ( ( resolve ) => {
210
204
client2 . registerCallback ( 'test' , 'test' , ( args , _ ) => {
@@ -216,7 +210,7 @@ describe('Typescript usage suite', () => {
216
210
let script = `
217
211
(seq
218
212
(call "${ client1 . relayPeerId } " ("op" "identity") [])
219
- (call "${ pid2 . toB58String ( ) } " ("test" "test") [a b c d])
213
+ (call "${ client2 . selfPeerId } " ("test" "test") [a b c d])
220
214
)
221
215
` ;
222
216
@@ -234,13 +228,8 @@ describe('Typescript usage suite', () => {
234
228
235
229
it ( 'event registration should work' , async function ( ) {
236
230
// arrange
237
- const pid1 = await generatePeerId ( ) ;
238
- const client1 = new FluenceClientImpl ( pid1 ) ;
239
- await client1 . connect ( devNodeAddress ) ;
240
-
241
- const pid2 = await generatePeerId ( ) ;
242
- const client2 = new FluenceClientImpl ( pid2 ) ;
243
- await client2 . connect ( devNodeAddress ) ;
231
+ const client1 = await createConnectedClient ( devNodeAddress ) ;
232
+ const client2 = await createConnectedClient ( devNodeAddress ) ;
244
233
245
234
client2 . registerEvent ( 'event_stream' , 'test' ) ;
246
235
const resMakingPromise = new Promise ( ( resolve ) => {
@@ -249,7 +238,7 @@ describe('Typescript usage suite', () => {
249
238
250
239
// act
251
240
let script = `
252
- (call "${ pid2 . toB58String ( ) } " ("event_stream" "test") [hello])
241
+ (call "${ client2 . selfPeerId } " ("event_stream" "test") [hello])
253
242
` ;
254
243
255
244
let data : Map < string , any > = new Map ( ) ;
0 commit comments