mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 03:51:29 +00:00
f37301c0c0
* Remove remote slashing protection feature * test fix * remove mock from tests --------- Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
65 lines
2.0 KiB
Go
65 lines
2.0 KiB
Go
package slasher
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/prysmaticlabs/prysm/v4/async/event"
|
|
mock "github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain/testing"
|
|
dbtest "github.com/prysmaticlabs/prysm/v4/beacon-chain/db/testing"
|
|
"github.com/prysmaticlabs/prysm/v4/beacon-chain/startup"
|
|
mockSync "github.com/prysmaticlabs/prysm/v4/beacon-chain/sync/initial-sync/testing"
|
|
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
|
|
"github.com/prysmaticlabs/prysm/v4/testing/require"
|
|
"github.com/prysmaticlabs/prysm/v4/testing/util"
|
|
"github.com/prysmaticlabs/prysm/v4/time/slots"
|
|
"github.com/sirupsen/logrus"
|
|
logTest "github.com/sirupsen/logrus/hooks/test"
|
|
)
|
|
|
|
var _ = SlashingChecker(&Service{})
|
|
|
|
func TestMain(m *testing.M) {
|
|
logrus.SetLevel(logrus.DebugLevel)
|
|
logrus.SetOutput(io.Discard)
|
|
|
|
m.Run()
|
|
}
|
|
|
|
func TestService_StartStop_ChainInitialized(t *testing.T) {
|
|
slasherDB := dbtest.SetupSlasherDB(t)
|
|
hook := logTest.NewGlobal()
|
|
beaconState, err := util.NewBeaconState()
|
|
require.NoError(t, err)
|
|
currentSlot := primitives.Slot(4)
|
|
require.NoError(t, beaconState.SetSlot(currentSlot))
|
|
mockChain := &mock.ChainService{
|
|
State: beaconState,
|
|
Slot: ¤tSlot,
|
|
}
|
|
gs := startup.NewClockSynchronizer()
|
|
srv, err := New(context.Background(), &ServiceConfig{
|
|
IndexedAttestationsFeed: new(event.Feed),
|
|
BeaconBlockHeadersFeed: new(event.Feed),
|
|
StateNotifier: &mock.MockStateNotifier{},
|
|
Database: slasherDB,
|
|
HeadStateFetcher: mockChain,
|
|
SyncChecker: &mockSync.Sync{IsSyncing: false},
|
|
ClockWaiter: gs,
|
|
})
|
|
require.NoError(t, err)
|
|
go srv.Start()
|
|
time.Sleep(time.Millisecond * 100)
|
|
var vr [32]byte
|
|
require.NoError(t, gs.SetClock(startup.NewClock(time.Now(), vr)))
|
|
time.Sleep(time.Millisecond * 100)
|
|
srv.attsSlotTicker = &slots.SlotTicker{}
|
|
srv.blocksSlotTicker = &slots.SlotTicker{}
|
|
srv.pruningSlotTicker = &slots.SlotTicker{}
|
|
require.NoError(t, srv.Stop())
|
|
require.NoError(t, srv.Status())
|
|
require.LogsContain(t, hook, "received chain initialization")
|
|
}
|