[#983] node: Configure subnets

Add `subnet` sub-section to `node` section of storage node config. Add
`entries` value which allows to enumerate subnets for entrance. Add
`exit_zero` value which allows to not enter zero subnet.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-11-28 15:06:07 +03:00 committed by LeL
parent b27c72c02a
commit 0fb838b169
6 changed files with 98 additions and 0 deletions

View file

@ -35,6 +35,20 @@ func TestNodeSection(t *testing.T) {
require.Empty(t, attribute)
require.Equal(t, false, relay)
require.Equal(t, PersistentStatePathDefault, persistatePath)
var subnetCfg SubnetConfig
subnetCfg.Init(*empty)
require.False(t, subnetCfg.ExitZero())
called := false
subnetCfg.IterateSubnets(func(string) {
called = true
})
require.False(t, called)
})
const path = "../../../../config/example/node"
@ -99,6 +113,20 @@ func TestNodeSection(t *testing.T) {
address.Uint160ToString(wKey.GetScriptHash()))
require.Equal(t, "/state", persistatePath)
var subnetCfg SubnetConfig
subnetCfg.Init(*c)
require.True(t, subnetCfg.ExitZero())
var ids []string
subnetCfg.IterateSubnets(func(id string) {
ids = append(ids, id)
})
require.Equal(t, []string{"123", "456", "789"}, ids)
}
configtest.ForEachFileType(path, fileConfigTest)