Browse Source

add a test for pex reactor

pull/1282/head
Anton Kaliaev 7 years ago
parent
commit
736ea055a8
No known key found for this signature in database GPG Key ID: 7B6881D965918214
1 changed files with 19 additions and 0 deletions
  1. +19
    -0
      p2p/pex/pex_reactor_test.go

+ 19
- 0
p2p/pex/pex_reactor_test.go View File

@ -268,6 +268,25 @@ func TestPEXReactorCrawlStatus(t *testing.T) {
// TODO: test // TODO: test
} }
func TestPEXReactorDoesNotAddPrivatePeersToAddrBook(t *testing.T) {
pexR, book := createReactor(&PEXReactorConfig{PrivatePeerIDs: []string{string(peer.NodeInfo().ID())}})
defer teardownReactor(book)
peer := p2p.CreateRandomPeer(false)
// we have to send a request to receive responses
r.RequestAddrs(peer)
size := book.Size()
addrs := []*p2p.NetAddress{peer.NodeInfo().NetAddress()}
msg := wire.BinaryBytes(struct{ PexMessage }{&pexAddrsMessage{Addrs: addrs}})
r.Receive(PexChannel, peer, msg)
assert.Equal(t, size, book.Size())
r.AddPeer(peer)
assert.Equal(t, size, book.Size())
}
func TestPEXReactorDialPeer(t *testing.T) { func TestPEXReactorDialPeer(t *testing.T) {
pexR, book := createReactor(&PEXReactorConfig{}) pexR, book := createReactor(&PEXReactorConfig{})
defer teardownReactor(book) defer teardownReactor(book)


Loading…
Cancel
Save