@@ -511,6 +511,42 @@ test('can watch downloads and appends', async t => {
511
511
t . end ( )
512
512
} )
513
513
514
+ test ( 'download all' , async t => {
515
+ const { clients, cleanup } = await createMany ( 2 )
516
+
517
+ const client1 = clients [ 0 ]
518
+ const client2 = clients [ 1 ]
519
+ const corestore1 = client1 . corestore ( )
520
+ const corestore2 = client2 . corestore ( )
521
+
522
+ const core1 = corestore1 . get ( )
523
+ await core1 . ready ( )
524
+ await core1 . append ( Buffer . from ( 'zero' , 'utf8' ) )
525
+ await core1 . append ( Buffer . from ( 'one' , 'utf8' ) )
526
+ await core1 . append ( Buffer . from ( 'two' , 'utf8' ) )
527
+ await client1 . network . configure ( core1 . discoveryKey , { announce : true , lookup : true , flush : true } )
528
+
529
+ const core2 = corestore2 . get ( core1 . key )
530
+ await core2 . ready ( )
531
+
532
+ let downloads = 0
533
+ const p = new Promise ( ( resolve ) => {
534
+ core2 . on ( 'download' , ( ) => {
535
+ downloads ++
536
+ if ( downloads === 3 ) resolve ( )
537
+ } )
538
+ } )
539
+
540
+ await client2 . network . configure ( core1 . discoveryKey , { announce : false , lookup : true } )
541
+
542
+ core2 . download ( ) // download all
543
+
544
+ await p
545
+ t . same ( downloads , 3 , '3 downloads' )
546
+ await cleanup ( )
547
+ t . end ( )
548
+ } )
549
+
514
550
function watchDownloadPromise ( core , expectedSeq ) {
515
551
return new Promise ( ( resolve , reject ) => {
516
552
core . once ( 'download' , seq => {
0 commit comments