47 lines
674 B
Go
47 lines
674 B
Go
|
package test
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
peering "forge.cadoles.com/wpetit/go-http-peering"
|
||
|
)
|
||
|
|
||
|
func TestPing(t *testing.T) {
|
||
|
|
||
|
if t.Skipped() {
|
||
|
t.SkipNow()
|
||
|
}
|
||
|
|
||
|
id, _, client, store := setup(t)
|
||
|
|
||
|
attrs := peering.PeerAttributes{}
|
||
|
if err := client.Advertise(attrs); err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
|
peer, err := store.Get(id)
|
||
|
if err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
|
lastContact := peer.LastContact
|
||
|
|
||
|
if err := store.Accept(id); err != nil {
|
||
|
t.Error(err)
|
||
|
}
|
||
|
|
||
|
if err := client.Ping(); err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
|
peer, err = store.Get(id)
|
||
|
if err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
|
if peer.LastContact == lastContact {
|
||
|
t.Error("peer.LastContact should have been updated")
|
||
|
}
|
||
|
|
||
|
}
|