isEmpty() now considers RLP with no data to be empty

This commit is contained in:
Ștefan Talpalaru 2019-01-23 13:39:45 +01:00
parent 6d08835d98
commit 323eb18706
No known key found for this signature in database
GPG Key ID: CBF7934204F1B6F9
2 changed files with 3 additions and 3 deletions

View File

@ -71,7 +71,7 @@ proc isBlob*(self: Rlp): bool =
proc isEmpty*(self: Rlp): bool = proc isEmpty*(self: Rlp): bool =
### Contains a blob or a list of zero length ### Contains a blob or a list of zero length
hasData() and (bytes[position] == BLOB_START_MARKER or not hasData() or (bytes[position] == BLOB_START_MARKER or
bytes[position] == LIST_START_MARKER) bytes[position] == LIST_START_MARKER)
proc isList*(self: Rlp): bool = proc isList*(self: Rlp): bool =
@ -233,7 +233,7 @@ proc toBytes*(self: Rlp): BytesRange =
result = bytes.slice(ibegin, iend) result = bytes.slice(ibegin, iend)
proc currentElemEnd(self: Rlp): int = proc currentElemEnd(self: Rlp): int =
assert hasData() doAssert hasData()
result = position result = position
if isSingleByte(): if isSingleByte():

View File

@ -13,7 +13,7 @@ test "empty bytes are not a proper RLP":
not rlp.hasData not rlp.hasData
not rlp.isBlob not rlp.isBlob
not rlp.isList not rlp.isList
not rlp.isEmpty rlp.isEmpty
expect Exception: expect Exception:
rlp.skipElem rlp.skipElem