From 474d2dfb658b1e3707ef6a12ab6c9cd3ebe44a04 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Wed, 14 Oct 2020 16:52:49 +0300 Subject: [PATCH] rpc: add Magic to Version --- pkg/rpc/client/rpc_test.go | 3 ++- pkg/rpc/response/result/version.go | 11 +++++++---- pkg/rpc/server/server.go | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pkg/rpc/client/rpc_test.go b/pkg/rpc/client/rpc_test.go index 6c58e6075..bc1a733d0 100644 --- a/pkg/rpc/client/rpc_test.go +++ b/pkg/rpc/client/rpc_test.go @@ -631,9 +631,10 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{ invoke: func(c *Client) (interface{}, error) { 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{} { return &result.Version{ + Magic: netmode.UnitTestNet, TCPPort: uint16(20332), WSPort: uint16(20342), Nonce: 2153672787, diff --git a/pkg/rpc/response/result/version.go b/pkg/rpc/response/result/version.go index 3572d6685..4d0fd76d0 100644 --- a/pkg/rpc/response/result/version.go +++ b/pkg/rpc/response/result/version.go @@ -1,12 +1,15 @@ package result +import "github.com/nspcc-dev/neo-go/pkg/config/netmode" + type ( // Version model used for reporting server version // info. Version struct { - TCPPort uint16 `json:"tcpport"` - WSPort uint16 `json:"wsport,omitempty"` - Nonce uint32 `json:"nonce"` - UserAgent string `json:"useragent"` + Magic netmode.Magic `json:"magic"` + TCPPort uint16 `json:"tcpport"` + WSPort uint16 `json:"wsport,omitempty"` + Nonce uint32 `json:"nonce"` + UserAgent string `json:"useragent"` } ) diff --git a/pkg/rpc/server/server.go b/pkg/rpc/server/server.go index 85630ca8a..ed5a4e851 100644 --- a/pkg/rpc/server/server.go +++ b/pkg/rpc/server/server.go @@ -466,6 +466,7 @@ func (s *Server) getVersion(_ request.Params) (interface{}, *response.Error) { return nil, response.NewInternalServerError("Cannot fetch tcp port", err) } return result.Version{ + Magic: s.network, TCPPort: port, Nonce: s.coreServer.ID(), UserAgent: s.coreServer.UserAgent,