11/* eslint-env mocha */
22'use strict'
33
4- const chai = require ( 'chai' )
5- const chaiAsProised = require ( 'chai-as-promised' )
6- const dirtyChai = require ( 'dirty-chai' )
7- const expect = chai . expect
8- chai . use ( chaiAsProised )
9- chai . use ( dirtyChai )
4+ const { expect } = require ( 'aegir/utils/chai' )
105const dagPB = require ( 'ipld-dag-pb' )
116const multihash = require ( 'multihashes' )
127const multicodec = require ( 'multicodec' )
13- const { Buffer } = require ( 'buffer ' )
8+ const uint8ArrayFromString = require ( 'uint8arrays/from-string ' )
149const inMemory = require ( 'ipld-in-memory' )
1510
1611const IPLDResolver = require ( '../src' )
@@ -27,9 +22,9 @@ describe('IPLD Resolver with dag-pb (MerkleDAG Protobuf)', () => {
2722 before ( async ( ) => {
2823 resolver = await inMemory ( IPLDResolver )
2924
30- node1 = new dagPB . DAGNode ( Buffer . from ( 'I am 1' ) )
31- node2 = new dagPB . DAGNode ( Buffer . from ( 'I am 2' ) )
32- node3 = new dagPB . DAGNode ( Buffer . from ( 'I am 3' ) )
25+ node1 = new dagPB . DAGNode ( uint8ArrayFromString ( 'I am 1' ) )
26+ node2 = new dagPB . DAGNode ( uint8ArrayFromString ( 'I am 2' ) )
27+ node3 = new dagPB . DAGNode ( uint8ArrayFromString ( 'I am 3' ) )
3328 const serialized1 = dagPB . util . serialize ( node1 )
3429 cid1 = await dagPB . util . cid ( serialized1 )
3530 node2 . addLink ( {
@@ -80,7 +75,7 @@ describe('IPLD Resolver with dag-pb (MerkleDAG Protobuf)', () => {
8075 const result = resolver . resolve ( cid1 , 'Data' )
8176 const node = await result . first ( )
8277 expect ( node . remainderPath ) . to . eql ( '' )
83- expect ( node . value ) . to . eql ( Buffer . from ( 'I am 1' ) )
78+ expect ( node . value ) . to . eql ( uint8ArrayFromString ( 'I am 1' ) )
8479 } )
8580
8681 it ( 'resolves a value within nested scope (1 level)' , async ( ) => {
@@ -91,7 +86,7 @@ describe('IPLD Resolver with dag-pb (MerkleDAG Protobuf)', () => {
9186 expect ( node1 . value . equals ( cid1 ) ) . to . be . true ( )
9287
9388 expect ( node2 . remainderPath ) . to . eql ( '' )
94- expect ( node2 . value ) . to . eql ( Buffer . from ( 'I am 1' ) )
89+ expect ( node2 . value ) . to . eql ( uint8ArrayFromString ( 'I am 1' ) )
9590 } )
9691
9792 it ( 'resolves value within nested scope (2 levels)' , async ( ) => {
@@ -105,7 +100,7 @@ describe('IPLD Resolver with dag-pb (MerkleDAG Protobuf)', () => {
105100 expect ( node2 . value . equals ( cid1 ) ) . to . be . true ( )
106101
107102 expect ( node3 . remainderPath ) . to . eql ( '' )
108- expect ( node3 . value ) . to . eql ( Buffer . from ( 'I am 1' ) )
103+ expect ( node3 . value ) . to . eql ( uint8ArrayFromString ( 'I am 1' ) )
109104 } )
110105
111106 it ( 'resolves value within nested scope (2 levels) with named links' , async ( ) => {
@@ -119,7 +114,7 @@ describe('IPLD Resolver with dag-pb (MerkleDAG Protobuf)', () => {
119114 expect ( node2 . value . equals ( cid1 ) ) . to . be . true ( )
120115
121116 expect ( node3 . remainderPath ) . to . eql ( '' )
122- expect ( node3 . value ) . to . eql ( Buffer . from ( 'I am 1' ) )
117+ expect ( node3 . value ) . to . eql ( uint8ArrayFromString ( 'I am 1' ) )
123118 } )
124119
125120 it ( 'resolver.get round-trip' , async ( ) => {
@@ -135,7 +130,7 @@ describe('IPLD Resolver with dag-pb (MerkleDAG Protobuf)', () => {
135130 // seems to be some race condition with inserting and removing items.
136131 // Hence create a unique item for this test. Though the tests
137132 // should really be independent so that there are no race conditions.
138- const node = new dagPB . DAGNode ( Buffer . from ( 'a dag-pb node' ) )
133+ const node = new dagPB . DAGNode ( uint8ArrayFromString ( 'a dag-pb node' ) )
139134 const cid = await resolver . put ( node , multicodec . DAG_PB )
140135 const sameAsNode = await resolver . get ( cid )
141136 // `size` is lazy, without a call to it a deep equal check would fail
@@ -151,7 +146,7 @@ describe('IPLD Resolver with dag-pb (MerkleDAG Protobuf)', () => {
151146 } )
152147
153148 it ( 'should return a v0 CID when specified' , async ( ) => {
154- const node = new dagPB . DAGNode ( Buffer . from ( 'a dag-pb node' ) )
149+ const node = new dagPB . DAGNode ( uint8ArrayFromString ( 'a dag-pb node' ) )
155150 const cid = await resolver . put ( node , multicodec . DAG_PB , {
156151 cidVersion : 0
157152 } )
@@ -160,7 +155,7 @@ describe('IPLD Resolver with dag-pb (MerkleDAG Protobuf)', () => {
160155 } )
161156
162157 it ( 'should return a v1 CID when specified' , async ( ) => {
163- const node = new dagPB . DAGNode ( Buffer . from ( 'a dag-pb node' ) )
158+ const node = new dagPB . DAGNode ( uint8ArrayFromString ( 'a dag-pb node' ) )
164159 const cid = await resolver . put ( node , multicodec . DAG_PB , {
165160 cidVersion : 1
166161 } )
0 commit comments