@@ -395,54 +395,3 @@ func TestDistantDiscarding(t *testing.T) {
395
395
t .Fatalf ("fetcher queued future block" )
396
396
}
397
397
}
398
-
399
- // Tests that if multiple uncles (i.e. blocks at the same height) are queued for
400
- // importing, then they will get inserted in phases, previous heights needing to
401
- // complete before the next numbered blocks can begin.
402
- func TestCompetingImports (t * testing.T ) {
403
- // Generate a few soft-forks for concurrent imports
404
- hashesA := createHashes (16 , knownHash )
405
- hashesB := createHashes (16 , knownHash )
406
- hashesC := createHashes (16 , knownHash )
407
-
408
- blocksA := createBlocksFromHashes (hashesA )
409
- blocksB := createBlocksFromHashes (hashesB )
410
- blocksC := createBlocksFromHashes (hashesC )
411
-
412
- // Create a tester, and override the import to check number reversals
413
- tester := newTester ()
414
-
415
- first := int32 (1 )
416
- height := uint64 (1 )
417
- tester .fetcher .insertChain = func (blocks types.Blocks ) (int , error ) {
418
- // Check for any phase reordering
419
- if prev := atomic .LoadUint64 (& height ); blocks [0 ].NumberU64 () < prev {
420
- t .Errorf ("phase reversal: have %v, want %v" , blocks [0 ].NumberU64 (), prev )
421
- }
422
- atomic .StoreUint64 (& height , blocks [0 ].NumberU64 ())
423
-
424
- // Sleep a bit on the first import not to race with the enqueues
425
- if atomic .CompareAndSwapInt32 (& first , 1 , 0 ) {
426
- time .Sleep (50 * time .Millisecond )
427
- }
428
- return tester .insertChain (blocks )
429
- }
430
- // Queue up everything but with a missing link
431
- for i := 0 ; i < len (hashesA )- 2 ; i ++ {
432
- tester .fetcher .Enqueue ("chain A" , blocksA [hashesA [i ]])
433
- tester .fetcher .Enqueue ("chain B" , blocksB [hashesB [i ]])
434
- tester .fetcher .Enqueue ("chain C" , blocksC [hashesC [i ]])
435
- }
436
- // Add the three missing links, and wait for a full import
437
- tester .fetcher .Enqueue ("chain A" , blocksA [hashesA [len (hashesA )- 2 ]])
438
- tester .fetcher .Enqueue ("chain B" , blocksB [hashesB [len (hashesB )- 2 ]])
439
- tester .fetcher .Enqueue ("chain C" , blocksC [hashesC [len (hashesC )- 2 ]])
440
-
441
- start := time .Now ()
442
- for len (tester .hashes ) != len (hashesA ) && time .Since (start ) < time .Second {
443
- time .Sleep (50 * time .Millisecond )
444
- }
445
- if len (tester .hashes ) != len (hashesA ) {
446
- t .Fatalf ("chain length mismatch: have %v, want %v" , len (tester .hashes ), len (hashesA ))
447
- }
448
- }
0 commit comments