Commit a819cee 1 parent 8cbdd15 commit a819cee Copy full SHA for a819cee
File tree 4 files changed +27
-31
lines changed
4 files changed +27
-31
lines changed Original file line number Diff line number Diff line change 1
1
import assert from 'assert'
2
- import { pollFor , newWallet , dumpStream } from './helpers'
2
+ import {
3
+ pollFor ,
4
+ newWallet ,
5
+ dumpStream ,
6
+ newLocalDockerClient ,
7
+ newDevClient ,
8
+ } from './helpers'
3
9
import { publishUserContact , sleep } from '../src/utils'
4
10
import Client , { KeyStoreType } from '../src/Client'
5
11
import { TestKeyCodec , ContentTypeTestKey } from './ContentTypeTestKey'
@@ -13,16 +19,6 @@ import {
13
19
PrivateKeyBundle ,
14
20
} from '../src'
15
21
16
- const newLocalDockerClient = ( ) : Promise < Client > =>
17
- Client . create ( newWallet ( ) , {
18
- bootstrapAddrs : [
19
- '/ip4/127.0.0.1/tcp/9001/ws/p2p/16Uiu2HAmNCxLZCkXNbpVPBpSSnHj9iq4HZQj7fxRzw2kj1kKSHHA' ,
20
- ] ,
21
- } )
22
-
23
- const newTestnetClient = ( ) : Promise < Client > =>
24
- Client . create ( newWallet ( ) , { env : 'dev' } )
25
-
26
22
describe ( 'Client' , ( ) => {
27
23
const tests = [
28
24
{
@@ -32,8 +28,8 @@ describe('Client', () => {
32
28
]
33
29
if ( process . env . CI || process . env . TESTNET ) {
34
30
tests . push ( {
35
- name : 'testnet ' ,
36
- newClient : newTestnetClient ,
31
+ name : 'dev ' ,
32
+ newClient : newDevClient ,
37
33
} )
38
34
}
39
35
tests . forEach ( ( testCase ) => {
Original file line number Diff line number Diff line change 1
1
import { Client } from '../../src'
2
- import { Wallet } from 'ethers'
3
2
import { sleep } from '../../src/utils'
4
-
5
- const opts = {
6
- bootstrapAddrs : [
7
- '/ip4/127.0.0.1/tcp/9001/ws/p2p/16Uiu2HAmNCxLZCkXNbpVPBpSSnHj9iq4HZQj7fxRzw2kj1kKSHHA' ,
8
- ] ,
9
- }
3
+ import { newLocalDockerClient } from '../helpers'
10
4
11
5
jest . setTimeout ( 20000 )
12
6
@@ -15,8 +9,8 @@ describe('conversations', () => {
15
9
let bob : Client
16
10
17
11
beforeEach ( async ( ) => {
18
- alice = await Client . create ( Wallet . createRandom ( ) , opts )
19
- bob = await Client . create ( Wallet . createRandom ( ) , opts )
12
+ alice = await newLocalDockerClient ( )
13
+ bob = await newLocalDockerClient ( )
20
14
} )
21
15
22
16
afterEach ( async ( ) => {
Original file line number Diff line number Diff line change
1
+ import { newLocalDockerClient } from './../helpers'
1
2
import { Client } from '../../src'
2
- import { Wallet } from 'ethers'
3
3
import { sleep } from '../../src/utils'
4
4
5
- const opts = {
6
- bootstrapAddrs : [
7
- '/ip4/127.0.0.1/tcp/9001/ws/p2p/16Uiu2HAmNCxLZCkXNbpVPBpSSnHj9iq4HZQj7fxRzw2kj1kKSHHA' ,
8
- ] ,
9
- }
10
-
11
5
jest . setTimeout ( 20000 )
12
6
13
7
describe ( 'conversations' , ( ) => {
14
8
let alice : Client
15
9
let bob : Client
16
10
17
11
beforeEach ( async ( ) => {
18
- alice = await Client . create ( Wallet . createRandom ( ) , opts )
19
- bob = await Client . create ( Wallet . createRandom ( ) , opts )
12
+ alice = await newLocalDockerClient ( )
13
+ bob = await newLocalDockerClient ( )
20
14
await sleep ( 100 )
21
15
} )
22
16
Original file line number Diff line number Diff line change @@ -5,10 +5,14 @@ import {
5
5
ContentCodec ,
6
6
ContentTypeId ,
7
7
TextCodec ,
8
+ Client ,
8
9
} from '../src'
9
10
import Stream from '../src/Stream'
10
11
import { promiseWithTimeout } from '../src/utils'
11
12
13
+ const LOCAL_DOCKER_MULTIADDR =
14
+ '/ip4/127.0.0.1/tcp/9001/ws/p2p/16Uiu2HAmNCxLZCkXNbpVPBpSSnHj9iq4HZQj7fxRzw2kj1kKSHHA'
15
+
12
16
export const sleep = ( ms : number ) : Promise < void > =>
13
17
new Promise ( ( resolve ) => setTimeout ( resolve , ms ) )
14
18
@@ -89,3 +93,11 @@ export class CodecRegistry {
89
93
return this . _codecs . get ( key )
90
94
}
91
95
}
96
+
97
+ export const newLocalDockerClient = ( ) : Promise < Client > =>
98
+ Client . create ( newWallet ( ) , {
99
+ bootstrapAddrs : [ LOCAL_DOCKER_MULTIADDR ] ,
100
+ } )
101
+
102
+ export const newDevClient = ( ) : Promise < Client > =>
103
+ Client . create ( newWallet ( ) , { env : 'dev' } )
You can’t perform that action at this time.
0 commit comments