aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/discover/table_test.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-08-07 06:10:26 +0800
committerFelix Lange <fjl@twurst.com>2015-08-11 17:42:17 +0800
commit01ed3fa1a9414328eb6c4fc839e1b2044a786a7a (patch)
treef081f6c63b7e5ca04c4976d85654797a4c7f2a0b /p2p/discover/table_test.go
parent698e98d9814605bfea98ba3ad2fe7fda073cb2b1 (diff)
downloadgo-tangerine-01ed3fa1a9414328eb6c4fc839e1b2044a786a7a.tar
go-tangerine-01ed3fa1a9414328eb6c4fc839e1b2044a786a7a.tar.gz
go-tangerine-01ed3fa1a9414328eb6c4fc839e1b2044a786a7a.tar.bz2
go-tangerine-01ed3fa1a9414328eb6c4fc839e1b2044a786a7a.tar.lz
go-tangerine-01ed3fa1a9414328eb6c4fc839e1b2044a786a7a.tar.xz
go-tangerine-01ed3fa1a9414328eb6c4fc839e1b2044a786a7a.tar.zst
go-tangerine-01ed3fa1a9414328eb6c4fc839e1b2044a786a7a.zip
p2p/discover: unlock the table during ping replacement
Table.mutex was being held while waiting for a reply packet, which effectively made many parts of the whole stack block on that packet, including the net_peerCount RPC call.
Diffstat (limited to 'p2p/discover/table_test.go')
-rw-r--r--p2p/discover/table_test.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/p2p/discover/table_test.go b/p2p/discover/table_test.go
index d259177bf..426f4e9cc 100644
--- a/p2p/discover/table_test.go
+++ b/p2p/discover/table_test.go
@@ -178,8 +178,8 @@ func TestTable_closest(t *testing.T) {
test := func(test *closeTest) bool {
// for any node table, Target and N
tab := newTable(nil, test.Self, &net.UDPAddr{}, "")
- tab.add(test.All)
defer tab.Close()
+ tab.stuff(test.All)
// check that doClosest(Target, N) returns nodes
result := tab.closest(test.Target, test.N).entries
@@ -240,7 +240,7 @@ func TestTable_ReadRandomNodesGetAll(t *testing.T) {
defer tab.Close()
for i := 0; i < len(buf); i++ {
ld := cfg.Rand.Intn(len(tab.buckets))
- tab.add([]*Node{nodeAtDistance(tab.self.sha, ld)})
+ tab.stuff([]*Node{nodeAtDistance(tab.self.sha, ld)})
}
gotN := tab.ReadRandomNodes(buf)
if gotN != tab.len() {
@@ -288,7 +288,7 @@ func TestTable_Lookup(t *testing.T) {
}
// seed table with initial node (otherwise lookup will terminate immediately)
seed := newNode(lookupTestnet.dists[256][0], net.IP{}, 256, 0)
- tab.add([]*Node{seed})
+ tab.stuff([]*Node{seed})
results := tab.Lookup(lookupTestnet.target)
t.Logf("results:")