Cleanup tags from yaml output and use 0xHex (#2160)
This commit is contained in:
parent
df2dcf593c
commit
24b4d52dea
|
@ -7,7 +7,7 @@
|
|||
|
||||
{.push raises: [].}
|
||||
|
||||
import ssz_serialization/types
|
||||
import ssz_serialization/types, stew/byteutils
|
||||
|
||||
type
|
||||
YamlTestProofBellatrix* = object
|
||||
|
@ -38,6 +38,6 @@ proc fromHex*[n](T: type array[n, Digest], a: array[n, string]): T =
|
|||
proc toHex*[n](a: array[n, Digest], T: type array[n, string]): T =
|
||||
var res: T
|
||||
for i in 0 ..< a.len:
|
||||
res[i] = toHex(a[i].data)
|
||||
res[i] = to0xHex(a[i].data)
|
||||
|
||||
res
|
||||
|
|
|
@ -41,6 +41,20 @@ proc loadFromYaml*(T: type, file: string): Result[T, string] =
|
|||
ok(res)
|
||||
|
||||
proc dumpToYaml*[T](value: T, file: string): Result[void, string] =
|
||||
# These are the default options aside from outputVersion which is set to none.
|
||||
const options = PresentationOptions(
|
||||
containers: cMixed,
|
||||
indentationStep: 2,
|
||||
newlines: nlOSDefault,
|
||||
outputVersion: ovNone,
|
||||
maxLineLength: some(80),
|
||||
directivesEnd: deIfNecessary,
|
||||
suppressAttrs: false,
|
||||
quoting: sqUnset,
|
||||
condenseFlow: true,
|
||||
explicitKeys: false,
|
||||
)
|
||||
|
||||
let s = newFileStream(file, fmWrite)
|
||||
defer:
|
||||
try:
|
||||
|
@ -48,7 +62,8 @@ proc dumpToYaml*[T](value: T, file: string): Result[void, string] =
|
|||
except Exception as e:
|
||||
raiseAssert(e.msg)
|
||||
try:
|
||||
dump(value, s)
|
||||
# Dump to yaml, avoiding TAGS and YAML version directives.
|
||||
dump(value, s, tagStyle = tsNone, options = options, handles = @[])
|
||||
except YamlPresenterJsonError as e:
|
||||
return err(e.msg)
|
||||
except YamlSerializationError as e:
|
||||
|
|
|
@ -347,11 +347,11 @@ proc exportBeaconBlockProofBellatrix(
|
|||
|
||||
let yamlTestProof = YamlTestProofBellatrix(
|
||||
execution_block_header:
|
||||
beaconBlock.message.body.execution_payload.block_hash.data.toHex,
|
||||
beaconBlock.message.body.execution_payload.block_hash.data.to0xHex(),
|
||||
beacon_block_body_proof: blockProof.beaconBlockBodyProof.toHex(array[8, string]),
|
||||
beacon_block_body_root: blockProof.beaconBlockBodyRoot.data.toHex(),
|
||||
beacon_block_body_root: blockProof.beaconBlockBodyRoot.data.to0xHex(),
|
||||
beacon_block_header_proof: blockProof.beaconBlockHeaderProof.toHex(array[3, string]),
|
||||
beacon_block_header_root: blockProof.beaconBlockHeaderRoot.data.toHex(),
|
||||
beacon_block_header_root: blockProof.beaconBlockHeaderRoot.data.to0xHex(),
|
||||
historical_roots_proof: blockProof.historicalRootsProof.toHex(array[14, string]),
|
||||
slot: blockProof.slot.uint64,
|
||||
)
|
||||
|
@ -469,11 +469,11 @@ proc exportBeaconBlockProofCapella(
|
|||
|
||||
let yamlTestProof = YamlTestProof(
|
||||
execution_block_header:
|
||||
beaconBlock.message.body.execution_payload.block_hash.data.toHex,
|
||||
beaconBlock.message.body.execution_payload.block_hash.data.to0xHex(),
|
||||
beacon_block_body_proof: blockProof.beaconBlockBodyProof.toHex(array[8, string]),
|
||||
beacon_block_body_root: blockProof.beaconBlockBodyRoot.data.toHex(),
|
||||
beacon_block_body_root: blockProof.beaconBlockBodyRoot.data.to0xHex(),
|
||||
beacon_block_header_proof: blockProof.beaconBlockHeaderProof.toHex(array[3, string]),
|
||||
beacon_block_header_root: blockProof.beaconBlockHeaderRoot.data.toHex(),
|
||||
beacon_block_header_root: blockProof.beaconBlockHeaderRoot.data.to0xHex(),
|
||||
historical_summaries_proof:
|
||||
blockProof.historicalSummariesProof.toHex(array[13, string]),
|
||||
slot: blockProof.slot.uint64,
|
||||
|
|
Loading…
Reference in New Issue