mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
Make GetVirtualSelectedParentBlueScore work properly (#1764)
This commit is contained in:
parent
319cbce768
commit
4ba8b14675
@ -8,9 +8,14 @@ import (
|
||||
|
||||
// HandleGetVirtualSelectedParentBlueScore handles the respectively named RPC command
|
||||
func HandleGetVirtualSelectedParentBlueScore(context *rpccontext.Context, _ *router.Router, _ appmessage.Message) (appmessage.Message, error) {
|
||||
virtualInfo, err := context.Domain.Consensus().GetVirtualInfo()
|
||||
c := context.Domain.Consensus()
|
||||
selectedParent, err := c.GetVirtualSelectedParent()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return appmessage.NewGetVirtualSelectedParentBlueScoreResponseMessage(virtualInfo.BlueScore), nil
|
||||
blockInfo, err := c.GetBlockInfo(selectedParent)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return appmessage.NewGetVirtualSelectedParentBlueScoreResponseMessage(blockInfo.BlueScore), nil
|
||||
}
|
||||
|
@ -17,14 +17,14 @@ func TestVirtualSelectedParentBlueScoreAndVirtualDAAScore(t *testing.T) {
|
||||
kaspad, teardown := setupHarness(t, harnessParams)
|
||||
defer teardown()
|
||||
|
||||
// Make sure that the initial blue score is 1
|
||||
// Make sure that the initial selected parent blue score is 0
|
||||
response, err := kaspad.rpcClient.GetVirtualSelectedParentBlueScore()
|
||||
if err != nil {
|
||||
t.Fatalf("Error getting virtual selected parent blue score: %s", err)
|
||||
}
|
||||
if response.BlueScore != 1 {
|
||||
if response.BlueScore != 0 {
|
||||
t.Fatalf("Unexpected virtual selected parent blue score. Want: %d, got: %d",
|
||||
1, response.BlueScore)
|
||||
0, response.BlueScore)
|
||||
}
|
||||
|
||||
// Register to virtual selected parent blue score changes
|
||||
@ -70,8 +70,8 @@ func TestVirtualSelectedParentBlueScoreAndVirtualDAAScore(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Error getting virtual selected parent blue score: %s", err)
|
||||
}
|
||||
if response.BlueScore != 1+blockAmountToMine {
|
||||
if response.BlueScore != blockAmountToMine {
|
||||
t.Fatalf("Unexpected virtual selected parent blue score. Want: %d, got: %d",
|
||||
1+blockAmountToMine, response.BlueScore)
|
||||
blockAmountToMine, response.BlueScore)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user