@@ -11,9 +11,11 @@ const dagCBOR = require('../src')
1111const loadFixture = require ( 'aegir/fixtures' )
1212const bs58 = require ( 'bs58' )
1313const isNode = require ( 'detect-node' )
14+ const CID = require ( 'cids' )
1415
1516const arrayLinkCBOR = loadFixture ( 'test/fixtures/array-link.cbor' )
1617const arrayLinkJSON = require ( './fixtures/array-link.json' )
18+ const arrayLink = arrayLinkJSON . map ( x => new CID ( x [ '/' ] ) )
1719
1820const emptyArrayCBOR = loadFixture ( 'test/fixtures/empty-array.cbor' )
1921const emptyArrayJSON = require ( './fixtures/empty-array.json' )
@@ -41,13 +43,9 @@ describe('dag-cbor interop tests', () => {
4143 dagCBOR . util . deserialize ( arrayLinkCBOR , ( err , node ) => {
4244 expect ( err ) . to . not . exist ( )
4345 // the JSON version that gets out of go-ipfs stringifies the CID
44- const bs58Str = bs58 . encode ( node [ 0 ] [ '/' ] )
46+ const bs58Str = node [ 0 ] . toBaseEncodedString ( )
4547
46- node [ 0 ] [ '/' ] = bs58Str
47- expect ( node ) . to . eql ( arrayLinkJSON )
48-
49- // put it back to bytes
50- node [ 0 ] [ '/' ] = bs58 . decode ( arrayLinkJSON [ 0 ] [ '/' ] )
48+ expect ( bs58Str ) . to . eql ( arrayLink [ 0 ] . toBaseEncodedString ( ) )
5149
5250 dagCBOR . util . cid ( node , ( err , cid ) => {
5351 expect ( err ) . to . not . exist ( )
@@ -94,7 +92,7 @@ describe('dag-cbor interop tests', () => {
9492 dagCBOR . util . cid ( node , ( err , cid ) => {
9593 expect ( err ) . to . not . exist ( )
9694 const cidStr = cid . toBaseEncodedString ( )
97- expect ( cidStr ) . to . eql ( expectedCIDs [ ' foo' ] [ '/' ] )
95+ expect ( cidStr ) . to . eql ( expectedCIDs . foo [ '/' ] )
9896 done ( )
9997 } )
10098 } )
0 commit comments