mirror of https://github.com/status-im/nim-rlp.git
isEmpty() now considers RLP with no data to be empty
This commit is contained in:
parent
6d08835d98
commit
323eb18706
4
rlp.nim
4
rlp.nim
|
@ -71,7 +71,7 @@ proc isBlob*(self: Rlp): bool =
|
|||
|
||||
proc isEmpty*(self: Rlp): bool =
|
||||
### 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)
|
||||
|
||||
proc isList*(self: Rlp): bool =
|
||||
|
@ -233,7 +233,7 @@ proc toBytes*(self: Rlp): BytesRange =
|
|||
result = bytes.slice(ibegin, iend)
|
||||
|
||||
proc currentElemEnd(self: Rlp): int =
|
||||
assert hasData()
|
||||
doAssert hasData()
|
||||
result = position
|
||||
|
||||
if isSingleByte():
|
||||
|
|
|
@ -13,7 +13,7 @@ test "empty bytes are not a proper RLP":
|
|||
not rlp.hasData
|
||||
not rlp.isBlob
|
||||
not rlp.isList
|
||||
not rlp.isEmpty
|
||||
rlp.isEmpty
|
||||
|
||||
expect Exception:
|
||||
rlp.skipElem
|
||||
|
|
Loading…
Reference in New Issue