File tree 2 files changed +24
-1
lines changed
2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ module.exports = class DAGNode {
51
51
// ensure links are instances of DAGLink
52
52
if ( links ) {
53
53
links . forEach ( ( l ) => {
54
- if ( l . name && typeof l . toJSON === 'function ' ) {
54
+ if ( l . constructor && l . constructor . name === 'DAGLink ' ) {
55
55
this . links . push ( l )
56
56
} else {
57
57
this . links . push (
Original file line number Diff line number Diff line change @@ -213,5 +213,28 @@ module.exports = function (repo) {
213
213
'DAGNode <QmU1Sq1B7RPQD2XcQNLB58qJUyJffVJqihcxmmN1STPMxf - data: "hello world", links: 0, size: 13>'
214
214
)
215
215
} )
216
+
217
+ it ( 'add two nameless links to a node' , function ( done ) {
218
+ const l1 = {
219
+ Name : '' ,
220
+ Hash : 'QmbAmuwox51c91FmC2jEX5Ng4zS4HyVgpA5GNPBF5QsWMA' ,
221
+ Size : 57806
222
+ }
223
+ const l2 = {
224
+ Name : '' ,
225
+ Hash : 'QmP7SrR76KHK9A916RbHG1ufy2TzNABZgiE23PjZDMzZXy' ,
226
+ Size : 262158
227
+ }
228
+ const link1 = new DAGLink ( l1 . Name , l1 . Size , new Buffer ( bs58 . decode ( l1 . Hash ) ) )
229
+ const link2 = new DAGLink ( l2 . Name , l2 . Size , new Buffer ( bs58 . decode ( l2 . Hash ) ) )
230
+
231
+ function createNode ( ) {
232
+ return new DAGNode ( new Buffer ( 'hiya' ) , [ link1 , link2 ] )
233
+ }
234
+
235
+ expect ( createNode ) . to . not . throw ( )
236
+
237
+ done ( )
238
+ } )
216
239
} )
217
240
}
You can’t perform that action at this time.
0 commit comments