diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-06-16 19:02:43 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-06-18 20:56:07 +0800 |
commit | 2a1b722d048d00401084c37a5ca12612f1dd5fcd (patch) | |
tree | c6cfa196e671d562915f18c3a4d9e5fc0b50a5fb /eth/downloader | |
parent | 7c2af1c11722dc3175a98342c060afcfaf6a275f (diff) | |
download | dexon-2a1b722d048d00401084c37a5ca12612f1dd5fcd.tar dexon-2a1b722d048d00401084c37a5ca12612f1dd5fcd.tar.gz dexon-2a1b722d048d00401084c37a5ca12612f1dd5fcd.tar.bz2 dexon-2a1b722d048d00401084c37a5ca12612f1dd5fcd.tar.lz dexon-2a1b722d048d00401084c37a5ca12612f1dd5fcd.tar.xz dexon-2a1b722d048d00401084c37a5ca12612f1dd5fcd.tar.zst dexon-2a1b722d048d00401084c37a5ca12612f1dd5fcd.zip |
eth/fetcher: fix timer reset bug, add initial tests
Diffstat (limited to 'eth/downloader')
-rw-r--r-- | eth/downloader/downloader_test.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/eth/downloader/downloader_test.go b/eth/downloader/downloader_test.go index 484cc3218..4fc4e1434 100644 --- a/eth/downloader/downloader_test.go +++ b/eth/downloader/downloader_test.go @@ -52,6 +52,8 @@ func copyBlock(block *types.Block) *types.Block { return createBlock(int(block.Number().Int64()), block.ParentHeaderHash, block.HeaderHash) } +// createBlocksFromHashes assembles a collection of blocks, each having a correct +// place in the given hash chain. func createBlocksFromHashes(hashes []common.Hash) map[common.Hash]*types.Block { blocks := make(map[common.Hash]*types.Block) for i := 0; i < len(hashes); i++ { @@ -64,6 +66,7 @@ func createBlocksFromHashes(hashes []common.Hash) map[common.Hash]*types.Block { return blocks } +// downloadTester is a test simulator for mocking out local block chain. type downloadTester struct { downloader *Downloader @@ -75,6 +78,7 @@ type downloadTester struct { maxHashFetch int // Overrides the maximum number of retrieved hashes } +// newTester creates a new downloader test mocker. func newTester() *downloadTester { tester := &downloadTester{ ownHashes: []common.Hash{knownHash}, @@ -82,9 +86,7 @@ func newTester() *downloadTester { peerHashes: make(map[string][]common.Hash), peerBlocks: make(map[string]map[common.Hash]*types.Block), } - var mux event.TypeMux - downloader := New(&mux, tester.hasBlock, tester.getBlock, tester.insertChain, tester.dropPeer) - tester.downloader = downloader + tester.downloader = New(new(event.TypeMux), tester.hasBlock, tester.getBlock, tester.insertChain, tester.dropPeer) return tester } |