prysm-pulse/beacon-chain/rpc/debug/forkchoice_test.go
terence tsao 0c3586a8ea
Add debug proto array fork choice endpoint (#6003)
* 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
2020-05-26 23:24:38 +00:00

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")
}
}