mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-03 08:37:37 +00:00
ee91be2c4a
* implementing basic proposer functionality * checked in gomocks * fix typo * refactor using feeds * use event feeds for assignment * sending the latest beacon block over announcement chan * 100 coverage, using feeds * gazelle * include parent hash from prev canonical block and slot number + 1 * including all other prop fields * fix build * proposer rpc method tests, implemented in beacon chain side * godoc
58 lines
1.3 KiB
Go
58 lines
1.3 KiB
Go
package attester
|
|
|
|
import (
|
|
"context"
|
|
"io/ioutil"
|
|
"testing"
|
|
|
|
"github.com/ethereum/go-ethereum/event"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil"
|
|
"github.com/sirupsen/logrus"
|
|
logTest "github.com/sirupsen/logrus/hooks/test"
|
|
)
|
|
|
|
func init() {
|
|
logrus.SetLevel(logrus.DebugLevel)
|
|
logrus.SetOutput(ioutil.Discard)
|
|
}
|
|
|
|
type mockAssigner struct{}
|
|
|
|
func (m *mockAssigner) AttesterAssignmentFeed() *event.Feed {
|
|
return new(event.Feed)
|
|
}
|
|
|
|
func TestLifecycle(t *testing.T) {
|
|
hook := logTest.NewGlobal()
|
|
cfg := &Config{
|
|
AssignmentBuf: 0,
|
|
Assigner: &mockAssigner{},
|
|
}
|
|
att := NewAttester(context.Background(), cfg)
|
|
att.Start()
|
|
testutil.AssertLogsContain(t, hook, "Starting service")
|
|
att.Stop()
|
|
testutil.AssertLogsContain(t, hook, "Stopping service")
|
|
}
|
|
|
|
func TestAttesterLoop(t *testing.T) {
|
|
hook := logTest.NewGlobal()
|
|
cfg := &Config{
|
|
AssignmentBuf: 0,
|
|
Assigner: &mockAssigner{},
|
|
}
|
|
att := NewAttester(context.Background(), cfg)
|
|
|
|
doneChan := make(chan struct{})
|
|
exitRoutine := make(chan bool)
|
|
go func() {
|
|
att.run(doneChan)
|
|
<-exitRoutine
|
|
}()
|
|
att.assignmentChan <- true
|
|
testutil.AssertLogsContain(t, hook, "Performing attester responsibility")
|
|
doneChan <- struct{}{}
|
|
exitRoutine <- true
|
|
testutil.AssertLogsContain(t, hook, "Attester context closed")
|
|
}
|