This repository was archived by the owner on Mar 10, 2020. It is now read-only.
File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 5
5
const { spawnNodeWithId } = require ( '../utils/spawn' )
6
6
const { getDescribe, getIt, expect } = require ( '../utils/mocha' )
7
7
const delay = require ( '../utils/delay' )
8
+ const CID = require ( 'cids' )
8
9
9
10
module . exports = ( createCommon , options ) => {
10
11
const describe = getDescribe ( options )
@@ -45,6 +46,20 @@ module.exports = (createCommon, options) => {
45
46
. to . eq ( `/ipfs/${ path } ` )
46
47
} )
47
48
49
+ it ( 'should resolve a record from peerid as cidv1 in base32' , async function ( ) {
50
+ this . timeout ( 20 * 1000 )
51
+ const [ { path } ] = await ipfs . add ( Buffer . from ( 'should resolve a record from cidv1b32' ) )
52
+ const { id : peerId } = await ipfs . id ( )
53
+ await ipfs . name . publish ( path , { 'allow-offline' : true } )
54
+
55
+ // Represent Peer ID as CIDv1 Base32
56
+ // https://github.com/libp2p/specs/blob/master/RFC/0001-text-peerid-cid.md
57
+ const keyCid = new CID ( peerId ) . toV1 ( ) . toString ( 'base32' )
58
+ const resolvedPath = await ipfs . name . resolve ( `/ipns/${ keyCid } ` )
59
+
60
+ return expect ( resolvedPath ) . to . equal ( `/ipfs/${ path } ` )
61
+ } )
62
+
48
63
it ( 'should resolve a record recursive === false' , async ( ) => {
49
64
const [ { path } ] = await ipfs . add ( Buffer . from ( 'should resolve a record recursive === false' ) )
50
65
await ipfs . name . publish ( path , { 'allow-offline' : true } )
You can’t perform that action at this time.
0 commit comments