Skip to content

Commit

Permalink
add: compute_columns_for_custody_group tests (#6838)
Browse files Browse the repository at this point in the history
* add new fixture networking tests

* update all tests

* fix test

* avoid extra variables

* other fixes

* oops

* updated tests file
  • Loading branch information
agnxsh authored Jan 12, 2025
1 parent 4f161e7 commit bc55a3a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 12 deletions.
9 changes: 7 additions & 2 deletions AllTests-mainnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,11 @@ OK: 253/253 Fail: 0/253 Skip: 0/253
OK: 56/56 Fail: 0/56 Skip: 0/56
## EF - PeerDAS - Networking [Preset: mainnet]
```diff
+ Networking - Compute Columns for Custody Group - mainnet/fulu/networking/compute_columns_f OK
+ Networking - Compute Columns for Custody Group - mainnet/fulu/networking/compute_columns_f OK
+ Networking - Compute Columns for Custody Group - mainnet/fulu/networking/compute_columns_f OK
+ Networking - Compute Columns for Custody Group - mainnet/fulu/networking/compute_columns_f OK
+ Networking - Compute Columns for Custody Group - mainnet/fulu/networking/compute_columns_f OK
+ Networking - Get Custody Groups - mainnet/fulu/networking/get_custody_groups/pyspec_tests/ OK
+ Networking - Get Custody Groups - mainnet/fulu/networking/get_custody_groups/pyspec_tests/ OK
+ Networking - Get Custody Groups - mainnet/fulu/networking/get_custody_groups/pyspec_tests/ OK
Expand All @@ -523,7 +528,7 @@ OK: 56/56 Fail: 0/56 Skip: 0/56
+ Networking - Get Custody Groups - mainnet/fulu/networking/get_custody_groups/pyspec_tests/ OK
+ Networking - Get Custody Groups - mainnet/fulu/networking/get_custody_groups/pyspec_tests/ OK
```
OK: 9/9 Fail: 0/9 Skip: 0/9
OK: 14/14 Fail: 0/14 Skip: 0/14
## EF - SSZ generic types
```diff
Testing basic_vector inputs - invalid Skip
Expand Down Expand Up @@ -1149,4 +1154,4 @@ OK: 2/2 Fail: 0/2 Skip: 0/2
OK: 9/9 Fail: 0/9 Skip: 0/9

---TOTAL---
OK: 778/783 Fail: 0/783 Skip: 5/783
OK: 783/788 Fail: 0/788 Skip: 5/788
4 changes: 2 additions & 2 deletions beacon_chain/spec/peerdas_helpers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ type
ProofBytes = array[fulu.CELLS_PER_EXT_BLOB, KzgProof]

# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.10/specs/fulu/das-core.md#compute_columns_for_custody_group
iterator compute_columns_for_custody_group(custody_group: CustodyIndex):
ColumnIndex =
iterator compute_columns_for_custody_group*(custody_group: CustodyIndex):
ColumnIndex =
for i in 0'u64 ..< COLUMNS_PER_GROUP:
yield ColumnIndex(NUMBER_OF_CUSTODY_GROUPS * i + custody_group)

Expand Down
40 changes: 32 additions & 8 deletions tests/consensus_spec/test_fixture_networking.nim
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,28 @@ import
../testutil,
./fixtures_utils, ./os_ops

from std/sequtils import mapIt
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

proc runGetCustodyColumns(suiteName, path: string) =
proc runGetCustodyGroups(suiteName, path: string) =
let relativePathComponent = path.relativeTestPathComponent()
test "Networking - Get Custody Groups - " & relativePathComponent:
type TestMetaYaml = object
Expand All @@ -36,17 +55,22 @@ proc runGetCustodyColumns(suiteName, path: string) =
res
node_id = UInt256.fromDecimal(meta.node_id)
custody_group_count = meta.custody_group_count
reslt = (meta.result).mapIt(it)

let columns = get_custody_groups(node_id, custody_group_count)

for i in 0..<columns.lenu64:
check columns[i] == reslt[i]
check columns[i] == meta.result[i]

suite "EF - PeerDAS - Networking" & preset():
const presetPath = SszTestsDir/const_preset
# foldering to be resolved in alpha 11 release of consensus spec tests
let basePath =
presetPath/"fulu"/"networking"/"get_custody_groups"/"pyspec_tests"
for kind, path in walkDir(basePath, relative = true, checkDir = true):
runGetCustodyColumns(suiteName, basePath/path)
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)

0 comments on commit bc55a3a

Please sign in to comment.