2024-06-07 07:40:28 +00:00
|
|
|
# beacon_chain
|
|
|
|
# Copyright (c) 2024 Status Research & Development GmbH
|
|
|
|
# Licensed and distributed under either of
|
|
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
|
|
|
{.push raises: [].}
|
|
|
|
{.used.}
|
|
|
|
|
|
|
|
import
|
|
|
|
std/[json, streams],
|
|
|
|
yaml,
|
2024-09-08 20:28:21 +00:00
|
|
|
kzg4844/[kzg, kzg_abi],
|
2024-06-07 07:40:28 +00:00
|
|
|
stint,
|
|
|
|
eth/p2p/discoveryv5/[node],
|
|
|
|
../../beacon_chain/spec/eip7594_helpers,
|
|
|
|
../testutil,
|
|
|
|
./fixtures_utils, ./os_ops
|
|
|
|
|
2024-09-08 20:28:21 +00:00
|
|
|
from std/sequtils import mapIt
|
2024-06-07 07:40:28 +00:00
|
|
|
|
|
|
|
proc runGetCustodyColumns(suiteName, path: string) =
|
|
|
|
let relativePathComponent = path.relativeTestPathComponent()
|
|
|
|
test "Networking - Get Custody Columns - " & relativePathComponent:
|
|
|
|
type TestMetaYaml = object
|
|
|
|
node_id: string
|
|
|
|
custody_subnet_count: uint64
|
2024-09-08 20:28:21 +00:00
|
|
|
result: seq[uint64]
|
2024-06-07 07:40:28 +00:00
|
|
|
let
|
|
|
|
meta = block:
|
|
|
|
var s = openFileStream(path/"meta.yaml")
|
|
|
|
defer: close(s)
|
|
|
|
var res: TestMetaYaml
|
|
|
|
yaml.load(s, res)
|
|
|
|
res
|
|
|
|
node_id = UInt256.fromDecimal(meta.node_id)
|
2024-09-08 20:28:21 +00:00
|
|
|
custody_subnet_count = meta.custody_subnet_count
|
|
|
|
reslt = (meta.result).mapIt(it)
|
|
|
|
|
|
|
|
let columns = get_custody_columns(node_id, custody_subnet_count)
|
2024-06-07 07:40:28 +00:00
|
|
|
|
2024-09-08 20:28:21 +00:00
|
|
|
for i in 0..<columns.lenu64:
|
|
|
|
check columns[i] == reslt[i]
|
2024-06-07 07:40:28 +00:00
|
|
|
|
|
|
|
suite "EF - EIP7594 - Networking" & preset():
|
2024-06-07 08:02:04 +00:00
|
|
|
const presetPath = SszTestsDir/const_preset
|
2024-06-07 07:40:28 +00:00
|
|
|
let basePath =
|
|
|
|
presetPath/"eip7594"/"networking"/"get_custody_columns"/"pyspec_tests"
|
|
|
|
for kind, path in walkDir(basePath, relative = true, checkDir = true):
|
2024-06-13 11:18:28 +00:00
|
|
|
runGetCustodyColumns(suiteName, basePath/path)
|