forked from enzoh/go-revolver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathping_test.go
41 lines (32 loc) · 853 Bytes
/
ping_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* File : ping_test.go
* Description : Unit tests.
* Copyright : Copyright (c) 2017-2018 DFINITY Stiftung. All rights reserved.
* Maintainer : Enzo Haussecker <[email protected]>
* Stability : Experimental
*/
package p2p
import (
"testing"
"gx/ipfs/QmPgDWmTmuzvP7QE5zwo1TmjbJme9pmZHNujB2453jkCTr/go-libp2p-peerstore"
)
// Show that a client can ping a peer.
func TestPing(test *testing.T) {
// Create a client.
client1, shutdown1 := newTestClient(test)
defer shutdown1()
// Create a second client.
client2, shutdown2 := newTestClient(test)
defer shutdown2()
// Add the second client to the peer store of the first.
client1.peerstore.AddAddrs(
client2.id,
client2.host.Addrs(),
peerstore.ProviderAddrTTL,
)
// Ping the second client.
err := client1.ping(client2.id)
if err != nil {
test.Fatal(err)
}
}