aboutsummaryrefslogtreecommitdiffstats
path: root/eth/downloader/downloader_test.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-05-14 20:38:49 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-05-14 20:38:49 +0800
commit3eda70c64c3b790573751227f8ac0fe42bdc0307 (patch)
treea5f402ea615e2484bf405f845b77ecd229a5842f /eth/downloader/downloader_test.go
parenta4246c2da658d9b5b02a4caba511688748a88b19 (diff)
downloadgo-tangerine-3eda70c64c3b790573751227f8ac0fe42bdc0307.tar
go-tangerine-3eda70c64c3b790573751227f8ac0fe42bdc0307.tar.gz
go-tangerine-3eda70c64c3b790573751227f8ac0fe42bdc0307.tar.bz2
go-tangerine-3eda70c64c3b790573751227f8ac0fe42bdc0307.tar.lz
go-tangerine-3eda70c64c3b790573751227f8ac0fe42bdc0307.tar.xz
go-tangerine-3eda70c64c3b790573751227f8ac0fe42bdc0307.tar.zst
go-tangerine-3eda70c64c3b790573751227f8ac0fe42bdc0307.zip
eth, eth/downloader: remove parent verification from the downlaoder
Diffstat (limited to 'eth/downloader/downloader_test.go')
-rw-r--r--eth/downloader/downloader_test.go26
1 files changed, 9 insertions, 17 deletions
diff --git a/eth/downloader/downloader_test.go b/eth/downloader/downloader_test.go
index c3d1b2e00..2a95b3d8e 100644
--- a/eth/downloader/downloader_test.go
+++ b/eth/downloader/downloader_test.go
@@ -197,10 +197,7 @@ func TestTaking(t *testing.T) {
if err != nil {
t.Error("download error", err)
}
- bs, err := tester.downloader.TakeBlocks()
- if err != nil {
- t.Fatalf("failed to take blocks: %v", err)
- }
+ bs := tester.downloader.TakeBlocks()
if len(bs) != targetBlocks {
t.Error("retrieved block mismatch: have %v, want %v", len(bs), targetBlocks)
}
@@ -280,8 +277,7 @@ func TestThrottling(t *testing.T) {
time.Sleep(time.Millisecond)
}
// Take a batch of blocks and accumulate
- blocks, _ := tester.downloader.TakeBlocks()
- took = append(took, blocks...)
+ took = append(took, tester.downloader.TakeBlocks()...)
}
done <- struct{}{}
}()
@@ -315,14 +311,13 @@ func TestNonExistingParentAttack(t *testing.T) {
if err := tester.sync("attack", hashes[0]); err != nil {
t.Fatalf("failed to synchronise blocks: %v", err)
}
- bs, err := tester.downloader.TakeBlocks()
- if err != ErrUnknownParent {
- t.Fatalf("take error mismatch: have %v, want %v", err, ErrUnknownParent)
+ bs := tester.downloader.TakeBlocks()
+ if len(bs) != 1 {
+ t.Fatalf("retrieved block mismatch: have %v, want %v", len(bs), 1)
}
- if len(bs) != 0 {
- t.Error("retrieved block mismatch: have %v, want %v", len(bs), 0)
+ if tester.hasBlock(bs[0].ParentHash()) {
+ t.Fatalf("tester knows about the unknown hash")
}
- // Cancel the download due to the parent attack
tester.downloader.Cancel()
// Reconstruct a valid chain, and try to synchronize with it
@@ -331,11 +326,8 @@ func TestNonExistingParentAttack(t *testing.T) {
if err := tester.sync("valid", hashes[0]); err != nil {
t.Fatalf("failed to synchronise blocks: %v", err)
}
- bs, err = tester.downloader.TakeBlocks()
- if err != nil {
- t.Fatalf("failed to retrieve blocks: %v", err)
- }
+ bs = tester.downloader.TakeBlocks()
if len(bs) != 1 {
- t.Error("retrieved block mismatch: have %v, want %v", len(bs), 1)
+ t.Fatalf("retrieved block mismatch: have %v, want %v", len(bs), 1)
}
}