File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 11/* eslint-env mocha */
22import { generateKeyPair } from '@libp2p/crypto/keys'
33import { expect } from 'aegir/chai'
4+ import { base36 } from 'multiformats/bases/base36'
45import { base58btc } from 'multiformats/bases/base58'
56import { CID } from 'multiformats/cid'
67import { identity } from 'multiformats/hashes/identity'
@@ -44,6 +45,14 @@ describe('PeerId', () => {
4445 expect ( id . toCID ( ) . toString ( ) ) . to . equal ( peerId . toCID ( ) . toString ( ) )
4546 } )
4647
48+ it ( 'should create a PeerId from a CID string' , async ( ) => {
49+ const id = peerIdFromString ( peerId . toCID ( ) . toString ( base36 ) , base36 . decoder )
50+ expect ( id . equals ( peerId ) ) . to . be . true ( )
51+ expect ( id . type ) . to . equal ( type )
52+ expect ( id . toString ( ) ) . to . equal ( peerId . toString ( ) )
53+ expect ( id . toCID ( ) . toString ( ) ) . to . equal ( peerId . toCID ( ) . toString ( ) )
54+ } )
55+
4756 it ( 'should stringify to the public key' , async ( ) => {
4857 expect ( peerId . toString ( ) ) . to . equal ( peerId . publicKey ?. toString ( ) )
4958 } )
You can’t perform that action at this time.
0 commit comments