diff --git a/pkg/rpc/client/rpc_test.go b/pkg/rpc/client/rpc_test.go index 501fd15d1..636c0ffbd 100644 --- a/pkg/rpc/client/rpc_test.go +++ b/pkg/rpc/client/rpc_test.go @@ -620,6 +620,21 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{ }, }, }, + "getstateheight": { + { + name: "positive", + invoke: func(c *Client) (interface{}, error) { + return c.GetStateHeight() + }, + serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"blockHeight":208,"stateHeight":200}}`, + result: func(c *Client) interface{} { + return &result.StateHeight{ + BlockHeight: 208, + StateHeight: 200, + } + }, + }, + }, "getstateroot": { { name: "positive", diff --git a/pkg/rpc/client/state.go b/pkg/rpc/client/state.go index 499ef9060..6dbc324cf 100644 --- a/pkg/rpc/client/state.go +++ b/pkg/rpc/client/state.go @@ -3,6 +3,7 @@ package client import ( "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/rpc/request" + "github.com/nspcc-dev/neo-go/pkg/rpc/response/result" "github.com/nspcc-dev/neo-go/pkg/util" ) @@ -24,3 +25,13 @@ func (c *Client) getStateRoot(p request.RawParams) (*state.MPTRootState, error) } return &resp, nil } + +// GetStateHeight returns current block and state height. +func (c *Client) GetStateHeight() (*result.StateHeight, error) { + resp := new(result.StateHeight) + err := c.performRequest("getstateheight", request.NewRawParams(), resp) + if err != nil { + return nil, err + } + return resp, nil +}