From 13c25036ea6afc0b13d1d07be6bc298f2ee24216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Thu, 18 Jun 2015 20:10:07 +0300 Subject: eth/fetcher: since uncles are allowed, drop phase test --- eth/fetcher/fetcher_test.go | 51 --------------------------------------------- 1 file changed, 51 deletions(-) (limited to 'eth/fetcher') diff --git a/eth/fetcher/fetcher_test.go b/eth/fetcher/fetcher_test.go index cdf875c5c..0d069ac65 100644 --- a/eth/fetcher/fetcher_test.go +++ b/eth/fetcher/fetcher_test.go @@ -395,54 +395,3 @@ func TestDistantDiscarding(t *testing.T) { t.Fatalf("fetcher queued future block") } } - -// Tests that if multiple uncles (i.e. blocks at the same height) are queued for -// importing, then they will get inserted in phases, previous heights needing to -// complete before the next numbered blocks can begin. -func TestCompetingImports(t *testing.T) { - // Generate a few soft-forks for concurrent imports - hashesA := createHashes(16, knownHash) - hashesB := createHashes(16, knownHash) - hashesC := createHashes(16, knownHash) - - blocksA := createBlocksFromHashes(hashesA) - blocksB := createBlocksFromHashes(hashesB) - blocksC := createBlocksFromHashes(hashesC) - - // Create a tester, and override the import to check number reversals - tester := newTester() - - first := int32(1) - height := uint64(1) - tester.fetcher.insertChain = func(blocks types.Blocks) (int, error) { - // Check for any phase reordering - if prev := atomic.LoadUint64(&height); blocks[0].NumberU64() < prev { - t.Errorf("phase reversal: have %v, want %v", blocks[0].NumberU64(), prev) - } - atomic.StoreUint64(&height, blocks[0].NumberU64()) - - // Sleep a bit on the first import not to race with the enqueues - if atomic.CompareAndSwapInt32(&first, 1, 0) { - time.Sleep(50 * time.Millisecond) - } - return tester.insertChain(blocks) - } - // Queue up everything but with a missing link - for i := 0; i < len(hashesA)-2; i++ { - tester.fetcher.Enqueue("chain A", blocksA[hashesA[i]]) - tester.fetcher.Enqueue("chain B", blocksB[hashesB[i]]) - tester.fetcher.Enqueue("chain C", blocksC[hashesC[i]]) - } - // Add the three missing links, and wait for a full import - tester.fetcher.Enqueue("chain A", blocksA[hashesA[len(hashesA)-2]]) - tester.fetcher.Enqueue("chain B", blocksB[hashesB[len(hashesB)-2]]) - tester.fetcher.Enqueue("chain C", blocksC[hashesC[len(hashesC)-2]]) - - start := time.Now() - for len(tester.hashes) != len(hashesA) && time.Since(start) < time.Second { - time.Sleep(50 * time.Millisecond) - } - if len(tester.hashes) != len(hashesA) { - t.Fatalf("chain length mismatch: have %v, want %v", len(tester.hashes), len(hashesA)) - } -} -- cgit v1.2.3