@@ -218,6 +218,29 @@ func TestReconciledLoader(t *testing.T) {
218
218
},
219
219
),
220
220
},
221
+ "remote skips DAG" : {
222
+ root : testChain .TipLink .(cidlink.Link ).Cid ,
223
+ baseStore : testBCStorage ,
224
+ presentRemoteBlocks : testChain .AllBlocks (),
225
+ remoteSeq : append (metadataRange (testChain , 0 , 30 , false ),
226
+ message.GraphSyncLinkMetadatum {
227
+ Link : testChain .LinkTipIndex (30 ).(cidlink.Link ).Cid ,
228
+ Action : graphsync .LinkActionDuplicateDAGSkipped ,
229
+ }),
230
+ steps : append (append ([]step {
231
+ goOnline {},
232
+ injest {metadataStart : 0 , metadataEnd : 31 },
233
+ }, syncLoadRange (testChain , 0 , 30 , false )... ),
234
+ // we should get an error that we're missing a block for our response
235
+ syncLoad {
236
+ loadSeq : 30 ,
237
+ expectedResult : types.AsyncLoadResult {Local : true , Err : graphsync.RemoteMissingBlockErr {
238
+ Link : testChain .LinkTipIndex (30 ),
239
+ Path : testChain .PathTipIndex (30 ),
240
+ }},
241
+ },
242
+ ),
243
+ },
221
244
"remote missing chain that local has" : {
222
245
root : testChain .TipLink .(cidlink.Link ).Cid ,
223
246
baseStore : testBCStorage ,
@@ -251,6 +274,39 @@ func TestReconciledLoader(t *testing.T) {
251
274
syncLoadRange (testChain , 30 , 100 , true )... ,
252
275
),
253
276
},
277
+ "remote skips chain that local has" : {
278
+ root : testChain .TipLink .(cidlink.Link ).Cid ,
279
+ baseStore : testBCStorage ,
280
+ presentRemoteBlocks : testChain .AllBlocks (),
281
+ presentLocalBlocks : testChain .Blocks (30 , 100 ),
282
+ remoteSeq : append (metadataRange (testChain , 0 , 30 , false ),
283
+ message.GraphSyncLinkMetadatum {
284
+ Link : testChain .LinkTipIndex (30 ).(cidlink.Link ).Cid ,
285
+ Action : graphsync .LinkActionDuplicateDAGSkipped ,
286
+ }),
287
+ steps : append (append (append (
288
+ []step {
289
+ goOnline {},
290
+ injest {metadataStart : 0 , metadataEnd : 31 },
291
+ },
292
+ // load the blocks the remote has
293
+ syncLoadRange (testChain , 0 , 30 , false )... ),
294
+ []step {
295
+ // load the block the remote missing says it's missing locally
296
+ syncLoadRange (testChain , 30 , 31 , true )[0 ],
297
+ asyncLoad {loadSeq : 31 },
298
+ // at this point we have no more remote responses, since it's a linear chain
299
+ verifyNoAsyncResult {},
300
+ // we'd expect the remote would terminate here, since we've sent the last missing block
301
+ goOffline {},
302
+ // this will cause us to start loading locally only again
303
+ verifyAsyncResult {
304
+ expectedResult : types.AsyncLoadResult {Local : true , Data : testChain .Blocks (31 , 32 )[0 ].RawData ()},
305
+ },
306
+ }... ),
307
+ syncLoadRange (testChain , 30 , 100 , true )... ,
308
+ ),
309
+ },
254
310
"remote missing chain that local has partial" : {
255
311
root : testChain .TipLink .(cidlink.Link ).Cid ,
256
312
baseStore : testBCStorage ,
@@ -326,6 +382,62 @@ func TestReconciledLoader(t *testing.T) {
326
382
syncLoad {loadSeq : 7 , expectedResult : types.AsyncLoadResult {Local : true , Data : testTree .LeafAlphaBlock .RawData ()}},
327
383
},
328
384
},
385
+ "remote duplicate not sent, blocks can load from local" : {
386
+ root : testTree .RootBlock .Cid (),
387
+ baseStore : testTree .Storage ,
388
+ presentRemoteBlocks : []blocks.Block {
389
+ testTree .RootBlock ,
390
+ testTree .MiddleListBlock ,
391
+ testTree .MiddleMapBlock ,
392
+ testTree .LeafAlphaBlock ,
393
+ testTree .LeafBetaBlock ,
394
+ },
395
+ presentLocalBlocks : nil ,
396
+ remoteSeq : []message.GraphSyncLinkMetadatum {
397
+ {Link : testTree .RootBlock .Cid (), Action : graphsync .LinkActionPresent },
398
+ {Link : testTree .MiddleListBlock .Cid (), Action : graphsync .LinkActionPresent },
399
+ {Link : testTree .LeafAlphaBlock .Cid (), Action : graphsync .LinkActionPresent },
400
+ {Link : testTree .LeafAlphaBlock .Cid (), Action : graphsync .LinkActionDuplicateNotSent },
401
+ {Link : testTree .LeafBetaBlock .Cid (), Action : graphsync .LinkActionPresent },
402
+ {Link : testTree .LeafAlphaBlock .Cid (), Action : graphsync .LinkActionDuplicateNotSent },
403
+ {Link : testTree .MiddleMapBlock .Cid (), Action : graphsync .LinkActionPresent },
404
+ {Link : testTree .LeafAlphaBlock .Cid (), Action : graphsync .LinkActionDuplicateNotSent },
405
+ },
406
+ steps : []step {
407
+ goOnline {},
408
+ injest {metadataStart : 0 , metadataEnd : 8 },
409
+ syncLoad {loadSeq : 0 , expectedResult : types.AsyncLoadResult {Local : false , Data : testTree .RootBlock .RawData ()}},
410
+ syncLoad {loadSeq : 1 , expectedResult : types.AsyncLoadResult {Local : false , Data : testTree .MiddleListBlock .RawData ()}},
411
+ syncLoad {loadSeq : 2 , expectedResult : types.AsyncLoadResult {Local : false , Data : testTree .LeafAlphaBlock .RawData ()}},
412
+ syncLoad {loadSeq : 3 , expectedResult : types.AsyncLoadResult {Local : true , Data : testTree .LeafAlphaBlock .RawData ()}},
413
+ syncLoad {loadSeq : 4 , expectedResult : types.AsyncLoadResult {Local : false , Data : testTree .LeafBetaBlock .RawData ()}},
414
+ syncLoad {loadSeq : 5 , expectedResult : types.AsyncLoadResult {Local : true , Data : testTree .LeafAlphaBlock .RawData ()}},
415
+ syncLoad {loadSeq : 6 , expectedResult : types.AsyncLoadResult {Local : false , Data : testTree .MiddleMapBlock .RawData ()}},
416
+ syncLoad {loadSeq : 7 , expectedResult : types.AsyncLoadResult {Local : true , Data : testTree .LeafAlphaBlock .RawData ()}},
417
+ },
418
+ },
419
+ "remote duplicate not sent load from local even when present in message" : {
420
+ root : testTree .RootBlock .Cid (),
421
+ baseStore : testTree .Storage ,
422
+ presentRemoteBlocks : []blocks.Block {
423
+ testTree .RootBlock ,
424
+ testTree .MiddleListBlock ,
425
+ },
426
+ presentLocalBlocks : []blocks.Block {
427
+ testTree .MiddleListBlock ,
428
+ },
429
+ remoteSeq : []message.GraphSyncLinkMetadatum {
430
+ {Link : testTree .RootBlock .Cid (), Action : graphsync .LinkActionPresent },
431
+ {Link : testTree .MiddleListBlock .Cid (), Action : graphsync .LinkActionDuplicateNotSent },
432
+ },
433
+ steps : []step {
434
+ goOnline {},
435
+ injest {metadataStart : 0 , metadataEnd : 2 },
436
+ syncLoad {loadSeq : 0 , expectedResult : types.AsyncLoadResult {Local : false , Data : testTree .RootBlock .RawData ()}},
437
+ syncLoad {loadSeq : 1 , expectedResult : types.AsyncLoadResult {Local : true , Data : testTree .MiddleListBlock .RawData ()}},
438
+ },
439
+ },
440
+
329
441
"remote missing branch finishes to end" : {
330
442
root : testTree .RootBlock .Cid (),
331
443
baseStore : testTree .Storage ,
@@ -351,6 +463,32 @@ func TestReconciledLoader(t *testing.T) {
351
463
syncLoad {loadSeq : 7 , expectedResult : types.AsyncLoadResult {Local : false , Data : testTree .LeafAlphaBlock .RawData ()}},
352
464
},
353
465
},
466
+
467
+ "remote skipping branch finishes to end" : {
468
+ root : testTree .RootBlock .Cid (),
469
+ baseStore : testTree .Storage ,
470
+ presentRemoteBlocks : []blocks.Block {
471
+ testTree .RootBlock ,
472
+ testTree .MiddleMapBlock ,
473
+ testTree .LeafAlphaBlock ,
474
+ },
475
+ presentLocalBlocks : nil ,
476
+ remoteSeq : []message.GraphSyncLinkMetadatum {
477
+ {Link : testTree .RootBlock .Cid (), Action : graphsync .LinkActionPresent },
478
+ // missing the whole list tree
479
+ {Link : testTree .MiddleListBlock .Cid (), Action : graphsync .LinkActionDuplicateDAGSkipped },
480
+ {Link : testTree .MiddleMapBlock .Cid (), Action : graphsync .LinkActionPresent },
481
+ {Link : testTree .LeafAlphaBlock .Cid (), Action : graphsync .LinkActionPresent },
482
+ },
483
+ steps : []step {
484
+ goOnline {},
485
+ injest {metadataStart : 0 , metadataEnd : 4 },
486
+ syncLoad {loadSeq : 0 , expectedResult : types.AsyncLoadResult {Local : false , Data : testTree .RootBlock .RawData ()}},
487
+ syncLoad {loadSeq : 1 , expectedResult : types.AsyncLoadResult {Local : true , Err : graphsync.RemoteMissingBlockErr {Link : testTree .MiddleListNodeLnk , Path : datamodel .ParsePath ("linkedList" )}}},
488
+ syncLoad {loadSeq : 6 , expectedResult : types.AsyncLoadResult {Local : false , Data : testTree .MiddleMapBlock .RawData ()}},
489
+ syncLoad {loadSeq : 7 , expectedResult : types.AsyncLoadResult {Local : false , Data : testTree .LeafAlphaBlock .RawData ()}},
490
+ },
491
+ },
354
492
"remote missing branch with partial local" : {
355
493
root : testTree .RootBlock .Cid (),
356
494
baseStore : testTree .Storage ,
0 commit comments