|
|
@ -177,18 +177,25 @@ func TestServerDial(t *testing.T) { |
|
|
|
if peer := srv.Peers()[0]; peer.Info().Network.Trusted { |
|
|
|
if peer := srv.Peers()[0]; peer.Info().Network.Trusted { |
|
|
|
t.Errorf("peer is trusted prematurely: %v", peer) |
|
|
|
t.Errorf("peer is trusted prematurely: %v", peer) |
|
|
|
} |
|
|
|
} |
|
|
|
srv.AddTrustedPeer(node) |
|
|
|
done := make(chan bool) |
|
|
|
if peer := srv.Peers()[0]; !peer.Info().Network.Trusted { |
|
|
|
go func() { |
|
|
|
t.Errorf("peer is not trusted after AddTrustedPeer: %v", peer) |
|
|
|
srv.AddTrustedPeer(node) |
|
|
|
} |
|
|
|
if peer := srv.Peers()[0]; !peer.Info().Network.Trusted { |
|
|
|
if peer := srv.Peers()[0]; peer.Inbound() { |
|
|
|
t.Errorf("peer is not trusted after AddTrustedPeer: %v", peer) |
|
|
|
t.Errorf("peer is marked inbound") |
|
|
|
} |
|
|
|
} |
|
|
|
srv.RemoveTrustedPeer(node) |
|
|
|
srv.RemoveTrustedPeer(node) |
|
|
|
if peer := srv.Peers()[0]; peer.Info().Network.Trusted { |
|
|
|
if peer := srv.Peers()[0]; peer.Info().Network.Trusted { |
|
|
|
t.Errorf("peer is trusted after RemoveTrustedPeer: %v", peer) |
|
|
|
t.Errorf("peer is trusted after RemoveTrustedPeer: %v", peer) |
|
|
|
} |
|
|
|
} |
|
|
|
done <- true |
|
|
|
|
|
|
|
}() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Trigger potential race conditions
|
|
|
|
|
|
|
|
peer = srv.Peers()[0] |
|
|
|
|
|
|
|
_ = peer.Inbound() |
|
|
|
|
|
|
|
_ = peer.Info() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<-done |
|
|
|
case <-time.After(1 * time.Second): |
|
|
|
case <-time.After(1 * time.Second): |
|
|
|
t.Error("server did not launch peer within one second") |
|
|
|
t.Error("server did not launch peer within one second") |
|
|
|
} |
|
|
|
} |
|
|
|