Commit 19a71f4c authored by Gari Singh's avatar Gari Singh Committed by Gerrit Code Review
Browse files

Merge "[FAB-5525] Fix configtx memory allocation bug"

parents b4051355 b3c14300
......@@ -83,7 +83,9 @@ func recurseConfig(result map[string]comparable, path []string, group *cb.Config
}
for key, group := range group.Groups {
nextPath := append(path, key)
nextPath := make([]string, len(path)+1)
copy(nextPath, path)
nextPath[len(nextPath)-1] = key
if err := recurseConfig(result, nextPath, group); err != nil {
return err
}
......
......@@ -29,6 +29,21 @@ func TestBadKey(t *testing.T) {
"Should have errored on key with illegal characters")
}
func TestConfigMapMultiGroup(t *testing.T) {
config := cb.NewConfigGroup()
config.Groups["0"] = cb.NewConfigGroup()
config.Groups["0"].Groups["1"] = cb.NewConfigGroup()
config.Groups["0"].Groups["1"].Groups["2.1"] = cb.NewConfigGroup()
config.Groups["0"].Groups["1"].Groups["2.1"].Values["Value"] = &cb.ConfigValue{}
config.Groups["0"].Groups["1"].Groups["2.2"] = cb.NewConfigGroup()
config.Groups["0"].Groups["1"].Groups["2.2"].Values["Value"] = &cb.ConfigValue{}
confMap, err := MapConfig(config)
assert.NoError(t, err)
assert.Equal(t, []string{"Channel", "0", "1", "2.1"}, confMap["[Values] /Channel/0/1/2.1/Value"].path)
assert.Equal(t, []string{"Channel", "0", "1", "2.2"}, confMap["[Values] /Channel/0/1/2.2/Value"].path)
}
func TestConfigMap(t *testing.T) {
config := cb.NewConfigGroup()
config.Groups["0DeepGroup"] = cb.NewConfigGroup()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment