File tree Expand file tree Collapse file tree 2 files changed +12
-14
lines changed
Expand file tree Collapse file tree 2 files changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -75,10 +75,4 @@ module.exports = class Hyperblobs {
7575 this . monitors . add ( monitor )
7676 return monitor
7777 }
78-
79- // closeMonitors () {
80- // const closing = []
81- // for (const monitor of this.monitors) closing.push(monitor.close())
82- // await Promise.allSettled(closing)
83- // }
8478}
Original file line number Diff line number Diff line change @@ -363,14 +363,18 @@ test('upload/download can be monitored', async (t) => {
363363 t . alike ( controRes , buf )
364364} )
365365
366- // test('monitor is removed from the Set on close', async (t) => {
367- // const { drive } = await testenv(t)
368- // const monitor = drive.monitor('/example.md')
369- // await monitor.ready()
370- // t.is(drive.monitors.size, 1)
371- // await monitor.close()
372- // t.is(drive.monitors.size, 0)
373- // })
366+ test ( 'monitor is removed from the Set on close' , async ( t ) => {
367+ const core = new Hypercore ( RAM )
368+ const blobs = new Hyperblobs ( core )
369+
370+ const bytes = 1024 * 100 // big enough to trigger more than one update event
371+ const buf = Buffer . alloc ( bytes , '0' )
372+ const id = await blobs . put ( buf )
373+ const monitor = blobs . monitor ( id )
374+ t . is ( blobs . monitors . size , 1 )
375+ await monitor . close ( )
376+ t . is ( blobs . monitors . size , 0 )
377+ } )
374378
375379async function createPair ( ) {
376380 const a = new Hypercore ( RAM )
You can’t perform that action at this time.
0 commit comments