If rendezvous wasn't start or was already stopped ignore Stop call (#1340)
This commit is contained in:
parent
944a35a11b
commit
54022561f5
|
@ -92,6 +92,9 @@ func (r *Rendezvous) Start() error {
|
|||
func (r *Rendezvous) Stop() error {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
if r.client == nil {
|
||||
return nil
|
||||
}
|
||||
r.cancelRootCtx()
|
||||
if err := r.client.Close(); err != nil {
|
||||
return err
|
||||
|
|
|
@ -83,6 +83,12 @@ func TestRendezvousRegisterAndDiscoverExitGracefully(t *testing.T) {
|
|||
require.EqualError(t, errDiscoveryIsStopped, err.Error())
|
||||
}
|
||||
|
||||
func TestStopStoppedNode(t *testing.T) {
|
||||
r, err := NewRendezvous(make([]ma.Multiaddr, 1), nil, nil)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, r.Stop())
|
||||
}
|
||||
|
||||
func BenchmarkRendezvousStart(b *testing.B) {
|
||||
identity, err := crypto.GenerateKey()
|
||||
require.NoError(b, err)
|
||||
|
|
Loading…
Reference in New Issue