76 lines
2.1 KiB
Nim
76 lines
2.1 KiB
Nim
# Nimbus
|
|
# Copyright (c) 2024 Status Research & Development GmbH
|
|
# Licensed under either of
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
|
# http://opensource.org/licenses/MIT)
|
|
# at your option. This file may not be copied, modified, or
|
|
# distributed except according to those terms.
|
|
|
|
{.used.}
|
|
|
|
import unittest2, ../../nimbus/db/aristo/aristo_blobify
|
|
|
|
suite "Aristo blobify":
|
|
test "VertexRef roundtrip":
|
|
let
|
|
leafAccount = VertexRef(vType: Leaf, lData: LeafPayload(pType: AccountData))
|
|
leafStoData =
|
|
VertexRef(vType: Leaf, lData: LeafPayload(pType: StoData, stoData: 42.u256))
|
|
branch = VertexRef(
|
|
vType: Branch,
|
|
bVid: [
|
|
VertexID(0),
|
|
VertexID(1),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(4),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
],
|
|
)
|
|
|
|
extension = VertexRef(
|
|
vType: Branch,
|
|
pfx: NibblesBuf.nibble(2),
|
|
bVid: [
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(2),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(5),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
VertexID(0),
|
|
],
|
|
)
|
|
|
|
key = HashKey.fromBytes(rlp.encode([10'u64]))[]
|
|
|
|
check:
|
|
deblobify(blobify(leafAccount, key), VertexRef)[] == leafAccount
|
|
deblobify(blobify(leafStoData, key), VertexRef)[] == leafStoData
|
|
deblobify(blobify(branch, key), VertexRef)[] == branch
|
|
deblobify(blobify(extension, key), VertexRef)[] == extension
|
|
|
|
deblobify(blobify(branch, key), HashKey)[] == key
|
|
deblobify(blobify(extension, key), HashKey)[] == key
|