@@ -6,15 +6,18 @@ import { MemoryBlockstore } from 'blockstore-core'
6
6
import delay from 'delay'
7
7
import all from 'it-all'
8
8
import drain from 'it-drain'
9
+ import { CID } from 'multiformats/cid'
9
10
import * as raw from 'multiformats/codecs/raw'
11
+ import { identity } from 'multiformats/hashes/identity'
10
12
import Sinon from 'sinon'
11
13
import { type StubbedInstance , stubInterface } from 'sinon-ts'
14
+ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
15
+ import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
12
16
import { defaultHashers } from '../../src/utils/default-hashers.js'
13
17
import { NetworkedStorage } from '../../src/utils/networked-storage.js'
14
18
import { createBlock } from '../fixtures/create-block.js'
15
19
import type { BlockAnnouncer , BlockRetriever } from '@helia/interface/blocks'
16
20
import type { Blockstore } from 'interface-blockstore'
17
- import type { CID } from 'multiformats/cid'
18
21
19
22
describe ( 'networked-storage' , ( ) => {
20
23
let storage : NetworkedStorage
@@ -185,4 +188,12 @@ describe('networked-storage', () => {
185
188
expect ( await blockstore . has ( blocks [ i ] . cid ) ) . to . be . true ( )
186
189
}
187
190
} )
191
+
192
+ it ( 'supports identity CIDs' , async ( ) => {
193
+ const data = uint8ArrayFromString ( 'hello world' )
194
+ const cid = CID . createV1 ( identity . code , identity . digest ( data ) )
195
+
196
+ const block = await storage . get ( cid )
197
+ expect ( uint8ArrayToString ( block ) ) . to . equal ( 'hello world' )
198
+ } )
188
199
} )
0 commit comments