Skip to content

Commit

Permalink
fix e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
gitferry committed Oct 8, 2024
1 parent 5fc6da8 commit 72fb47f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
11 changes: 5 additions & 6 deletions finality-provider/service/fp_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ type FinalityProviderManager struct {
isStarted *atomic.Bool

// mutex to acess map of fp instances (fpIns)
mu sync.Mutex
wg sync.WaitGroup

fpIns *FinalityProviderInstance
Expand Down Expand Up @@ -265,12 +264,15 @@ func (fpm *FinalityProviderManager) Stop() error {
return fmt.Errorf("the finality-provider manager has already stopped")
}

close(fpm.quit)
fpm.wg.Wait()
defer func() {
close(fpm.quit)
fpm.wg.Wait()
}()

if fpm.fpIns == nil {
return nil
}

if !fpm.fpIns.IsRunning() {
return nil
}
Expand Down Expand Up @@ -354,9 +356,6 @@ func (fpm *FinalityProviderManager) startFinalityProviderInstance(
pk *bbntypes.BIP340PubKey,
passphrase string,
) error {
fpm.mu.Lock()
defer fpm.mu.Unlock()

pkHex := pk.MarshalHex()
if fpm.fpIns == nil {
fpIns, err := NewFinalityProviderInstance(
Expand Down
10 changes: 2 additions & 8 deletions itest/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/btcsuite/btcd/btcec/v2"
"github.com/stretchr/testify/require"

"github.com/babylonlabs-io/finality-provider/finality-provider/proto"
"github.com/babylonlabs-io/finality-provider/types"
)

Expand Down Expand Up @@ -100,14 +99,9 @@ func TestDoubleSigning(t *testing.T) {

tm.WaitForFpShutDown(t)

// try to start all the finality providers and the slashed one should not be restarted
// try to start the finality providers and the slashed one should expect err
err = tm.Fpa.StartHandlingFinalityProvider(fpIns.GetBtcPkBIP340(), "")
require.NoError(t, err)
fps, err := tm.Fpa.ListAllFinalityProvidersInfo()
require.NoError(t, err)
require.Equal(t, 1, len(fps))
require.Equal(t, proto.FinalityProviderStatus_name[4], fps[0].Status)
require.Equal(t, false, fps[0].IsRunning)
require.Error(t, err)
}

// TestFastSync tests the fast sync process where the finality-provider is terminated and restarted with fast sync
Expand Down
4 changes: 1 addition & 3 deletions itest/test_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,7 @@ func StartManagerWithFinalityProvider(t *testing.T) (*TestManager, *service.Fina
}

func (tm *TestManager) Stop(t *testing.T) {
err := tm.Fpa.Stop()
require.NoError(t, err)
err = tm.manager.ClearResources()
err := tm.manager.ClearResources()
require.NoError(t, err)
err = os.RemoveAll(tm.baseDir)
require.NoError(t, err)
Expand Down

0 comments on commit 72fb47f

Please sign in to comment.