This repository was archived by the owner on Mar 10, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 13 files changed +222
-0
lines changed Expand file tree Collapse file tree 13 files changed +222
-0
lines changed Original file line number Diff line number Diff line change @@ -107,5 +107,13 @@ module.exports = (createCommon, options) => {
107107 } )
108108 } )
109109 } )
110+
111+ it ( 'should return an error for an invalid CID' , ( ) => {
112+ return ipfs . block . get ( 'invalid' )
113+ . then (
114+ ( ) => expect . fail ( 'should have returned an error for invalid argument' ) ,
115+ ( err ) => expect ( err ) . to . be . an . instanceof ( Error )
116+ )
117+ } )
110118 } )
111119}
Original file line number Diff line number Diff line change @@ -43,5 +43,21 @@ module.exports = (createCommon, options) => {
4343 done ( )
4444 } )
4545 } )
46+
47+ it ( 'should return error for missing argument' , ( ) => {
48+ return ipfs . block . stat ( null )
49+ . then (
50+ ( ) => expect . fail ( 'should have thrown for missing parameter' ) ,
51+ ( err ) => expect ( err ) . to . be . an . instanceof ( Error )
52+ )
53+ } )
54+
55+ it ( 'should return error for invalid argument' , ( ) => {
56+ return ipfs . block . stat ( 'invalid' )
57+ . then (
58+ ( ) => expect . fail ( 'should have thrown for invalid parameter' ) ,
59+ ( err ) => expect ( err ) . to . be . an . instanceof ( Error )
60+ )
61+ } )
4662 } )
4763}
Original file line number Diff line number Diff line change @@ -60,5 +60,20 @@ module.exports = (createCommon, options) => {
6060 done ( )
6161 } )
6262 } )
63+
64+ it ( 'should prevent duplicate inserts of bootstrap peers' , async ( ) => {
65+ const removed = await ipfs . bootstrap . rm ( null , { all : true } )
66+ expect ( removed ) . to . have . property ( 'Peers' ) . that . is . an ( 'array' )
67+ expect ( removed . Peers ) . to . have . lengthOf ( 0 )
68+
69+ const added = await ipfs . bootstrap . add ( validIp4 )
70+ expect ( added ) . to . have . property ( 'Peers' ) . that . deep . equals ( [ validIp4 ] )
71+
72+ const addedAgain = await ipfs . bootstrap . add ( validIp4 )
73+ expect ( addedAgain ) . to . have . property ( 'Peers' ) . that . deep . equals ( [ validIp4 ] )
74+
75+ const list = await ipfs . bootstrap . list ( )
76+ expect ( list ) . to . have . property ( 'Peers' ) . that . deep . equals ( [ validIp4 ] )
77+ } )
6378 } )
6479}
Original file line number Diff line number Diff line change @@ -72,6 +72,22 @@ module.exports = (createCommon, options) => {
7272 } )
7373 } )
7474
75+ it ( 'should set a boolean' , async ( ) => {
76+ const value = true
77+ const key = 'Datastore.Path'
78+
79+ await ipfs . config . set ( key , value )
80+ expect ( await ipfs . config . get ( key ) ) . to . equal ( value )
81+ } )
82+
83+ it ( 'should set the other boolean' , async ( ) => {
84+ const value = false
85+ const key = 'Datastore.Path'
86+
87+ await ipfs . config . set ( key , value )
88+ expect ( await ipfs . config . get ( key ) ) . to . equal ( value )
89+ } )
90+
7591 it ( 'should set a JSON object' , ( done ) => {
7692 const key = 'API.HTTPHeaders.Access-Control-Allow-Origin'
7793 const val = [ 'http://example.io' ]
Original file line number Diff line number Diff line change @@ -91,5 +91,29 @@ module.exports = (createCommon, options) => {
9191 } )
9292 } )
9393 } )
94+
95+ it ( 'should list an empty directory' , async ( ) => {
96+ const testDir = `/test-${ hat ( ) } `
97+ await ipfs . files . mkdir ( testDir )
98+ const contents = await ipfs . files . ls ( testDir )
99+
100+ expect ( contents ) . to . be . an ( 'array' ) . and . to . be . empty ( )
101+ } )
102+
103+ it ( 'should list an file directly' , async ( ) => {
104+ const fileName = `single-file-${ hat ( ) } .txt`
105+ const filePath = `/${ fileName } `
106+ await ipfs . files . write ( filePath , Buffer . from ( 'Hello world' ) , {
107+ create : true
108+ } )
109+ const contents = await ipfs . files . ls ( filePath )
110+
111+ expect ( contents ) . to . be . an ( 'array' ) . and . have . lengthOf ( 1 ) . and . to . deep . equal ( [ {
112+ hash : '' ,
113+ name : fileName ,
114+ size : 0 ,
115+ type : 0
116+ } ] )
117+ } )
94118 } )
95119}
Original file line number Diff line number Diff line change @@ -118,5 +118,21 @@ module.exports = (createCommon, options) => {
118118 } )
119119 } )
120120 } )
121+
122+ it ( 'returns error for request without argument' , ( ) => {
123+ return ipfs . object . data ( null )
124+ . then (
125+ ( ) => expect . fail ( 'should have returned an error for invalid argument' ) ,
126+ ( err ) => expect ( err ) . to . be . an . instanceof ( Error )
127+ )
128+ } )
129+
130+ it ( 'returns error for request with invalid argument' , ( ) => {
131+ ipfs . object . data ( 'invalid' , { enc : 'base58' } )
132+ . then (
133+ ( ) => expect . fail ( 'should have returned an error for invalid argument' ) ,
134+ ( err ) => expect ( err ) . to . be . an . instanceof ( Error )
135+ )
136+ } )
121137 } )
122138}
Original file line number Diff line number Diff line change @@ -336,5 +336,21 @@ module.exports = (createCommon, options) => {
336336 expect ( meta . fileSize ( ) ) . to . equal ( data . length )
337337 } )
338338 } )
339+
340+ it ( 'should error for request without argument' , ( ) => {
341+ return ipfs . object . get ( null )
342+ . then (
343+ ( ) => expect . fail ( 'should have returned an error for invalid argument' ) ,
344+ ( err ) => expect ( err ) . to . be . an . instanceof ( Error )
345+ )
346+ } )
347+
348+ it ( 'returns error for request with invalid argument' , ( ) => {
349+ return ipfs . object . get ( 'invalid' , { enc : 'base58' } )
350+ . then (
351+ ( ) => expect . fail ( 'should have returned an error for invalid argument' ) ,
352+ ( err ) => expect ( err ) . to . be . an . instanceof ( Error )
353+ )
354+ } )
339355 } )
340356}
Original file line number Diff line number Diff line change @@ -206,5 +206,21 @@ module.exports = (createCommon, options) => {
206206 } )
207207 } )
208208 } )
209+
210+ it ( 'returns error for request without argument' , ( ) => {
211+ return ipfs . object . links ( null )
212+ . then (
213+ ( ) => expect . fail ( 'should have returned an error for invalid argument' ) ,
214+ ( err ) => expect ( err ) . to . be . an . instanceof ( Error )
215+ )
216+ } )
217+
218+ it ( 'returns error for request with invalid argument' , ( ) => {
219+ ipfs . object . links ( 'invalid' , { enc : 'base58' } )
220+ . then (
221+ ( ) => expect . fail ( 'should have returned an error for invalid argument' ) ,
222+ ( err ) => expect ( err ) . to . be . an . instanceof ( Error )
223+ )
224+ } )
209225 } )
210226}
Original file line number Diff line number Diff line change @@ -163,5 +163,21 @@ module.exports = (createCommon, options) => {
163163
164164 expect ( newParentCid ) . to . eql ( nodeFromObjectPatchCid )
165165 } )
166+
167+ it ( 'returns error for request without arguments' , ( ) => {
168+ return ipfs . object . patch . addLink ( null , null , null )
169+ . then (
170+ ( ) => expect . fail ( 'should have returned an error for invalid argument' ) ,
171+ ( err ) => expect ( err ) . to . be . an . instanceof ( Error )
172+ )
173+ } )
174+
175+ it ( 'returns error for request with only one invalid argument' , ( ) => {
176+ return ipfs . object . patch . addLink ( 'invalid' , null , null )
177+ . then (
178+ ( ) => expect . fail ( 'should have returned an error for invalid argument' ) ,
179+ ( err ) => expect ( err ) . to . be . an . instanceof ( Error )
180+ )
181+ } )
166182 } )
167183}
Original file line number Diff line number Diff line change @@ -59,5 +59,23 @@ module.exports = (createCommon, options) => {
5959
6060 expect ( nodeCid ) . to . not . deep . equal ( patchedNodeCid )
6161 } )
62+
63+ it ( 'returns error for request without key & data' , ( ) => {
64+ return ipfs . object . patch . appendData ( null , null )
65+ . then (
66+ ( ) => expect . fail ( 'should have returned an error for invalid argument' ) ,
67+ ( err ) => expect ( err ) . to . be . an . instanceof ( Error )
68+ )
69+ } )
70+
71+ it ( 'returns error for request without data' , ( ) => {
72+ const filePath = 'test/fixtures/test-data/badnode.json'
73+
74+ return ipfs . object . patch . appendData ( null , filePath )
75+ . then (
76+ ( ) => expect . fail ( 'should have returned an error for invalid argument' ) ,
77+ ( err ) => expect ( err ) . to . be . an . instanceof ( Error )
78+ )
79+ } )
6280 } )
6381}
You can’t perform that action at this time.
0 commit comments