diff options
author | Sonic <sonic@dexon.org> | 2019-01-31 19:40:39 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-12 17:27:22 +0800 |
commit | 30d6c027cda04c08a1216b32d9fda2e19f53f4c0 (patch) | |
tree | da62879f109f3669cfaa419891c023f0d1b3121e /dex/protocol_test.go | |
parent | 13651db29d3534620bf156be1539857cf558d352 (diff) | |
download | go-tangerine-30d6c027cda04c08a1216b32d9fda2e19f53f4c0.tar go-tangerine-30d6c027cda04c08a1216b32d9fda2e19f53f4c0.tar.gz go-tangerine-30d6c027cda04c08a1216b32d9fda2e19f53f4c0.tar.bz2 go-tangerine-30d6c027cda04c08a1216b32d9fda2e19f53f4c0.tar.lz go-tangerine-30d6c027cda04c08a1216b32d9fda2e19f53f4c0.tar.xz go-tangerine-30d6c027cda04c08a1216b32d9fda2e19f53f4c0.tar.zst go-tangerine-30d6c027cda04c08a1216b32d9fda2e19f53f4c0.zip |
p2p, dex: rework connection management (#183)
* p2p, dex: rework connection management
* dex: refresh our node record periodically
* dex: don't send new record event if no new record
Diffstat (limited to 'dex/protocol_test.go')
-rw-r--r-- | dex/protocol_test.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/dex/protocol_test.go b/dex/protocol_test.go index 5c68785e8..74778cdda 100644 --- a/dex/protocol_test.go +++ b/dex/protocol_test.go @@ -18,7 +18,6 @@ package dex import ( "crypto/ecdsa" - "encoding/hex" "fmt" "reflect" "sync" @@ -36,6 +35,7 @@ import ( "github.com/dexon-foundation/dexon/crypto" "github.com/dexon-foundation/dexon/dex/downloader" "github.com/dexon-foundation/dexon/p2p" + "github.com/dexon-foundation/dexon/p2p/enode" "github.com/dexon-foundation/dexon/p2p/enr" "github.com/dexon-foundation/dexon/rlp" ) @@ -553,11 +553,15 @@ func TestSendVote(t *testing.T) { }, } + pm.peers.label2Nodes = make(map[peerLabel]map[string]*enode.Node) for i, tt := range testPeers { p, _ := newTestPeer(fmt.Sprintf("peer #%d", i), dex64, pm, true) if tt.label != nil { - b := crypto.FromECDSAPub(p.Node().Pubkey()) - pm.peers.addDirectPeer(hex.EncodeToString(b), *tt.label) + if pm.peers.label2Nodes[*tt.label] == nil { + pm.peers.label2Nodes[*tt.label] = make(map[string]*enode.Node) + } + pm.peers.label2Nodes[*tt.label][p.ID().String()] = p.Node() + pm.peers.addDirectPeer(p.ID().String(), *tt.label) } wg.Add(1) go checkvote(p, tt.isReceiver) |