aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-06-19 01:10:07 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-06-19 01:10:07 +0800
commit13c25036ea6afc0b13d1d07be6bc298f2ee24216 (patch)
tree42d3d92416235a54db325967b2b2430c5918be30 /eth
parentecd19919c5ec7118862fc88e2bfac19d4abbff53 (diff)
downloaddexon-13c25036ea6afc0b13d1d07be6bc298f2ee24216.tar.gz
dexon-13c25036ea6afc0b13d1d07be6bc298f2ee24216.tar.zst
dexon-13c25036ea6afc0b13d1d07be6bc298f2ee24216.zip
eth/fetcher: since uncles are allowed, drop phase test
Diffstat (limited to 'eth')
-rw-r--r--eth/fetcher/fetcher_test.go51
1 files changed, 0 insertions, 51 deletions
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))
- }
-}