mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-27 21:57:16 +00:00
0c3586a8ea
* Add proto array fork choice object to RPC * Add pb * Add pb * Expose proto array store object * Test * Merge branch 'forkchoice-endpoint' of github.com:prysmaticlabs/prysm into forkchoice-endpoint * s/Nodes/nodes * Remove proto from gitignore * More implementations of GetProtoArrayForkChoice * Comments * Use hex * Gazelle * GetForkChoice Test * Remove pb.go * Merge branch 'master' into forkchoice-endpoint * Typo, thanks Raul! * Merge branch 'forkchoice-endpoint' of github.com:prysmaticlabs/prysm into forkchoice-endpoint
41 lines
1.0 KiB
Go
41 lines
1.0 KiB
Go
package debug
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
ptypes "github.com/gogo/protobuf/types"
|
|
mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/protoarray"
|
|
)
|
|
|
|
func TestServer_GetForkChoice(t *testing.T) {
|
|
store := &protoarray.Store{
|
|
PruneThreshold: 1,
|
|
JustifiedEpoch: 2,
|
|
FinalizedEpoch: 3,
|
|
Nodes: []*protoarray.Node{{Slot: 4, Root: [32]byte{'a'}}},
|
|
}
|
|
|
|
bs := &Server{
|
|
HeadFetcher: &mock.ChainService{ForkChoiceStore: store},
|
|
}
|
|
|
|
res, err := bs.GetProtoArrayForkChoice(context.Background(), &ptypes.Empty{})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if res.PruneThreshold != store.PruneThreshold {
|
|
t.Error("Did not get wanted prune threshold")
|
|
}
|
|
if res.JustifiedEpoch != store.JustifiedEpoch {
|
|
t.Error("Did not get wanted justified epoch")
|
|
}
|
|
if res.FinalizedEpoch != store.FinalizedEpoch {
|
|
t.Error("Did not get wanted finalized epoch")
|
|
}
|
|
if res.ProtoArrayNodes[0].Slot != store.Nodes[0].Slot {
|
|
t.Error("Did not get wanted node slot")
|
|
}
|
|
}
|