@@ -14,28 +14,20 @@ const peerIdJSON = require('./peer-test.json')
1414describe ( 'peer-info' ,  ( )  =>  { 
1515  let  pi 
1616
17-   beforeEach ( ( done )  =>  { 
18-     Id . create ( {  bits : 512  } ,  ( err ,  id )  =>  { 
19-       if  ( err )  { 
20-         return  done ( err ) 
21-       } 
22-       pi  =  new  Info ( id ) 
23-       done ( ) 
24-     } ) 
17+   beforeEach ( async  ( )  =>  { 
18+     const  id  =  await  Id . create ( {  bits : 512  } ) 
19+     pi  =  new  Info ( id ) 
2520  } ) 
2621
27-   it ( 'create with Id class' ,  ( done )  =>  { 
28-     Id . create ( {  bits : 512  } ,  ( err ,  id )  =>  { 
29-       expect ( err ) . to . not . exist ( ) 
30-       const  pi  =  new  Info ( id ) 
31-       const  pi2  =  new  Info ( id ) 
32-       expect ( pi . id ) . to . exist ( ) 
33-       expect ( pi . id ) . to . eql ( id ) 
34-       expect ( pi2 ) . to . exist ( ) 
35-       expect ( pi2 . id ) . to . exist ( ) 
36-       expect ( pi2 . id ) . to . eql ( id ) 
37-       done ( ) 
38-     } ) 
22+   it ( 'create with Id class' ,  async  ( )  =>  { 
23+     const  id  =  await  Id . create ( {  bits : 512  } ) 
24+     const  pi  =  new  Info ( id ) 
25+     const  pi2  =  new  Info ( id ) 
26+     expect ( pi . id ) . to . exist ( ) 
27+     expect ( pi . id ) . to . eql ( id ) 
28+     expect ( pi2 ) . to . exist ( ) 
29+     expect ( pi2 . id ) . to . exist ( ) 
30+     expect ( pi2 . id ) . to . eql ( id ) 
3931  } ) 
4032
4133  it ( 'throws when not passing an Id' ,  ( )  =>  { 
@@ -48,34 +40,23 @@ describe('peer-info', () => {
4840    expect ( Info . isPeerInfo ( 'bananas' ) ) . to . equal ( false ) 
4941  } ) 
5042
51-   it ( '.create' ,  function  ( done )  { 
43+   it ( '.create' ,  async   function  ( )  { 
5244    this . timeout ( 20  *  1000 ) 
53-     Info . create ( ( err ,  pi )  =>  { 
54-       expect ( err ) . to . not . exist ( ) 
55-       expect ( pi . id ) . to . exist ( ) 
56-       done ( ) 
57-     } ) 
45+     const  info  =  await  Info . create ( ) 
46+     expect ( info . id ) . to . exist ( ) 
5847  } ) 
5948
60-   it ( 'create with Id as JSON' ,  ( done )  =>  { 
61-     Info . create ( peerIdJSON ,  ( err ,  pi )  =>  { 
62-       expect ( err ) . to . not . exist ( ) 
63-       expect ( pi . id ) . to . exist ( ) 
64-       expect ( pi . id . toJSON ( ) ) . to . eql ( peerIdJSON ) 
65-       done ( ) 
66-     } ) 
49+   it ( 'create with Id as JSON' ,  async  ( )  =>  { 
50+     const  info  =  await  Info . create ( peerIdJSON ) 
51+     expect ( info . id ) . to . exist ( ) 
52+     expect ( info . id . toJSON ( ) ) . to . eql ( peerIdJSON ) 
6753  } ) 
6854
69-   it ( '.create with existing id' ,  ( done )  =>  { 
70-     Id . create ( {  bits : 512  } ,  ( err ,  id )  =>  { 
71-       expect ( err ) . to . not . exist ( ) 
72-       Info . create ( id ,  ( err ,  pi )  =>  { 
73-         expect ( err ) . to . not . exist ( ) 
74-         expect ( pi . id ) . to . exist ( ) 
75-         expect ( pi . id . isEqual ( id ) ) . to . equal ( true ) 
76-         done ( ) 
77-       } ) 
78-     } ) 
55+   it ( '.create with existing id' ,  async  ( )  =>  { 
56+     const  id  =  await  Id . create ( {  bits : 512  } ) 
57+     const  info  =  await  Info . create ( id ) 
58+     expect ( info . id ) . to . exist ( ) 
59+     expect ( info . id . isEqual ( id ) ) . to . equal ( true ) 
7960  } ) 
8061
8162  it ( 'add multiaddr' ,  ( )  =>  { 
0 commit comments