rpcsrv, rpcclient: support findstorage and findstoragehistoric

Close #3095 and add the corresponding historic extension.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
Anna Shaleva 2023-08-22 19:00:43 +03:00
parent 124c3df2ff
commit 617c628c24
11 changed files with 741 additions and 43 deletions

View file

@ -915,6 +915,74 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
},
},
},
"findstorage": {
{
name: "positive by hash",
invoke: func(c *Client) (any, error) {
cHash, _ := util.Uint160DecodeStringLE("5c9e40a12055c6b9e3f72271c9779958c842135d")
start := 1
return c.FindStorageByHash(cHash, []byte("aa"), &start)
},
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"results":[{"key":"YWExMA==","value":"djI="}],"truncated":true, "next": 1}}`,
result: func(c *Client) any {
return result.FindStorage{
Results: []result.KeyValue{{Key: []byte("aa10"), Value: []byte("v2")}},
Truncated: true,
Next: 1,
}
},
},
{
name: "positive by ID",
invoke: func(c *Client) (any, error) {
start := 1
return c.FindStorageByID(1, []byte("aa"), &start)
},
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"results":[{"key":"YWExMA==","value":"djI="}],"truncated":true, "next": 1}}`,
result: func(c *Client) any {
return result.FindStorage{
Results: []result.KeyValue{{Key: []byte("aa10"), Value: []byte("v2")}},
Truncated: true,
Next: 1,
}
},
},
},
"findstoragehistoric": {
{
name: "positive by hash",
invoke: func(c *Client) (any, error) {
root, _ := util.Uint256DecodeStringLE("252e9d73d49c95c7618d40650da504e05183a1b2eed0685e42c360413c329170")
cHash, _ := util.Uint160DecodeStringLE("5c9e40a12055c6b9e3f72271c9779958c842135d")
start := 1
return c.FindStorageByHashHistoric(root, cHash, []byte("aa"), &start)
},
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"results":[{"key":"YWExMA==","value":"djI="}],"truncated":true, "next": 1}}`,
result: func(c *Client) any {
return result.FindStorage{
Results: []result.KeyValue{{Key: []byte("aa10"), Value: []byte("v2")}},
Truncated: true,
Next: 1,
}
},
},
{
name: "positive by ID",
invoke: func(c *Client) (any, error) {
root, _ := util.Uint256DecodeStringLE("252e9d73d49c95c7618d40650da504e05183a1b2eed0685e42c360413c329170")
start := 1
return c.FindStorageByIDHistoric(root, 1, []byte("aa"), &start)
},
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"results":[{"key":"YWExMA==","value":"djI="}],"truncated":true, "next": 1}}`,
result: func(c *Client) any {
return result.FindStorage{
Results: []result.KeyValue{{Key: []byte("aa10"), Value: []byte("v2")}},
Truncated: true,
Next: 1,
}
},
},
},
"getstateheight": {
{
name: "positive",