diff options
author | obscuren <geffobscura@gmail.com> | 2015-04-24 21:56:18 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-04-24 21:56:18 +0800 |
commit | a9e4b96573f7ce900227f0b19d621e363330d914 (patch) | |
tree | ee33b1f245b3b90b82e1bf6600e01c6b2ee298aa /eth/downloader | |
parent | d84c2202e79c30ec906b1a078bfd9fdf5ae94a31 (diff) | |
download | go-tangerine-a9e4b96573f7ce900227f0b19d621e363330d914.tar go-tangerine-a9e4b96573f7ce900227f0b19d621e363330d914.tar.gz go-tangerine-a9e4b96573f7ce900227f0b19d621e363330d914.tar.bz2 go-tangerine-a9e4b96573f7ce900227f0b19d621e363330d914.tar.lz go-tangerine-a9e4b96573f7ce900227f0b19d621e363330d914.tar.xz go-tangerine-a9e4b96573f7ce900227f0b19d621e363330d914.tar.zst go-tangerine-a9e4b96573f7ce900227f0b19d621e363330d914.zip |
eth/downloader: fixed tests
Diffstat (limited to 'eth/downloader')
-rw-r--r-- | eth/downloader/downloader_test.go | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/eth/downloader/downloader_test.go b/eth/downloader/downloader_test.go index ddb3ec7ae..8843ca0c7 100644 --- a/eth/downloader/downloader_test.go +++ b/eth/downloader/downloader_test.go @@ -65,10 +65,6 @@ func (dl *downloadTester) hasBlock(hash common.Hash) bool { func (dl *downloadTester) insertChain(blocks types.Blocks) error { dl.insertedBlocks += len(blocks) - if len(dl.blocks)-1 <= dl.insertedBlocks { - dl.done <- true - } - return nil } @@ -93,14 +89,14 @@ func (dl *downloadTester) getBlocks(id string) func([]common.Hash) error { func (dl *downloadTester) newPeer(id string, td *big.Int, hash common.Hash) { dl.pcount++ - dl.downloader.RegisterPeer(id, td, hash, dl.getHashes, dl.getBlocks(id)) + dl.downloader.RegisterPeer(id, hash, dl.getHashes, dl.getBlocks(id)) } func (dl *downloadTester) badBlocksPeer(id string, td *big.Int, hash common.Hash) { dl.pcount++ // This bad peer never returns any blocks - dl.downloader.RegisterPeer(id, td, hash, dl.getHashes, func([]common.Hash) error { + dl.downloader.RegisterPeer(id, hash, dl.getHashes, func([]common.Hash) error { return nil }) } @@ -122,13 +118,13 @@ func TestDownload(t *testing.T) { tester.badBlocksPeer("peer3", big.NewInt(0), common.Hash{}) tester.badBlocksPeer("peer4", big.NewInt(0), common.Hash{}) - blox, err := tester.downloader.Synchronise("peer1", hashes[0]) + 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)) + if tester.insertedBlocks != targetBlocks { + t.Error("expected", targetBlocks, "have", tester.insertedBlocks) } } @@ -147,12 +143,12 @@ func TestMissing(t *testing.T) { hashes = append(extraHashes, hashes[:len(hashes)-1]...) tester.newPeer("peer2", big.NewInt(0), common.Hash{}) - blox, err := tester.downloader.Synchronise("peer1", hashes[0]) + 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)) + if tester.insertedBlocks != targetBlocks { + t.Error("expected", targetBlocks, "have", tester.insertedBlocks) } } |