mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-31 23:41:22 +00:00
d143187b7e
* include fixes * rev * logrus * tests for query sync status and chain head * begin tests for indexed atts * test passing for requesting historical atts * Update slasher/beaconclient/chain_data_test.go * Update slasher/beaconclient/historical_data_retrieval.go * lint * fixed up wanted vs receied * fix mock * gazelle * fix broken build * tests pass * dep * gaz * add dep * tests pass Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
59 lines
1.5 KiB
Go
59 lines
1.5 KiB
Go
package beaconclient
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/gogo/protobuf/proto"
|
|
"github.com/golang/mock/gomock"
|
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/shared/mock"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil"
|
|
logTest "github.com/sirupsen/logrus/hooks/test"
|
|
)
|
|
|
|
func TestService_ChainHead(t *testing.T) {
|
|
ctrl := gomock.NewController(t)
|
|
defer ctrl.Finish()
|
|
client := mock.NewMockBeaconChainClient(ctrl)
|
|
|
|
bs := Service{
|
|
beaconClient: client,
|
|
}
|
|
wanted := ðpb.ChainHead{
|
|
HeadSlot: 4,
|
|
HeadEpoch: 0,
|
|
HeadBlockRoot: make([]byte, 32),
|
|
}
|
|
client.EXPECT().GetChainHead(gomock.Any(), gomock.Any()).Return(wanted, nil)
|
|
res, err := bs.ChainHead(context.Background())
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !proto.Equal(res, wanted) {
|
|
t.Errorf("Wanted %v, received %v", wanted, res)
|
|
}
|
|
}
|
|
|
|
func TestService_QuerySyncStatus(t *testing.T) {
|
|
hook := logTest.NewGlobal()
|
|
ctrl := gomock.NewController(t)
|
|
defer ctrl.Finish()
|
|
client := mock.NewMockNodeClient(ctrl)
|
|
|
|
bs := Service{
|
|
nodeClient: client,
|
|
}
|
|
syncStatusPollingInterval = time.Millisecond
|
|
client.EXPECT().GetSyncStatus(gomock.Any(), gomock.Any()).Return(ðpb.SyncStatus{
|
|
Syncing: true,
|
|
}, nil)
|
|
client.EXPECT().GetSyncStatus(gomock.Any(), gomock.Any()).Return(ðpb.SyncStatus{
|
|
Syncing: false,
|
|
}, nil)
|
|
bs.querySyncStatus(context.Background())
|
|
testutil.AssertLogsContain(t, hook, "Waiting for beacon node to be fully synced...")
|
|
testutil.AssertLogsContain(t, hook, "Beacon node is fully synced")
|
|
}
|