Skip to content

Commit

Permalink
neorpc: change func getStorage - return errors
Browse files Browse the repository at this point in the history
Function getStorage has started to return errors unlike to previous behavior: return nil instead of errors.

Close nspcc-dev#2248

Signed-off-by: Tatiana Nesterenko <tatiana@nspcc.io>
  • Loading branch information
tatiana-nspcc committed Aug 10, 2023
1 parent e2aabe4 commit 907b120
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
5 changes: 1 addition & 4 deletions pkg/services/rpcsrv/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1718,9 +1718,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.ErrVerificationFailed {
return nil, nil
}
if rErr != nil {
return nil, rErr
}
Expand All @@ -1732,7 +1729,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
Expand Down
10 changes: 4 additions & 6 deletions pkg/services/rpcsrv/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 907b120

Please sign in to comment.