add a test for pex reactor

This commit is contained in:
Anton Kaliaev 2018-03-07 12:25:31 +04:00
parent a39aec0bae
commit 736ea055a8
No known key found for this signature in database
GPG Key ID: 7B6881D965918214
1 changed files with 19 additions and 0 deletions

View File

@ -268,6 +268,25 @@ func TestPEXReactorCrawlStatus(t *testing.T) {
// 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) {
pexR, book := createReactor(&PEXReactorConfig{})
defer teardownReactor(book)