mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 07:58:22 -05:00
refactor: use maps.Copy for cleaner map handling (#15090)
Signed-off-by: xinhangzhou <shuangcui@aliyun.com>
This commit is contained in:
@@ -150,7 +150,14 @@ func Test_endpoints(t *testing.T) {
|
||||
actualRoutes[e.template] = e.methods
|
||||
}
|
||||
}
|
||||
expectedRoutes := combineMaps(beaconRoutes, builderRoutes, configRoutes, debugRoutes, eventsRoutes, nodeRoutes, validatorRoutes, rewardsRoutes, lightClientRoutes, blobRoutes, prysmValidatorRoutes, prysmNodeRoutes, prysmBeaconRoutes)
|
||||
expectedRoutes := make(map[string][]string)
|
||||
for _, m := range []map[string][]string{
|
||||
beaconRoutes, builderRoutes, configRoutes, debugRoutes, eventsRoutes,
|
||||
nodeRoutes, validatorRoutes, rewardsRoutes, lightClientRoutes, blobRoutes,
|
||||
prysmValidatorRoutes, prysmNodeRoutes, prysmBeaconRoutes,
|
||||
} {
|
||||
maps.Copy(expectedRoutes, m)
|
||||
}
|
||||
|
||||
assert.Equal(t, true, maps.EqualFunc(expectedRoutes, actualRoutes, func(actualMethods []string, expectedMethods []string) bool {
|
||||
return slices.Equal(expectedMethods, actualMethods)
|
||||
|
||||
@@ -23,18 +23,6 @@ func init() {
|
||||
logrus.SetOutput(io.Discard)
|
||||
}
|
||||
|
||||
func combineMaps(maps ...map[string][]string) map[string][]string {
|
||||
combinedMap := make(map[string][]string)
|
||||
|
||||
for _, m := range maps {
|
||||
for k, v := range m {
|
||||
combinedMap[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
return combinedMap
|
||||
}
|
||||
|
||||
func TestLifecycle_OK(t *testing.T) {
|
||||
hook := logTest.NewGlobal()
|
||||
chainService := &mock.ChainService{
|
||||
|
||||
3
changelog/xinhangzhou_use_maps.Copy.md
Normal file
3
changelog/xinhangzhou_use_maps.Copy.md
Normal file
@@ -0,0 +1,3 @@
|
||||
### Ignored
|
||||
|
||||
- Use maps.Copy for cleaner map handling
|
||||
Reference in New Issue
Block a user