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