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 =
|
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():
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue