Skip to content

Commit

Permalink
Update GetNodeVersionInfo response object
Browse files Browse the repository at this point in the history
  • Loading branch information
illia-malachyn committed Sep 26, 2024
1 parent 9b49f3e commit d61758c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions access/grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,19 @@ func (c *BaseClient) GetNodeVersionInfo(ctx context.Context, opts ...grpc.CallOp
}

info := res.GetInfo()
compRange := flow.CompatibleRange{
StartHeight: info.CompatibleRange.GetStartHeight(),
EndHeight: info.CompatibleRange.GetEndHeight(),
}

return &flow.NodeVersionInfo{
Semver: info.Semver,
Commit: info.Commit,
SporkId: flow.BytesToID(info.SporkId),
ProtocolVersion: info.ProtocolVersion,
SporkRootBlockHeight: info.SporkRootBlockHeight,
NodeRootBlockHeight: info.NodeRootBlockHeight,
CompatibleRange: compRange,
}, nil
}

Expand Down
3 changes: 3 additions & 0 deletions access/grpc/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ func TestClient_GetNodeInfo(t *testing.T) {
ver := uint64(1)
spork := uint64(2)
root := uint64(3)
compRange := &entities.CompatibleRange{StartHeight: 1, EndHeight: 10}

response := &access.GetNodeVersionInfoResponse{
Info: &entities.NodeVersionInfo{
Expand All @@ -165,6 +166,7 @@ func TestClient_GetNodeInfo(t *testing.T) {
ProtocolVersion: ver,
SporkRootBlockHeight: spork,
NodeRootBlockHeight: root,
CompatibleRange: compRange,
},
}

Expand All @@ -175,6 +177,7 @@ func TestClient_GetNodeInfo(t *testing.T) {
ProtocolVersion: ver,
SporkRootBlockHeight: spork,
NodeRootBlockHeight: root,
CompatibleRange: flow.CompatibleRange{StartHeight: compRange.StartHeight, EndHeight: compRange.EndHeight},
}

rpc.On("GetNodeVersionInfo", ctx, mock.Anything).Return(response, nil)
Expand Down
6 changes: 6 additions & 0 deletions flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ type NodeVersionInfo struct {
ProtocolVersion uint64
SporkRootBlockHeight uint64
NodeRootBlockHeight uint64
CompatibleRange CompatibleRange
}

type CompatibleRange struct {
StartHeight uint64
EndHeight uint64
}

// entityHasher is a thread-safe hasher used to hash Flow entities.
Expand Down

0 comments on commit d61758c

Please sign in to comment.