mirror of https://github.com/status-im/op-geth.git
eth/downloader: remove uneeded testing functions
This commit is contained in:
parent
66d3dc8690
commit
2937903299
|
@ -214,18 +214,13 @@ func TestBlockTaking(t *testing.T) {
|
||||||
|
|
||||||
// Tests that an inactive downloader will not accept incoming hashes and blocks.
|
// Tests that an inactive downloader will not accept incoming hashes and blocks.
|
||||||
func TestInactiveDownloader(t *testing.T) {
|
func TestInactiveDownloader(t *testing.T) {
|
||||||
// Create a small enough block chain to download and the tester
|
|
||||||
targetBlocks := blockCacheLimit - 15
|
|
||||||
hashes := createHashes(0, targetBlocks)
|
|
||||||
blocks := createBlocksFromHashSet(createHashSet(hashes))
|
|
||||||
|
|
||||||
tester := newTester(t, nil, nil)
|
tester := newTester(t, nil, nil)
|
||||||
|
|
||||||
// Check that neither hashes nor blocks are accepted
|
// Check that neither hashes nor blocks are accepted
|
||||||
if err := tester.downloader.DeliverHashes("bad peer", hashes); err != errNoSyncActive {
|
if err := tester.downloader.DeliverHashes("bad peer", []common.Hash{}); err != errNoSyncActive {
|
||||||
t.Errorf("error mismatch: have %v, want %v", err, errNoSyncActive)
|
t.Errorf("error mismatch: have %v, want %v", err, errNoSyncActive)
|
||||||
}
|
}
|
||||||
if err := tester.downloader.DeliverBlocks("bad peer", blocks); err != errNoSyncActive {
|
if err := tester.downloader.DeliverBlocks("bad peer", []*types.Block{}); err != errNoSyncActive {
|
||||||
t.Errorf("error mismatch: have %v, want %v", err, errNoSyncActive)
|
t.Errorf("error mismatch: have %v, want %v", err, errNoSyncActive)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
package downloader
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
|
||||||
"gopkg.in/fatih/set.v0"
|
|
||||||
)
|
|
||||||
|
|
||||||
func createHashSet(hashes []common.Hash) *set.Set {
|
|
||||||
hset := set.New()
|
|
||||||
|
|
||||||
for _, hash := range hashes {
|
|
||||||
hset.Add(hash)
|
|
||||||
}
|
|
||||||
|
|
||||||
return hset
|
|
||||||
}
|
|
||||||
|
|
||||||
func createBlocksFromHashSet(hashes *set.Set) []*types.Block {
|
|
||||||
blocks := make([]*types.Block, hashes.Size())
|
|
||||||
|
|
||||||
var i int
|
|
||||||
hashes.Each(func(v interface{}) bool {
|
|
||||||
blocks[i] = createBlock(i, common.Hash{}, v.(common.Hash))
|
|
||||||
i++
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
|
|
||||||
return blocks
|
|
||||||
}
|
|
Loading…
Reference in New Issue