go-http-peering/test/ping_test.go

47 lines
674 B
Go
Raw Normal View History

2019-02-03 20:56:58 +01:00
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")
}
}