forked from TrueCloudLab/neoneo-go
rpc: add Magic to Version
This commit is contained in:
parent
c50f3db6ad
commit
474d2dfb65
3 changed files with 10 additions and 5 deletions
|
@ -631,9 +631,10 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
|
||||||
invoke: func(c *Client) (interface{}, error) {
|
invoke: func(c *Client) (interface{}, error) {
|
||||||
return c.GetVersion()
|
return c.GetVersion()
|
||||||
},
|
},
|
||||||
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"tcpport":20332,"wsport":20342,"nonce":2153672787,"useragent":"/NEO-GO:0.73.1-pre-273-ge381358/"}}`,
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"magic":42,"tcpport":20332,"wsport":20342,"nonce":2153672787,"useragent":"/NEO-GO:0.73.1-pre-273-ge381358/"}}`,
|
||||||
result: func(c *Client) interface{} {
|
result: func(c *Client) interface{} {
|
||||||
return &result.Version{
|
return &result.Version{
|
||||||
|
Magic: netmode.UnitTestNet,
|
||||||
TCPPort: uint16(20332),
|
TCPPort: uint16(20332),
|
||||||
WSPort: uint16(20342),
|
WSPort: uint16(20342),
|
||||||
Nonce: 2153672787,
|
Nonce: 2153672787,
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
package result
|
package result
|
||||||
|
|
||||||
|
import "github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
||||||
|
|
||||||
type (
|
type (
|
||||||
// Version model used for reporting server version
|
// Version model used for reporting server version
|
||||||
// info.
|
// info.
|
||||||
Version struct {
|
Version struct {
|
||||||
TCPPort uint16 `json:"tcpport"`
|
Magic netmode.Magic `json:"magic"`
|
||||||
WSPort uint16 `json:"wsport,omitempty"`
|
TCPPort uint16 `json:"tcpport"`
|
||||||
Nonce uint32 `json:"nonce"`
|
WSPort uint16 `json:"wsport,omitempty"`
|
||||||
UserAgent string `json:"useragent"`
|
Nonce uint32 `json:"nonce"`
|
||||||
|
UserAgent string `json:"useragent"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -466,6 +466,7 @@ func (s *Server) getVersion(_ request.Params) (interface{}, *response.Error) {
|
||||||
return nil, response.NewInternalServerError("Cannot fetch tcp port", err)
|
return nil, response.NewInternalServerError("Cannot fetch tcp port", err)
|
||||||
}
|
}
|
||||||
return result.Version{
|
return result.Version{
|
||||||
|
Magic: s.network,
|
||||||
TCPPort: port,
|
TCPPort: port,
|
||||||
Nonce: s.coreServer.ID(),
|
Nonce: s.coreServer.ID(),
|
||||||
UserAgent: s.coreServer.UserAgent,
|
UserAgent: s.coreServer.UserAgent,
|
||||||
|
|
Loading…
Reference in a new issue