[#82] Return length check of serialized container

In #37 we've decided to remove length check, because smart contract would
fail on casting `nil` value from storage to `[]byte` producing FAULT state.
Apparently it does not fail, so we have to check length explicitly.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-10-07 19:22:22 +03:00 committed by Alex Vanin
parent 87fc4f5df7
commit 7d51688d2c

View file

@ -71,7 +71,14 @@ func (w *Wrapper) Get(cid *container.ID) (*container.Container, error) {
// ask RPC neo node to get serialized container // ask RPC neo node to get serialized container
rpcAnswer, err := w.client.Get(args) rpcAnswer, err := w.client.Get(args)
if err != nil { if err != nil {
return nil, errors.Wrap(core.ErrNotFound, err.Error()) return nil, err
}
// In #37 we've decided to remove length check, because smart contract would
// fail on casting `nil` value from storage to `[]byte` producing FAULT state.
// Apparently it does not fail, so we have to check length explicitly.
if len(rpcAnswer.Container()) == 0 {
return nil, core.ErrNotFound
} }
// convert serialized bytes into GRPC structure // convert serialized bytes into GRPC structure