prysm-pulse/beacon-chain/attestation/service_test.go

38 lines
878 B
Go
Raw Normal View History

package attestation
import (
"context"
"testing"
"github.com/prysmaticlabs/prysm/beacon-chain/internal"
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/sirupsen/logrus"
logTest "github.com/sirupsen/logrus/hooks/test"
)
func init() {
logrus.SetLevel(logrus.DebugLevel)
}
func TestIncomingAttestations(t *testing.T) {
hook := logTest.NewGlobal()
beaconDB := internal.SetupDB(t)
defer internal.TeardownDB(t, beaconDB)
2018-10-17 06:11:24 +00:00
service := NewAttestationService(context.Background(), &Config{BeaconDB: beaconDB})
exitRoutine := make(chan bool)
go func() {
2018-10-05 17:14:50 +00:00
service.aggregateAttestations()
<-exitRoutine
}()
service.incomingChan <- &pb.Attestation{
Data: &pb.AttestationData{},
}
2018-10-05 17:14:50 +00:00
service.cancel()
exitRoutine <- true
testutil.AssertLogsContain(t, hook, "Forwarding aggregated attestation")
}