diff options
author | Felföldi Zsolt <zsfelfoldi@gmail.com> | 2017-06-21 18:27:38 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2017-06-21 18:27:38 +0800 |
commit | a5d08c893d61f66d60d8a91216aee5347b78f93e (patch) | |
tree | 500f3a788ecd4f299692ce1d1069f2efdc79d73d /les/handler_test.go | |
parent | 60e27b51bc5643bc6a76151020a9e1a245340b70 (diff) | |
download | dexon-a5d08c893d61f66d60d8a91216aee5347b78f93e.tar dexon-a5d08c893d61f66d60d8a91216aee5347b78f93e.tar.gz dexon-a5d08c893d61f66d60d8a91216aee5347b78f93e.tar.bz2 dexon-a5d08c893d61f66d60d8a91216aee5347b78f93e.tar.lz dexon-a5d08c893d61f66d60d8a91216aee5347b78f93e.tar.xz dexon-a5d08c893d61f66d60d8a91216aee5347b78f93e.tar.zst dexon-a5d08c893d61f66d60d8a91216aee5347b78f93e.zip |
les: code refactoring (#14416)
This commit does various code refactorings:
- generalizes and moves the request retrieval/timeout/resend logic out of LesOdr
(will be used by a subsequent PR)
- reworks the peer management logic so that all services can register with
peerSet to get notified about added/dropped peers (also gets rid of the ugly
getAllPeers callback in requestDistributor)
- moves peerSet, LesOdr, requestDistributor and retrieveManager initialization
out of ProtocolManager because I believe they do not really belong there and the
whole init process was ugly and ad-hoc
Diffstat (limited to 'les/handler_test.go')
-rw-r--r-- | les/handler_test.go | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/les/handler_test.go b/les/handler_test.go index 0b94d0d30..5df1d3463 100644 --- a/les/handler_test.go +++ b/les/handler_test.go @@ -25,6 +25,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/eth/downloader" + "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/trie" @@ -42,7 +43,8 @@ func expectResponse(r p2p.MsgReader, msgcode, reqID, bv uint64, data interface{} func TestGetBlockHeadersLes1(t *testing.T) { testGetBlockHeaders(t, 1) } func testGetBlockHeaders(t *testing.T, protocol int) { - pm, _, _ := newTestProtocolManagerMust(t, false, downloader.MaxHashFetch+15, nil) + db, _ := ethdb.NewMemDatabase() + pm := newTestProtocolManagerMust(t, false, downloader.MaxHashFetch+15, nil, nil, nil, db) bc := pm.blockchain.(*core.BlockChain) peer, _ := newTestPeer(t, "peer", protocol, pm, true) defer peer.close() @@ -170,7 +172,8 @@ func testGetBlockHeaders(t *testing.T, protocol int) { func TestGetBlockBodiesLes1(t *testing.T) { testGetBlockBodies(t, 1) } func testGetBlockBodies(t *testing.T, protocol int) { - pm, _, _ := newTestProtocolManagerMust(t, false, downloader.MaxBlockFetch+15, nil) + db, _ := ethdb.NewMemDatabase() + pm := newTestProtocolManagerMust(t, false, downloader.MaxBlockFetch+15, nil, nil, nil, db) bc := pm.blockchain.(*core.BlockChain) peer, _ := newTestPeer(t, "peer", protocol, pm, true) defer peer.close() @@ -246,7 +249,8 @@ func TestGetCodeLes1(t *testing.T) { testGetCode(t, 1) } func testGetCode(t *testing.T, protocol int) { // Assemble the test environment - pm, _, _ := newTestProtocolManagerMust(t, false, 4, testChainGen) + db, _ := ethdb.NewMemDatabase() + pm := newTestProtocolManagerMust(t, false, 4, testChainGen, nil, nil, db) bc := pm.blockchain.(*core.BlockChain) peer, _ := newTestPeer(t, "peer", protocol, pm, true) defer peer.close() @@ -278,7 +282,8 @@ func TestGetReceiptLes1(t *testing.T) { testGetReceipt(t, 1) } func testGetReceipt(t *testing.T, protocol int) { // Assemble the test environment - pm, db, _ := newTestProtocolManagerMust(t, false, 4, testChainGen) + db, _ := ethdb.NewMemDatabase() + pm := newTestProtocolManagerMust(t, false, 4, testChainGen, nil, nil, db) bc := pm.blockchain.(*core.BlockChain) peer, _ := newTestPeer(t, "peer", protocol, pm, true) defer peer.close() @@ -304,7 +309,8 @@ func TestGetProofsLes1(t *testing.T) { testGetReceipt(t, 1) } func testGetProofs(t *testing.T, protocol int) { // Assemble the test environment - pm, db, _ := newTestProtocolManagerMust(t, false, 4, testChainGen) + db, _ := ethdb.NewMemDatabase() + pm := newTestProtocolManagerMust(t, false, 4, testChainGen, nil, nil, db) bc := pm.blockchain.(*core.BlockChain) peer, _ := newTestPeer(t, "peer", protocol, pm, true) defer peer.close() |