-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: loop sorted validator indexes * generate JSON tests * use generic sorting function
- Loading branch information
1 parent
3a9cb8e
commit 3d6c3ac
Showing
12 changed files
with
1,870 additions
and
1,852 deletions.
There are no files selected for viewing
904 changes: 452 additions & 452 deletions
904
ssv/spectest/generate/tests/committee.MultiCommitteeSpecTest_decided.json
Large diffs are not rendered by default.
Oops, something went wrong.
2,050 changes: 1,025 additions & 1,025 deletions
2,050
ssv/spectest/generate/tests/committee.MultiCommitteeSpecTest_happy_flow.json
Large diffs are not rendered by default.
Oops, something went wrong.
162 changes: 81 additions & 81 deletions
162
...rate/tests/committee.MultiCommitteeSpecTest_start_committee_duty_with_missing_shares.json
Large diffs are not rendered by default.
Oops, something went wrong.
108 changes: 54 additions & 54 deletions
108
...tiMsgProcessingSpecTest_post_consensus_partial_invalid_root_quorum_then_valid_quorum.json
Large diffs are not rendered by default.
Oops, something went wrong.
368 changes: 184 additions & 184 deletions
368
...ltiMsgProcessingSpecTest_post_consensus_partial_invalid_sig_quorum_then_valid_quorum.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package testingutils | ||
|
||
import ( | ||
"sort" | ||
|
||
"golang.org/x/exp/constraints" | ||
) | ||
|
||
// SortMapByKey sorts a map by its keys and returns a sorted slice of key-value pairs. | ||
func SortedMapKeys[K constraints.Ordered, V any](m map[K]V) []struct { | ||
Key K | ||
Value V | ||
} { | ||
// Extract and sort keys | ||
keys := make([]K, 0, len(m)) | ||
for k := range m { | ||
keys = append(keys, k) | ||
} | ||
sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] }) | ||
|
||
// Create sorted key-value pairs | ||
pairs := make([]struct { | ||
Key K | ||
Value V | ||
}, len(keys)) | ||
|
||
for i, k := range keys { | ||
pairs[i] = struct { | ||
Key K | ||
Value V | ||
}{k, m[k]} | ||
} | ||
|
||
return pairs | ||
} |