@@ -6,21 +6,20 @@ const chai = require('chai')
66const dirtyChai = require ( 'dirty-chai' )
77const expect = chai . expect
88chai . use ( dirtyChai )
9+
910const parallel = require ( 'async/parallel' )
1011
1112const IPFSFactory = require ( 'ipfsd-ctl' )
1213const f = IPFSFactory . create ( { type : 'js' } )
1314
1415const config = {
15- Addresses : {
16- Swarm : [ `/ip4/127.0.0.1/tcp/0` , `/ip4/127.0.0.1/tcp/0/ws` ] ,
17- API : `/ip4/127.0.0.1/tcp/0` ,
18- Gateway : `/ip4/127.0.0.1/tcp/0`
19- } ,
2016 Bootstrap : [ ] ,
2117 Discovery : {
2218 MDNS : {
2319 Enabled : false
20+ } ,
21+ webRTCStar : {
22+ Enabled : false
2423 }
2524 }
2625}
@@ -29,15 +28,15 @@ function createNode (callback) {
2928 f . spawn ( {
3029 exec : './src/cli/bin.js' ,
3130 config,
32- initOptions : { bits : 512 }
31+ initOptions : { bits : 512 } ,
32+ args : [ '--enable-dht-experiment' ]
3333 } , callback )
3434}
3535
36- describe . skip ( 'verify that kad-dht is doing its thing ', ( ) => {
36+ describe ( ' kad-dht is routing content and peers correctly ', ( ) => {
3737 let nodeA
3838 let nodeB
3939 let nodeC
40- // let addrA
4140 let addrB
4241 let addrC
4342
@@ -59,7 +58,6 @@ describe.skip('verify that kad-dht is doing its thing', () => {
5958 ( cb ) => nodeC . id ( cb )
6059 ] , ( err , ids ) => {
6160 expect ( err ) . to . not . exist ( )
62- // addrA = ids[0].addresses[0]
6361 addrB = ids [ 1 ] . addresses [ 0 ]
6462 addrC = ids [ 2 ] . addresses [ 0 ]
6563 parallel ( [
@@ -72,19 +70,37 @@ describe.skip('verify that kad-dht is doing its thing', () => {
7270
7371 after ( ( done ) => parallel ( nodes . map ( ( node ) => ( cb ) => node . stop ( cb ) ) , done ) )
7472
75- it . skip ( 'add a file in C, fetch through B in A' , ( done ) => {
73+ it ( 'add a file in B, fetch in A' , function ( done ) {
74+ this . timeout ( 30 * 1000 )
75+ const file = {
76+ path : 'testfile1.txt' ,
77+ content : Buffer . from ( 'hello kad 1' )
78+ }
79+
80+ nodeB . files . add ( file , ( err , filesAdded ) => {
81+ expect ( err ) . to . not . exist ( )
82+
83+ nodeA . files . cat ( filesAdded [ 0 ] . hash , ( err , data ) => {
84+ expect ( err ) . to . not . exist ( )
85+ expect ( data ) . to . eql ( file . content )
86+ done ( )
87+ } )
88+ } )
89+ } )
90+
91+ it ( 'add a file in C, fetch through B in A' , function ( done ) {
92+ this . timeout ( 30 * 1000 )
7693 const file = {
77- path : 'testfile .txt' ,
78- content : Buffer . from ( 'hello kad' )
94+ path : 'testfile2 .txt' ,
95+ content : Buffer . from ( 'hello kad 2 ' )
7996 }
8097
8198 nodeC . add ( file , ( err , filesAdded ) => {
8299 expect ( err ) . to . not . exist ( )
83100
84101 nodeA . cat ( filesAdded [ 0 ] . hash , ( err , data ) => {
85102 expect ( err ) . to . not . exist ( )
86- expect ( data . length ) . to . equal ( file . data . length )
87- expect ( data ) . to . eql ( file . data )
103+ expect ( data ) . to . eql ( file . content )
88104 done ( )
89105 } )
90106 } )
0 commit comments