Tests that direct block enqueues (due to block propagation vs. hash announce) are correctly schedule, filling and import queue gaps.
(t *testing.T)
| 426 | // Tests that direct block enqueues (due to block propagation vs. hash announce) |
| 427 | // are correctly schedule, filling and import queue gaps. |
| 428 | func TestQueueGapFill(t *testing.T) { |
| 429 | // Create a chain of blocks to import, and choose one to not announce at all |
| 430 | targetBlocks := maxQueueDist |
| 431 | hashes, blocks := makeChain(targetBlocks, 0, genesis) |
| 432 | skip := targetBlocks / 2 |
| 433 | |
| 434 | tester := newTester() |
| 435 | headerFetcher := tester.makeHeaderFetcher("valid", blocks, -gatherSlack) |
| 436 | bodyFetcher := tester.makeBodyFetcher("valid", blocks, 0) |
| 437 | |
| 438 | // Iteratively announce blocks, skipping one entry |
| 439 | imported := make(chan *types.Block, len(hashes)-1) |
| 440 | tester.fetcher.importedHook = func(block *types.Block) { imported <- block } |
| 441 | |
| 442 | for i := len(hashes) - 1; i >= 0; i-- { |
| 443 | if i != skip { |
| 444 | tester.fetcher.Notify("valid", hashes[i], uint64(len(hashes)-i-1), time.Now().Add(-arriveTimeout), headerFetcher, bodyFetcher) |
| 445 | time.Sleep(time.Millisecond) |
| 446 | } |
| 447 | } |
| 448 | // Fill the missing block directly as if propagated |
| 449 | tester.fetcher.Enqueue("valid", blocks[hashes[skip]]) |
| 450 | verifyImportCount(t, imported, len(hashes)-1) |
| 451 | } |
| 452 | |
| 453 | // Tests that blocks arriving from various sources (multiple propagations, hash |
| 454 | // announces, etc) do not get scheduled for import multiple times. |
nothing calls this directly
no test coverage detected