rpc/client: support verifyproof RPC

This commit is contained in:
Evgenii Stratonikov 2020-06-25 15:56:05 +03:00
parent 654877fb1b
commit eb37f92881
2 changed files with 25 additions and 0 deletions

View file

@ -913,6 +913,20 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
},
},
},
"verifyproof": {
{
name: "positive",
invoke: func(c *Client) (interface{}, error) {
return c.VerifyProof(util.Uint256{}, new(result.ProofWithKey))
},
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"value":"7465737476616c7565"}}`,
result: func(c *Client) interface{} {
return &result.VerifyProof{
Value: []byte("testvalue"),
}
},
},
},
}
type rpcClientErrorCase struct {

View file

@ -48,3 +48,14 @@ func (c *Client) GetProof(root util.Uint256, sc util.Uint160, key []byte) (*resu
}
return &resp, nil
}
// VerifyProof verifies keyed proof for the state with the specified root.
func (c *Client) VerifyProof(root util.Uint256, proof *result.ProofWithKey) (*result.VerifyProof, error) {
resp := new(result.VerifyProof)
ps := request.NewRawParams(root, proof.String())
err := c.performRequest("verifyproof", ps, resp)
if err != nil {
return nil, err
}
return resp, nil
}