rpcsrv: return error on unknown storage item from getstorage

Follow the reference implementation, the behaviour was changed in
237ef7d057.

Signed-off-by: Tatiana Nesterenko <tatiana@nspcc.io>
This commit is contained in:
Tatiana Nesterenko 2023-08-11 22:56:15 +01:00
parent d3fe92de14
commit 1e6372e6d9
2 changed files with 5 additions and 10 deletions

View file

@ -1722,9 +1722,6 @@ func (s *Server) getStateRoot(ps params.Params) (any, *neorpc.Error) {
func (s *Server) getStorage(ps params.Params) (any, *neorpc.Error) {
id, rErr := s.contractIDFromParam(ps.Value(0))
if rErr == neorpc.ErrUnknownContract {
return nil, nil
}
if rErr != nil {
return nil, rErr
}
@ -1736,7 +1733,7 @@ func (s *Server) getStorage(ps params.Params) (any, *neorpc.Error) {
item := s.chain.GetStorageItem(id, key)
if item == nil {
return "", nil
return "", neorpc.ErrUnknownStorageItem
}
return []byte(item), nil

View file

@ -621,12 +621,10 @@ var rpcTestCases = map[string][]rpcTestCase{
},
},
{
name: "missing key",
params: fmt.Sprintf(`["%s", "dGU="]`, testContractHash),
result: func(e *executor) any {
v := ""
return &v
},
name: "missing key",
params: fmt.Sprintf(`["%s", "dGU="]`, testContractHash),
fail: true,
errCode: neorpc.ErrUnknownStorageItemCode,
},
{
name: "no params",