2024-09-04 19:35:18 +05:30
|
|
|
# beacon_chain
|
2025-01-08 04:19:22 +05:30
|
|
|
# Copyright (c) 2024-2025 Status Research & Development GmbH
|
2024-09-04 19:35:18 +05:30
|
|
|
# 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,
|
|
|
|
kzg4844/[kzg, kzg_abi],
|
|
|
|
stint,
|
|
|
|
eth/p2p/discoveryv5/[node],
|
2024-12-20 15:53:46 +05:30
|
|
|
../../beacon_chain/spec/peerdas_helpers,
|
2024-09-04 19:35:18 +05:30
|
|
|
../testutil,
|
|
|
|
./fixtures_utils, ./os_ops
|
|
|
|
|
2025-01-12 10:34:55 +05:30
|
|
|
proc runComputeForCustodyGroup(suiteName, path: string) =
|
|
|
|
let relativeTestPathComponent = path.relativeTestPathComponent()
|
|
|
|
test "Networking - Compute Columns for Custody Group - " &
|
|
|
|
relativeTestPathComponent:
|
|
|
|
type TestMetaYaml = object
|
|
|
|
custody_group: uint64
|
|
|
|
result: seq[uint64]
|
|
|
|
let
|
|
|
|
meta = block:
|
|
|
|
var s = openFileStream(path/"meta.yaml")
|
|
|
|
defer: close(s)
|
|
|
|
var res: TestMetaYaml
|
|
|
|
yaml.load(s, res)
|
|
|
|
res
|
|
|
|
custody_group = meta.custody_group
|
|
|
|
|
|
|
|
var counter = 0
|
|
|
|
for column in compute_columns_for_custody_group(custody_group):
|
|
|
|
check column == meta.result[counter]
|
|
|
|
inc counter
|
2024-09-04 19:35:18 +05:30
|
|
|
|
2025-01-12 10:34:55 +05:30
|
|
|
proc runGetCustodyGroups(suiteName, path: string) =
|
2024-09-04 19:35:18 +05:30
|
|
|
let relativePathComponent = path.relativeTestPathComponent()
|
2024-12-29 02:37:12 +05:30
|
|
|
test "Networking - Get Custody Groups - " & relativePathComponent:
|
2024-09-04 19:35:18 +05:30
|
|
|
type TestMetaYaml = object
|
|
|
|
node_id: string
|
2024-12-15 13:18:52 +00:00
|
|
|
custody_group_count: uint64
|
2024-09-04 19:35:18 +05:30
|
|
|
result: seq[uint64]
|
|
|
|
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-12-15 13:18:52 +00:00
|
|
|
custody_group_count = meta.custody_group_count
|
2024-09-04 19:35:18 +05:30
|
|
|
|
2024-12-29 02:37:12 +05:30
|
|
|
let columns = get_custody_groups(node_id, custody_group_count)
|
2024-09-04 19:35:18 +05:30
|
|
|
|
|
|
|
for i in 0..<columns.lenu64:
|
2025-01-12 10:34:55 +05:30
|
|
|
check columns[i] == meta.result[i]
|
2024-09-04 19:35:18 +05:30
|
|
|
|
2025-01-08 04:19:22 +05:30
|
|
|
suite "EF - PeerDAS - Networking" & preset():
|
2024-09-04 19:35:18 +05:30
|
|
|
const presetPath = SszTestsDir/const_preset
|
2024-12-29 02:37:12 +05:30
|
|
|
# foldering to be resolved in alpha 11 release of consensus spec tests
|
2025-01-12 10:34:55 +05:30
|
|
|
block:
|
|
|
|
let basePath =
|
|
|
|
presetPath/"fulu"/"networking"/"get_custody_groups"/"pyspec_tests"
|
|
|
|
for kind, path in walkDir(basePath, relative = true, checkDir = true):
|
|
|
|
runGetCustodyGroups(suiteName, basePath/path)
|
|
|
|
block:
|
|
|
|
let basePath =
|
|
|
|
presetPath/"fulu"/"networking"/"compute_columns_for_custody_group"/"pyspec_tests"
|
|
|
|
for kind, path in walkDir(basePath, relative = true, checkDir = true):
|
|
|
|
runComputeForCustodyGroup(suiteName, basePath/path)
|