From 81ddaeca169bb184b9c0e24029cbf06baaa59154 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Thu, 24 Jun 2021 15:41:19 +0300 Subject: [PATCH] [#607] config/example: Add all formats of node's network addresses Signed-off-by: Leonard Lyubich --- cmd/neofs-node/config/node/config_test.go | 48 ++++++++++++++++++----- config/example/node.env | 2 +- config/example/node.json | 4 +- config/example/node.yaml | 4 +- 4 files changed, 46 insertions(+), 12 deletions(-) diff --git a/cmd/neofs-node/config/node/config_test.go b/cmd/neofs-node/config/node/config_test.go index 00b67e424..6e49a8554 100644 --- a/cmd/neofs-node/config/node/config_test.go +++ b/cmd/neofs-node/config/node/config_test.go @@ -40,21 +40,51 @@ func TestNodeSection(t *testing.T) { var fileConfigTest = func(c *config.Config) { key := Key(c) - addr := BootstrapAddresses(c) + addrs := BootstrapAddresses(c) attributes := Attributes(c) relay := Relay(c) wKey := Wallet(c) - var expectedAddr network.AddressGroup - - err := expectedAddr.FromIterator(stringAddressGroup([]string{ - "s01.neofs.devenv:8080", - "s02.neofs.devenv:8081", - })) - require.NoError(t, err) + expectedAddr := []struct { + str string + host string + tls bool + }{ + { + str: "/dns4/localhost/tcp/8083/tls", + host: "localhost:8083", + tls: true, + }, + { + str: "/dns4/s01.neofs.devenv/tcp/8080", + host: "s01.neofs.devenv:8080", + }, + { + str: "/dns4/s02.neofs.devenv/tcp/8081", + host: "s02.neofs.devenv:8081", + }, + { + str: "/ip4/127.0.0.1/tcp/8082", + host: "127.0.0.1:8082", + }, + } require.Equal(t, "NbUgTSFvPmsRxmGeWpuuGeJUoRoi6PErcM", key.Address()) - require.Equal(t, expectedAddr, addr) + + require.EqualValues(t, len(expectedAddr), addrs.Len()) + + ind := 0 + + addrs.IterateAddresses(func(addr network.Address) bool { + require.Equal(t, expectedAddr[ind].str, addr.String()) + require.Equal(t, expectedAddr[ind].host, addr.HostAddr()) + require.Equal(t, expectedAddr[ind].tls, addr.TLSEnabled()) + + ind++ + + return false + }) + require.Equal(t, true, relay) require.Len(t, attributes, 2) diff --git a/config/example/node.env b/config/example/node.env index 42e395c4d..1a62c8641 100644 --- a/config/example/node.env +++ b/config/example/node.env @@ -11,7 +11,7 @@ NEOFS_NODE_KEY=./wallet.key NEOFS_NODE_WALLET_PATH=./wallet.json NEOFS_NODE_WALLET_ADDRESS=NcpJzXcSDrh5CCizf4K9Ro6w4t59J5LKzz NEOFS_NODE_WALLET_PASSWORD=password -NEOFS_NODE_ADDRESSES=s01.neofs.devenv:8080 s02.neofs.devenv:8081 +NEOFS_NODE_ADDRESSES=s01.neofs.devenv:8080 /dns4/s02.neofs.devenv/tcp/8081 grpc://127.0.0.1:8082 grpcs://localhost:8083 NEOFS_NODE_ATTRIBUTE_0=Price:11 NEOFS_NODE_ATTRIBUTE_1=UN-LOCODE:RU MSK NEOFS_NODE_RELAY=true diff --git a/config/example/node.json b/config/example/node.json index bd6baceee..abea66e9d 100644 --- a/config/example/node.json +++ b/config/example/node.json @@ -19,7 +19,9 @@ }, "addresses": [ "s01.neofs.devenv:8080", - "s02.neofs.devenv:8081" + "/dns4/s02.neofs.devenv/tcp/8081", + "grpc://127.0.0.1:8082", + "grpcs://localhost:8083" ], "attribute_0": "Price:11", "attribute_1": "UN-LOCODE:RU MSK", diff --git a/config/example/node.yaml b/config/example/node.yaml index c7c576f3d..f3dccb8bf 100644 --- a/config/example/node.yaml +++ b/config/example/node.yaml @@ -17,7 +17,9 @@ node: password: "password" addresses: - s01.neofs.devenv:8080 - - s02.neofs.devenv:8081 + - /dns4/s02.neofs.devenv/tcp/8081 + - grpc://127.0.0.1:8082 + - grpcs://localhost:8083 attribute_0: "Price:11" attribute_1: UN-LOCODE:RU MSK relay: true