@@ -13,19 +13,19 @@ import last from 'it-last'
13
13
/**
14
14
* @typedef {import('ipfsd-ctl').Controller } Controller
15
15
* @typedef {import('ipfsd-ctl').Factory } Factory
16
+ * @typedef {import('ipfsd-ctl').ControllerOptions } ControllerOptions
16
17
*/
17
18
18
19
/**
19
20
* @param {string } dir
20
21
* @param {number } depth
21
- * @param {number } num
22
+ * @param {number } numFiles
22
23
*/
23
- async function * randomDir ( dir , depth , num ) {
24
+ async function * dirContent ( dir , depth , numFiles ) {
24
25
const dirs = new Array ( depth ) . fill ( 0 ) . map ( ( ) => nanoid ( ) )
25
26
26
- for ( let i = 0 ; i < num ; i ++ ) {
27
- const index = Math . round ( Math . random ( ) * depth )
28
- const path = `${ dir } /${ dirs . slice ( 0 , index ) . join ( '/' ) } /${ nanoid ( ) } .txt`
27
+ for ( let i = 0 ; i < numFiles ; i ++ ) {
28
+ const path = `${ dir } /${ dirs . slice ( 0 , depth ) . join ( '/' ) } /${ nanoid ( ) } .txt`
29
29
30
30
yield {
31
31
path,
@@ -51,57 +51,35 @@ const sizes = [
51
51
8 * MB ,
52
52
64 * MB ,
53
53
128 * MB
54
- // 512 * MB
55
- // GB
56
- // 10 * GB,
57
- // 100 * GB,
58
- // 1000 * GB
59
54
]
60
55
61
- if ( isCi ) {
62
- sizes . push (
63
- // 512 * MB,
64
- // GB
65
- // 10 * GB,
66
- // 100 * GB,
67
- // 1000 * GB
68
- )
69
- }
70
-
71
56
const dirs = [
72
57
5 ,
73
58
10
74
- // 50,
75
- // 100,
76
- // 1000,
77
- // 10000
78
59
]
79
60
80
- if ( isCi ) {
81
- dirs . push (
82
- // 50,
83
- // 100,
84
- // 1000
85
- // 10000
86
- )
87
- }
88
-
89
61
const depth = [
90
62
5 ,
91
63
10
92
64
]
93
65
94
- if ( isCi ) {
95
- depth . push (
96
- // 100
97
- // 1000
98
- // 10000
99
- )
100
- }
101
-
102
66
const min = 60 * 1000
103
67
const timeout = isCi ? 2 * min : min
104
68
69
+ /**
70
+ * @type {ControllerOptions }
71
+ */
72
+ const daemonOptions = {
73
+ test : true ,
74
+ ipfsOptions : {
75
+ config : {
76
+ Routing : {
77
+ Type : 'none'
78
+ }
79
+ }
80
+ }
81
+ }
82
+
105
83
describe ( 'exchange files' , function ( ) {
106
84
this . timeout ( timeout )
107
85
@@ -128,7 +106,7 @@ describe('exchange files', function () {
128
106
let daemon2
129
107
130
108
before ( 'spawn nodes' , async function ( ) {
131
- [ daemon1 , daemon2 ] = await Promise . all ( tests [ name ] . map ( type => factory . spawn ( { type } ) ) )
109
+ [ daemon1 , daemon2 ] = await Promise . all ( tests [ name ] . map ( type => factory . spawn ( { ... daemonOptions , type } ) ) )
132
110
} )
133
111
134
112
before ( 'connect' , async function ( ) {
@@ -163,7 +141,7 @@ describe('exchange files', function () {
163
141
it ( `${ name } : depth: ${ d } , num: ${ num } ` , async function ( ) {
164
142
const dir = `/${ nanoid ( ) } `
165
143
166
- const res = await last ( daemon1 . api . addAll ( randomDir ( dir , d , num ) , {
144
+ const res = await last ( daemon1 . api . addAll ( dirContent ( dir , d , num ) , {
167
145
wrapWithDirectory : true
168
146
} ) )
169
147
0 commit comments