aboutsummaryrefslogtreecommitdiffstats
path: root/blockpool/peers_test.go
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2015-04-10 23:31:00 +0800
committerzelig <viktor.tron@gmail.com>2015-04-10 23:36:40 +0800
commitda7332a7317bda9003e5e8a4aaa4b1710c69b664 (patch)
tree7c4fc11a84c18946b105bf778aa7243dd70e54ec /blockpool/peers_test.go
parentfc1d1f9afd155fab1f614c6a0340233f90afafd6 (diff)
downloadgo-tangerine-da7332a7317bda9003e5e8a4aaa4b1710c69b664.tar.gz
go-tangerine-da7332a7317bda9003e5e8a4aaa4b1710c69b664.tar.zst
go-tangerine-da7332a7317bda9003e5e8a4aaa4b1710c69b664.zip
td update from node
- reorg and simplify AddBlock - introduce nodeCache - TestPeerPromotionByTdOnBlock unskipped and passes - move switchC/idleC channel creation around: solves deadlock (now respects the contract with section process: either can activate or complete at any one time)
Diffstat (limited to 'blockpool/peers_test.go')
-rw-r--r--blockpool/peers_test.go11
1 files changed, 4 insertions, 7 deletions
diff --git a/blockpool/peers_test.go b/blockpool/peers_test.go
index e32bb6fc8..e5788e379 100644
--- a/blockpool/peers_test.go
+++ b/blockpool/peers_test.go
@@ -145,7 +145,6 @@ func TestAddPeer(t *testing.T) {
}
func TestPeerPromotionByTdOnBlock(t *testing.T) {
- t.Skip()
test.LogInit()
_, blockPool, blockPoolTester := newTestBlockPool(t)
blockPoolTester.blockChain[0] = nil
@@ -155,28 +154,26 @@ func TestPeerPromotionByTdOnBlock(t *testing.T) {
peer2 := blockPoolTester.newPeer("peer2", 4, 4)
blockPool.Start()
- blockPoolTester.tds = make(map[int]int)
- blockPoolTester.tds[3] = 3
- // pool
peer0.AddPeer()
peer0.serveBlocks(1, 2)
best := peer1.AddPeer()
// this tests that peer1 is not promoted over peer0 yet
if best {
t.Errorf("peer1 (TD=1) should not be set as best")
+ return
}
best = peer2.AddPeer()
peer2.serveBlocks(3, 4)
peer2.serveBlockHashes(4, 3, 2, 1)
- // hashes := blockPoolTester.hashPool.IndexesToHashes([]int{2, 3})
- peer1.serveBlocks(2, 3)
+ peer1.sendBlocks(3, 4)
blockPool.RemovePeer("peer2")
if blockPool.peers.best.id != "peer1" {
t.Errorf("peer1 (TD=3) should be set as best")
+ return
}
- peer1.serveBlocks(0, 1, 2)
+ peer1.serveBlocks(0, 1, 2, 3)
blockPool.Wait(waitTimeout)
blockPool.Stop()