Skip to content

Commit

Permalink
fix e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
gitferry committed Sep 30, 2024
1 parent fe696e4 commit 2aaae63
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
6 changes: 2 additions & 4 deletions finality-provider/service/fp_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ package service
import (
"errors"
"fmt"
"strings"
"sync"
"time"

"github.com/avast/retry-go/v4"
bbntypes "github.com/babylonlabs-io/babylon/types"
btcstakingtypes "github.com/babylonlabs-io/babylon/x/btcstaking/types"
"go.uber.org/atomic"
"go.uber.org/zap"

Expand Down Expand Up @@ -101,13 +99,13 @@ func (fpm *FinalityProviderManager) monitorCriticalErr() {
}
// cannot use error.Is because the unwrapped error
// is not the expected error type
if strings.Contains(criticalErr.err.Error(), btcstakingtypes.ErrFpAlreadySlashed.Error()) {
if errors.Is(criticalErr.err, ErrFinalityProviderSlashed) {
fpm.setFinalityProviderSlashed(fpi)
fpm.logger.Debug("the finality-provider has been slashed",
zap.String("pk", criticalErr.fpBtcPk.MarshalHex()))
continue
}
if strings.Contains(criticalErr.err.Error(), btcstakingtypes.ErrFpAlreadyJailed.Error()) {
if errors.Is(criticalErr.err, ErrFinalityProviderJailed) {
fpm.setFinalityProviderJailed(fpi)
fpm.logger.Debug("the finality-provider has been jailed",
zap.String("pk", criticalErr.fpBtcPk.MarshalHex()))
Expand Down
10 changes: 10 additions & 0 deletions itest/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ 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 @@ -102,6 +103,15 @@ func TestDoubleSigning(t *testing.T) {
t.Logf("the equivocation attack is successful")

tm.WaitForFpShutDown(t, fpIns.GetBtcPkBIP340())

// try to start all the finality providers and the slashed one should not be restarted
err = tm.Fpa.StartHandlingAll()
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)
}

// TestFastSync tests the fast sync process where the finality-provider is terminated and restarted with fast sync
Expand Down
5 changes: 3 additions & 2 deletions itest/test_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package e2etest
import (
"encoding/hex"
"fmt"
"github.com/babylonlabs-io/finality-provider/itest/container"
"github.com/babylonlabs-io/finality-provider/testutil"
"math/rand"
"os"
"path/filepath"
Expand All @@ -14,6 +12,9 @@ import (
"testing"
"time"

"github.com/babylonlabs-io/finality-provider/itest/container"
"github.com/babylonlabs-io/finality-provider/testutil"

sdkmath "cosmossdk.io/math"
"github.com/babylonlabs-io/babylon/btcstaking"
txformat "github.com/babylonlabs-io/babylon/btctxformatter"
Expand Down

0 comments on commit 2aaae63

Please sign in to comment.