aboutsummaryrefslogtreecommitdiffstats
path: root/eth/downloader/queue_test.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-05-06 20:32:53 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-05-07 15:57:34 +0800
commit4800c94392e814a2cb9d343aab4706be0cd0851d (patch)
treebff7b3bf3763d58451dcee85961e05895da3ca5d /eth/downloader/queue_test.go
parent97c37356fdcfac8b704c3d75b33e322a737c4e55 (diff)
downloaddexon-4800c94392e814a2cb9d343aab4706be0cd0851d.tar.gz
dexon-4800c94392e814a2cb9d343aab4706be0cd0851d.tar.zst
dexon-4800c94392e814a2cb9d343aab4706be0cd0851d.zip
eth/downloader: prioritize block fetch based on chain position, cap memory use
Diffstat (limited to 'eth/downloader/queue_test.go')
-rw-r--r--eth/downloader/queue_test.go17
1 files changed, 8 insertions, 9 deletions
diff --git a/eth/downloader/queue_test.go b/eth/downloader/queue_test.go
index b163bd9c7..b1f3591f3 100644
--- a/eth/downloader/queue_test.go
+++ b/eth/downloader/queue_test.go
@@ -32,31 +32,30 @@ func createBlocksFromHashSet(hashes *set.Set) []*types.Block {
}
func TestChunking(t *testing.T) {
- queue := newqueue()
+ queue := newQueue()
peer1 := newPeer("peer1", common.Hash{}, nil, nil)
peer2 := newPeer("peer2", common.Hash{}, nil, nil)
// 99 + 1 (1 == known genesis hash)
hashes := createHashes(0, 99)
- hashSet := createHashSet(hashes)
- queue.put(hashSet)
+ queue.Insert(hashes)
- chunk1 := queue.get(peer1, 99)
+ chunk1 := queue.Reserve(peer1, 99)
if chunk1 == nil {
t.Errorf("chunk1 is nil")
t.FailNow()
}
- chunk2 := queue.get(peer2, 99)
+ chunk2 := queue.Reserve(peer2, 99)
if chunk2 == nil {
t.Errorf("chunk2 is nil")
t.FailNow()
}
- if chunk1.hashes.Size() != 99 {
- t.Error("expected chunk1 hashes to be 99, got", chunk1.hashes.Size())
+ if len(chunk1.Hashes) != 99 {
+ t.Error("expected chunk1 hashes to be 99, got", len(chunk1.Hashes))
}
- if chunk2.hashes.Size() != 1 {
- t.Error("expected chunk1 hashes to be 1, got", chunk2.hashes.Size())
+ if len(chunk2.Hashes) != 1 {
+ t.Error("expected chunk1 hashes to be 1, got", len(chunk2.Hashes))
}
}