Skip to content

Commit

Permalink
chain: update neutrinoclient wait group and stop
Browse files Browse the repository at this point in the history
Changes the Start method to signal Done on the wait group
once the ClientConnected message is sent and calls wg.Wait()
in the Stop method.
  • Loading branch information
MStreet3 committed Oct 16, 2022
1 parent e03b032 commit c9d2561
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 8 additions & 1 deletion chain/mocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ var (
ErrNotImplemented = errors.New("not implemented")
_ Rescanner = (*mockRescanner)(nil)
_ ChainService = (*mockChainService)(nil)
testBestBlock = &headerfs.BlockStamp{
Height: 42,
}
)

func newMockNeutrinoClient(t *testing.T) *NeutrinoClient {
Expand Down Expand Up @@ -67,7 +70,11 @@ func (m *mockChainService) GetBlockHeight(*chainhash.Hash) (int32, error) {
}

func (m *mockChainService) BestBlock() (*headerfs.BlockStamp, error) {
return nil, ErrNotImplemented
return m.getBestBlock(), nil
}

func (m *mockChainService) getBestBlock() *headerfs.BlockStamp {
return testBestBlock
}

func (m *mockChainService) GetBlockHash(int64) (*chainhash.Hash, error) {
Expand Down
10 changes: 6 additions & 4 deletions chain/neutrino_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package chain

import "testing"

func TestNeutrinoClientRescan(t *testing.T) {
import (
"testing"
)

// TestNeutrinoClientMultipleRestart ensures that multiple goroutines
// can Start and Stop the client without errors or races.
func TestNeutrinoClientMultipleRestart(t *testing.T) {
// call notifyreceived and rescan in a loop
nc := newMockNeutrinoClient(t)
_ = nc

}

0 comments on commit c9d2561

Please sign in to comment.