From c189062f405f84238f4bffbf84800b4dc2a096ac Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 13 Jan 2020 11:33:04 +0300 Subject: [PATCH] rpc: move ValidateAddress to the result package Because it is a result of the RPC call. --- pkg/rpc/{wrappers => result}/validate_address.go | 6 +++--- pkg/rpc/server.go | 4 ++-- pkg/rpc/server_helper_test.go | 6 +++--- pkg/rpc/server_test.go | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) rename pkg/rpc/{wrappers => result}/validate_address.go (61%) diff --git a/pkg/rpc/wrappers/validate_address.go b/pkg/rpc/result/validate_address.go similarity index 61% rename from pkg/rpc/wrappers/validate_address.go rename to pkg/rpc/result/validate_address.go index 3af2c0d23..bb4963893 100644 --- a/pkg/rpc/wrappers/validate_address.go +++ b/pkg/rpc/result/validate_address.go @@ -1,9 +1,9 @@ -package wrappers +package result -// ValidateAddressResponse represents response to validate address call. Notice +// ValidateAddress represents result of the `validateaddress` call. Notice that // Address is an interface{} here because server echoes back whatever address // value user has sent to it, even if it's not a string. -type ValidateAddressResponse struct { +type ValidateAddress struct { Address interface{} `json:"address"` IsValid bool `json:"isvalid"` } diff --git a/pkg/rpc/server.go b/pkg/rpc/server.go index 880d3959b..47f186c9d 100644 --- a/pkg/rpc/server.go +++ b/pkg/rpc/server.go @@ -555,8 +555,8 @@ func (s *Server) blockHeightFromParam(param *Param) (int, error) { // validateAddress verifies that the address is a correct NEO address // see https://docs.neo.org/en-us/node/cli/2.9.4/api/validateaddress.html -func validateAddress(addr interface{}) wrappers.ValidateAddressResponse { - resp := wrappers.ValidateAddressResponse{Address: addr} +func validateAddress(addr interface{}) result.ValidateAddress { + resp := result.ValidateAddress{Address: addr} if addr, ok := addr.(string); ok { _, err := address.StringToUint160(addr) resp.IsValid = (err == nil) diff --git a/pkg/rpc/server_helper_test.go b/pkg/rpc/server_helper_test.go index 5451d4e1b..b3350c82f 100644 --- a/pkg/rpc/server_helper_test.go +++ b/pkg/rpc/server_helper_test.go @@ -50,9 +50,9 @@ type InvokeFunctionResponse struct { // ValidateAddrResponse struct for testing. type ValidateAddrResponse struct { - Jsonrpc string `json:"jsonrpc"` - Result wrappers.ValidateAddressResponse `json:"result"` - ID int `json:"id"` + Jsonrpc string `json:"jsonrpc"` + Result result.ValidateAddress `json:"result"` + ID int `json:"id"` } // GetPeersResponse struct for testing. diff --git a/pkg/rpc/server_test.go b/pkg/rpc/server_test.go index 71826a559..5720299ea 100644 --- a/pkg/rpc/server_test.go +++ b/pkg/rpc/server_test.go @@ -14,7 +14,7 @@ import ( "github.com/CityOfZion/neo-go/pkg/core" "github.com/CityOfZion/neo-go/pkg/core/transaction" - "github.com/CityOfZion/neo-go/pkg/rpc/wrappers" + "github.com/CityOfZion/neo-go/pkg/rpc/result" "github.com/CityOfZion/neo-go/pkg/util" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -527,7 +527,7 @@ var rpcTestCases = map[string][]rpcTestCase{ result: func(*executor) interface{} { return &ValidateAddrResponse{ Jsonrpc: defaultJSONRPC, - Result: wrappers.ValidateAddressResponse{ + Result: result.ValidateAddress{ Address: float64(1), IsValid: false, },