Tenative fix for the test suite
This commit is contained in:
parent
2a3c237bbb
commit
182593ccb5
|
@ -1,6 +1,6 @@
|
|||
import
|
||||
options,
|
||||
serialization,
|
||||
options, typetraits,
|
||||
serialization, chronicles,
|
||||
spec/[datatypes, digest, crypto],
|
||||
kvstore, ssz
|
||||
|
||||
|
@ -100,12 +100,17 @@ proc putTailBlock*(db: BeaconChainDB, key: Eth2Digest) =
|
|||
|
||||
proc get(db: BeaconChainDB, key: auto, T: typedesc): Option[T] =
|
||||
var res: Option[T]
|
||||
discard db.backend.get(key, proc (data: openArray[byte]) =
|
||||
discard db.backend.get(key) do (data: openArray[byte]):
|
||||
try:
|
||||
res = some(SSZ.decode(data, T))
|
||||
except SerializationError:
|
||||
discard
|
||||
)
|
||||
# Please note that this is intentionally a normal assert.
|
||||
# We consider this a hard failure in debug mode, because
|
||||
# it suggests a corrupted database. Release builds "recover"
|
||||
# from the situation by failing to deliver a result from the
|
||||
# database.
|
||||
assert false
|
||||
error "Corrupt database entry", key, `type` = name(T)
|
||||
res
|
||||
|
||||
proc getBlock*(db: BeaconChainDB, key: Eth2Digest): Option[SignedBeaconBlock] =
|
||||
|
|
|
@ -167,7 +167,7 @@ func readSszValue*(input: openarray[byte], T: type): T =
|
|||
endOffset = if boundingOffsets[1] == -1: input.len
|
||||
else: readOffset(boundingOffsets[1])
|
||||
trs "VAR FIELD ", startOffset, "-", endOffset
|
||||
if startOffset >= endOffset:
|
||||
if startOffset > endOffset:
|
||||
raise newException(MalformedSszError, "SSZ field offsets are not monotonically increasing")
|
||||
elif endOffset > input.len:
|
||||
raise newException(MalformedSszError, "SSZ field offset points past the end of the input")
|
||||
|
|
Loading…
Reference in New Issue