Skip to content

[TM-329] Consider lengths during unpack

Konstantin Ivanov requested to merge martoon/tm329-consider-lengths into master

Description

All binary data in Michelson encoding is prefixed with its length, and sometimes we ignore this length and parse as many bytes as reasonable with regard to the type we parse (e.g. Address has fixed length). But this is obviously wrong and if that length in the prefix does not match against how many bytes we are going to consume, then we have to fail.

After committing a fix, I noticed some refactorings which can be made, so this MR even reached fixing another issue.

Related issue(s)

https://issues.serokell.io/issue/TM-329

Resolves #19 (closed).

Checklist for your Merge Request

Related changes (conditional)

  • Tests (see short guidelines)

    • If I added new functionality, I added tests covering it.
    • If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
  • Documentation

    • I checked whether I should update the docs and did so if necessary:

Stylistic guide (mandatory)

Edited by Konstantin Ivanov

Merge request reports