aboutsummaryrefslogtreecommitdiffstats
path: root/eth/downloader/downloader_test.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-04-24 21:04:58 +0800
committerobscuren <geffobscura@gmail.com>2015-04-24 21:04:58 +0800
commit31f82eb3347454f64f3d41de3087109d09597806 (patch)
treeec641ffa199d3139e8e142dbe3c6e71be0df4fd9 /eth/downloader/downloader_test.go
parentb86e7526e12a5a49c1739ec02d3c1c5cc667dcb3 (diff)
downloadgo-tangerine-31f82eb3347454f64f3d41de3087109d09597806.tar
go-tangerine-31f82eb3347454f64f3d41de3087109d09597806.tar.gz
go-tangerine-31f82eb3347454f64f3d41de3087109d09597806.tar.bz2
go-tangerine-31f82eb3347454f64f3d41de3087109d09597806.tar.lz
go-tangerine-31f82eb3347454f64f3d41de3087109d09597806.tar.xz
go-tangerine-31f82eb3347454f64f3d41de3087109d09597806.tar.zst
go-tangerine-31f82eb3347454f64f3d41de3087109d09597806.zip
eth, eth/downloader: don't require td on downloader. Fixed tests
Diffstat (limited to 'eth/downloader/downloader_test.go')
-rw-r--r--eth/downloader/downloader_test.go34
1 files changed, 17 insertions, 17 deletions
diff --git a/eth/downloader/downloader_test.go b/eth/downloader/downloader_test.go
index 1d449cfba..ddb3ec7ae 100644
--- a/eth/downloader/downloader_test.go
+++ b/eth/downloader/downloader_test.go
@@ -49,7 +49,7 @@ type downloadTester struct {
func newTester(t *testing.T, hashes []common.Hash, blocks map[common.Hash]*types.Block) *downloadTester {
tester := &downloadTester{t: t, hashes: hashes, blocks: blocks, done: make(chan bool)}
- downloader := New(tester.hasBlock, tester.insertChain, func() *big.Int { return new(big.Int) })
+ downloader := New(tester.hasBlock, tester.insertChain)
tester.downloader = downloader
return tester
@@ -112,7 +112,8 @@ func TestDownload(t *testing.T) {
minDesiredPeerCount = 4
blockTtl = 1 * time.Second
- hashes := createHashes(0, 1000)
+ targetBlocks := 1000
+ hashes := createHashes(0, targetBlocks)
blocks := createBlocksFromHashes(hashes)
tester := newTester(t, hashes, blocks)
@@ -121,21 +122,21 @@ func TestDownload(t *testing.T) {
tester.badBlocksPeer("peer3", big.NewInt(0), common.Hash{})
tester.badBlocksPeer("peer4", big.NewInt(0), common.Hash{})
-success:
- select {
- case <-tester.done:
- break success
- case <-time.After(10 * time.Second): // XXX this could actually fail on a slow computer
- t.Error("timeout")
+ blox, err := tester.downloader.Synchronise("peer1", hashes[0])
+ if err != nil {
+ t.Error("download error", err)
+ }
+
+ if len(blox) != targetBlocks {
+ t.Error("expected", targetBlocks, "have", len(blox))
}
}
func TestMissing(t *testing.T) {
- t.Skip()
-
glog.SetV(logger.Detail)
glog.SetToStderr(true)
+ targetBlocks := 1000
hashes := createHashes(0, 1000)
extraHashes := createHashes(1001, 1003)
blocks := createBlocksFromHashes(append(extraHashes, hashes...))
@@ -146,13 +147,12 @@ func TestMissing(t *testing.T) {
hashes = append(extraHashes, hashes[:len(hashes)-1]...)
tester.newPeer("peer2", big.NewInt(0), common.Hash{})
-success1:
- select {
- case <-tester.done:
- break success1
- case <-time.After(10 * time.Second): // XXX this could actually fail on a slow computer
- t.Error("timout")
+ blox, err := tester.downloader.Synchronise("peer1", hashes[0])
+ if err != nil {
+ t.Error("download error", err)
}
- tester.downloader.AddBlock("peer2", blocks[hashes[len(hashes)-1]], big.NewInt(10001))
+ if len(blox) != targetBlocks {
+ t.Error("expected", targetBlocks, "have", len(blox))
+ }
}