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' ;
55import log from 'loglevel' ;
6- import { createClient } from '../../api' ;
6+ import { createClient } from '../../api' ;
77import Multiaddr from 'multiaddr' ;
88
99const devNodeAddress = '/dns4/dev.fluence.dev/tcp/19001/wss/p2p/12D3KooWEXNUbCXooUwHrHBbrmjsrpHXoEphPwbjQXEGyzbqKnE9' ;
@@ -40,8 +40,7 @@ describe('Typescript usage suite', () => {
4040
4141 await client . sendScript ( script , data ) ;
4242
43- const res = await resMakingPromise ;
44- return res ;
43+ return await resMakingPromise ;
4544 } ;
4645
4746 it ( 'address as string' , async function ( ) {
@@ -198,13 +197,8 @@ describe('Typescript usage suite', () => {
198197
199198 it ( 'two clients should work inside the same time browser' , async function ( ) {
200199 // 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 ) ;
208202
209203 let resMakingPromise = new Promise ( ( resolve ) => {
210204 client2 . registerCallback ( 'test' , 'test' , ( args , _ ) => {
@@ -216,7 +210,7 @@ describe('Typescript usage suite', () => {
216210 let script = `
217211 (seq
218212 (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])
220214 )
221215 ` ;
222216
@@ -234,13 +228,8 @@ describe('Typescript usage suite', () => {
234228
235229 it ( 'event registration should work' , async function ( ) {
236230 // 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 ) ;
244233
245234 client2 . registerEvent ( 'event_stream' , 'test' ) ;
246235 const resMakingPromise = new Promise ( ( resolve ) => {
@@ -249,7 +238,7 @@ describe('Typescript usage suite', () => {
249238
250239 // act
251240 let script = `
252- (call "${ pid2 . toB58String ( ) } " ("event_stream" "test") [hello])
241+ (call "${ client2 . selfPeerId } " ("event_stream" "test") [hello])
253242 ` ;
254243
255244 let data : Map < string , any > = new Map ( ) ;
0 commit comments