Skip to content

Commit

Permalink
Fixed discovery tests
Browse files Browse the repository at this point in the history
  • Loading branch information
soffokl committed Sep 19, 2018
1 parent 1a612f4 commit 7e9dcd2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions discovery/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ func (d *Discovery) stopLoop() {
log.Info(logPrefix, "stopping discovery loop..")
d.RLock()
if d.status == WaitingForRegistration {
d.RUnlock()
d.unsubscribe()
d.RLock()
}
d.RUnlock()

d.RLock()
if d.status == RegisterProposal || d.status == PingProposal {
d.RUnlock()
d.changeStatus(UnregisterProposal)
Expand Down
4 changes: 2 additions & 2 deletions discovery/discovery_fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"github.com/mysteriumnetwork/node/server"
)

// NewFakeDiscrovery creates fake discovery structure
func NewFakeDiscrovery() *Discovery {
// NewFakeDiscovery creates fake discovery structure
func NewFakeDiscovery() *Discovery {
return &Discovery{
statusChan: make(chan Status),
proposalAnnouncementStopped: &sync.WaitGroup{},
Expand Down
10 changes: 5 additions & 5 deletions discovery/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var (
)

func TestStartRegistersProposal(t *testing.T) {
d := NewFakeDiscrovery()
d := NewFakeDiscovery()
d.identityRegistry = &identity_registry.FakeRegistry{RegistrationEventExists: false, Registered: true}

d.Start(providerID, proposal)
Expand All @@ -45,7 +45,7 @@ func TestStartRegistersProposal(t *testing.T) {
}

func TestStartRegistersIdentitySuccessfully(t *testing.T) {
d := NewFakeDiscrovery()
d := NewFakeDiscovery()
d.identityRegistry = &identity_registry.FakeRegistry{RegistrationEventExists: true, Registered: false}

d.Start(providerID, proposal)
Expand All @@ -55,7 +55,7 @@ func TestStartRegistersIdentitySuccessfully(t *testing.T) {
}

func TestStartRegisterIdentityCancelled(t *testing.T) {
d := NewFakeDiscrovery()
d := NewFakeDiscovery()
d.identityRegistry = &identity_registry.FakeRegistry{RegistrationEventExists: false, Registered: false}

d.Start(providerID, proposal)
Expand All @@ -70,7 +70,7 @@ func TestStartRegisterIdentityCancelled(t *testing.T) {
}

func TestStartStopUnregisterProposal(t *testing.T) {
d := NewFakeDiscrovery()
d := NewFakeDiscovery()
d.identityRegistry = &identity_registry.FakeRegistry{RegistrationEventExists: false, Registered: true}

d.Start(providerID, proposal)
Expand All @@ -91,7 +91,7 @@ func observeStatus(d *Discovery, status Status) Status {
d.RUnlock()
return d.status
}
time.Sleep(10 * time.Millisecond)
d.RUnlock()
time.Sleep(10 * time.Millisecond)
}
}
12 changes: 6 additions & 6 deletions discovery/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ func NewService(
signerCreate identity.SignerFactory,
) *Discovery {
return &Discovery{
identityRegistry: identityRegistry,
identityRegistration: identityRegistration,
mysteriumClient: mysteriumClient,
signerCreate: signerCreate,
statusChan: make(chan Status),
status: StatusUndefined,
identityRegistry: identityRegistry,
identityRegistration: identityRegistration,
mysteriumClient: mysteriumClient,
signerCreate: signerCreate,
statusChan: make(chan Status),
status: StatusUndefined,
proposalAnnouncementStopped: &sync.WaitGroup{},
unsubscribe: func() {},
stop: func() {},
Expand Down

0 comments on commit 7e9dcd2

Please sign in to comment.