@@ -7,6 +7,7 @@ const Readable = require('stream').Readable
7
7
const path = require ( 'path' )
8
8
const isNode = require ( 'detect-node' )
9
9
const fs = require ( 'fs' )
10
+ const bs58 = require ( 'bs58' )
10
11
11
12
let testfile
12
13
let testfileBig
@@ -37,8 +38,9 @@ describe('.add', () => {
37
38
expect ( err ) . to . not . exist
38
39
39
40
const added = res [ 0 ] != null ? res [ 0 ] : res
40
- expect ( added ) . to . have . property ( 'Hash' , 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' )
41
- expect ( added ) . to . have . property ( 'Name' , 'testfile.txt' )
41
+ const mh = bs58 . encode ( added . multihash ( ) ) . toString ( )
42
+ expect ( mh ) . to . equal ( 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' )
43
+ expect ( added . links ) . to . have . length ( 0 )
42
44
done ( )
43
45
} )
44
46
} )
@@ -49,7 +51,9 @@ describe('.add', () => {
49
51
expect ( err ) . to . not . exist
50
52
51
53
expect ( res ) . to . have . length ( 1 )
52
- expect ( res [ 0 ] ) . to . have . property ( 'Hash' , 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' )
54
+ const mh = bs58 . encode ( res [ 0 ] . multihash ( ) ) . toString ( )
55
+ expect ( mh ) . to . equal ( 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' )
56
+ expect ( res [ 0 ] . links ) . to . have . length ( 0 )
53
57
done ( )
54
58
} )
55
59
} )
@@ -63,7 +67,9 @@ describe('.add', () => {
63
67
expect ( err ) . to . not . exist
64
68
65
69
expect ( res ) . to . have . length ( 1 )
66
- expect ( res [ 0 ] ) . to . have . a . property ( 'Hash' , 'Qme79tX2bViL26vNjPsF3DP1R9rMKMvnPYJiKTTKPrXJjq' )
70
+ const mh = bs58 . encode ( res [ 0 ] . multihash ( ) ) . toString ( )
71
+ expect ( mh ) . to . equal ( 'Qmcx5werSWQPdrGVap7LARHB4QUSPRPJwxhFuHvdoXqQXT' )
72
+ expect ( res [ 0 ] . links ) . to . have . length ( 58 )
67
73
done ( )
68
74
} )
69
75
} )
@@ -77,7 +83,9 @@ describe('.add', () => {
77
83
expect ( err ) . to . not . exist
78
84
79
85
const added = res [ 0 ] != null ? res [ 0 ] : res
80
- expect ( added ) . to . have . property ( 'Hash' , 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' )
86
+ const mh = bs58 . encode ( added . multihash ( ) ) . toString ( )
87
+ expect ( mh ) . to . equal ( 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' )
88
+ expect ( added . links ) . to . have . length ( 0 )
81
89
done ( )
82
90
} )
83
91
} )
@@ -88,14 +96,9 @@ describe('.add', () => {
88
96
expect ( err ) . to . not . exist
89
97
90
98
const added = res [ res . length - 1 ]
91
- expect ( added ) . to . have . property ( 'Hash' , 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6' )
92
-
93
- // check that the symlink was replaced by the target file
94
- const linkPath = 'test-folder/hello-link'
95
- const filePath = 'test-folder/files/hello.txt'
96
- const linkHash = res . filter ( ( e ) => e . Name === linkPath ) [ 0 ] . Hash
97
- const fileHash = res . filter ( ( e ) => e . Name === filePath ) [ 0 ] . Hash
98
- expect ( linkHash ) . to . equal ( fileHash )
99
+ const mh = bs58 . encode ( added . multihash ( ) ) . toString ( )
100
+ expect ( mh ) . to . equal ( 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6' )
101
+ expect ( added . links ) . to . have . length ( 7 )
99
102
100
103
done ( )
101
104
} else {
@@ -112,7 +115,9 @@ describe('.add', () => {
112
115
113
116
const added = res [ res . length - 1 ]
114
117
// same hash as the result from the cli (ipfs add test/test-folder -r)
115
- expect ( added ) . to . have . property ( 'Hash' , 'QmRArDYd8Rk7Zb7K2699KqmQM1uUoejn1chtEAcqkvjzGg' )
118
+ const mh = bs58 . encode ( added . multihash ( ) ) . toString ( )
119
+ expect ( mh ) . to . equal ( 'QmRArDYd8Rk7Zb7K2699KqmQM1uUoejn1chtEAcqkvjzGg' )
120
+ expect ( added . links ) . to . have . length ( 7 )
116
121
done ( )
117
122
} else {
118
123
expect ( err . message ) . to . be . equal ( 'Recursive uploads are not supported in the browser' )
@@ -147,7 +152,9 @@ describe('.add', () => {
147
152
expect ( err ) . to . not . exist
148
153
149
154
const added = res [ res . length - 1 ]
150
- expect ( added ) . to . have . property ( 'Hash' , 'QmTDH2RXGn8XyDAo9YyfbZAUXwL1FCr44YJCN9HBZmL9Gj' )
155
+ const mh = bs58 . encode ( added . multihash ( ) ) . toString ( )
156
+ expect ( mh ) . to . equal ( 'QmTDH2RXGn8XyDAo9YyfbZAUXwL1FCr44YJCN9HBZmL9Gj' )
157
+ expect ( added . links ) . to . have . length ( 6 )
151
158
done ( )
152
159
} )
153
160
} )
@@ -161,7 +168,9 @@ describe('.add', () => {
161
168
expect ( err ) . to . not . exist
162
169
163
170
const added = res [ 0 ] != null ? res [ 0 ] : res
164
- expect ( added ) . to . have . a . property ( 'Hash' , 'QmNRCQWfgze6AbBCaT1rkrkV5tJ2aP4oTNPb5JZcXYywve' )
171
+ const mh = bs58 . encode ( added . multihash ( ) ) . toString ( )
172
+ expect ( mh ) . to . equal ( 'QmNRCQWfgze6AbBCaT1rkrkV5tJ2aP4oTNPb5JZcXYywve' )
173
+ expect ( added . links ) . to . have . length ( 0 )
165
174
done ( )
166
175
} )
167
176
} )
@@ -172,7 +181,9 @@ describe('.add', () => {
172
181
expect ( err ) . to . not . exist
173
182
174
183
const added = res [ 0 ] != null ? res [ 0 ] : res
175
- expect ( added ) . to . have . a . property ( 'Hash' , 'QmZmHgEX9baxUn3qMjsEXQzG6DyNcrVnwieQQTrpDdrFvt' )
184
+ const mh = bs58 . encode ( added . multihash ( ) ) . toString ( )
185
+ expect ( mh ) . to . equal ( 'QmRzvSX35JpzQ2Lyn55r3YwWqdVP6PPxYHFpiWpwQTff8A' )
186
+ expect ( added . links ) . to . have . length ( 0 )
176
187
done ( )
177
188
} )
178
189
} )
@@ -182,8 +193,10 @@ describe('.add', () => {
182
193
let buf = new Buffer ( testfile )
183
194
return apiClients . a . add ( buf )
184
195
. then ( ( res ) => {
185
- expect ( res ) . to . have . length ( 1 )
186
- expect ( res [ 0 ] ) . to . have . property ( 'Hash' , 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' )
196
+ const added = res [ 0 ] != null ? res [ 0 ] : res
197
+ const mh = bs58 . encode ( added . multihash ( ) ) . toString ( )
198
+ expect ( mh ) . to . equal ( 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' )
199
+ expect ( added . links ) . to . have . length ( 0 )
187
200
} )
188
201
} )
189
202
} )
0 commit comments